/* ==========================================
   DESIGN SYSTEM - FitApp
   ========================================== */

:root {
    /* Colors */
    --bg-primary: #0f0f14;
    --bg-secondary: #1a1a24;
    --bg-card: #22222e;
    --bg-card-hover: #2a2a38;
    --bg-input: #16161e;
    --border-color: #2e2e3e;

    --text-primary: #f0f0f5;
    --text-secondary: #8888a0;
    --text-muted: #55556a;

    --accent-blue: #4a90d9;
    --accent-blue-dim: #3a70b0;
    --accent-green: #4caf7c;
    --accent-green-dim: #3a8a60;
    --accent-red: #e05555;
    --accent-orange: #e0943a;
    --accent-yellow: #e0c83a;
    --accent-purple: #9070d0;

    /* Macros colors */
    --color-protein: #e05555;
    --color-carbs: #e0943a;
    --color-fat: #e0c83a;
    --color-calories: #4a90d9;

    /* Muscle highlight colors */
    --muscle-primary: #e05555;
    --muscle-secondary: #e0943a;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Border radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 50%;

    /* Font sizes */
    --font-xs: 0.7rem;
    --font-sm: 0.8rem;
    --font-base: 0.95rem;
    --font-lg: 1.15rem;
    --font-xl: 1.4rem;
    --font-2xl: 1.8rem;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;

    /* Nav height */
    --nav-height: 70px;
    --header-height: 56px;

    /* Safe area */
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ==========================================
   RESET
   ========================================== */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    font-size: inherit;
    border: none;
    background: none;
    color: inherit;
    cursor: pointer;
    -webkit-appearance: none;
}

input, select, textarea {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: var(--space-sm) var(--space-md);
    outline: none;
    transition: border-color var(--transition-fast);
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent-blue);
}

input[type="number"] {
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
}

ul, ol {
    list-style: none;
}

img, svg {
    display: block;
    max-width: 100%;
}

/* ==========================================
   APP LAYOUT
   ========================================== */

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

#app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 var(--space-md);
    z-index: 100;
}

#page-title {
    font-size: var(--font-lg);
    font-weight: 700;
    color: var(--text-primary);
}

#page-content {
    flex: 1;
    padding: calc(var(--header-height) + var(--space-md)) var(--space-md) calc(var(--nav-height) + var(--safe-bottom) + var(--space-md));
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

/* ==========================================
   BOTTOM NAVIGATION
   ========================================== */

#bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: var(--space-sm) var(--space-md);
    color: var(--text-muted);
    transition: color var(--transition-fast);
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

.nav-item svg {
    width: 22px;
    height: 22px;
}

.nav-item span {
    font-size: var(--font-xs);
    font-weight: 500;
}

.nav-item.active {
    color: var(--accent-blue);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    background: var(--accent-blue);
    border-radius: 0 0 3px 3px;
}

/* ==========================================
   COMMON COMPONENTS
   ========================================== */

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-bottom: var(--space-md);
    border: 1px solid var(--border-color);
    transition: background var(--transition-fast);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}

.card-title {
    font-size: var(--font-lg);
    font-weight: 600;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: var(--font-sm);
    transition: all var(--transition-fast);
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: var(--accent-blue);
    color: white;
}

.btn-primary:active {
    background: var(--accent-blue-dim);
    transform: scale(0.97);
}

.btn-secondary {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:active {
    background: var(--bg-card-hover);
}

.btn-success {
    background: var(--accent-green);
    color: white;
}

.btn-success:active {
    background: var(--accent-green-dim);
    transform: scale(0.97);
}

.btn-sm {
    padding: var(--space-xs) var(--space-md);
    min-height: 36px;
    font-size: var(--font-xs);
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: var(--radius-full);
}

/* Tags / Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: var(--font-xs);
    font-weight: 600;
}

.badge-blue {
    background: rgba(74, 144, 217, 0.15);
    color: var(--accent-blue);
}

.badge-green {
    background: rgba(76, 175, 124, 0.15);
    color: var(--accent-green);
}

.badge-orange {
    background: rgba(224, 148, 58, 0.15);
    color: var(--accent-orange);
}

.badge-red {
    background: rgba(224, 85, 85, 0.15);
    color: var(--accent-red);
}

.badge-purple {
    background: rgba(144, 112, 208, 0.15);
    color: var(--accent-purple);
}

/* Section headers */
.section-title {
    font-size: var(--font-sm);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-md);
}

/* Divider */
.divider {
    height: 1px;
    background: var(--border-color);
    margin: var(--space-md) 0;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: var(--space-2xl) var(--space-md);
    color: var(--text-muted);
}

.empty-state svg {
    margin: 0 auto var(--space-md);
    opacity: 0.4;
}

/* Progress bar */
.progress-bar {
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width var(--transition-normal);
}

/* Circular progress */
.circular-progress {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.circular-progress svg {
    transform: rotate(-90deg);
}

.circular-progress-text {
    position: absolute;
    font-size: var(--font-sm);
    font-weight: 700;
}

/* Modal / Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    width: 100%;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
    padding: var(--space-lg);
    transform: translateY(100%);
    transition: transform var(--transition-normal);
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-handle {
    width: 40px;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    margin: 0 auto var(--space-md);
}

/* Search input */
.search-box {
    position: relative;
    margin-bottom: var(--space-md);
}

.search-box input {
    width: 100%;
    padding-left: 40px;
}

.search-box svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

/* Chip / Filter buttons */
.chips {
    display: flex;
    gap: var(--space-sm);
    overflow-x: auto;
    padding-bottom: var(--space-sm);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.chips::-webkit-scrollbar {
    display: none;
}

.chip {
    flex-shrink: 0;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: var(--font-xs);
    font-weight: 500;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.chip.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
}

/* Macro summary row */
.macro-row {
    display: flex;
    gap: var(--space-md);
}

.macro-item {
    flex: 1;
    text-align: center;
}

.macro-value {
    font-size: var(--font-lg);
    font-weight: 700;
}

.macro-label {
    font-size: var(--font-xs);
    color: var(--text-secondary);
}

/* Page transition */
.page-enter {
    animation: pageEnter var(--transition-normal) forwards;
}

@keyframes pageEnter {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: calc(var(--nav-height) + var(--safe-bottom) + var(--space-md));
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-sm);
    font-size: var(--font-sm);
    font-weight: 500;
    border: 1px solid var(--border-color);
    opacity: 0;
    transition: all var(--transition-normal);
    z-index: 300;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Day schedule badges */
.day-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: var(--font-sm);
    font-weight: 600;
}

.day-push { background: rgba(224, 85, 85, 0.12); color: var(--accent-red); }
.day-pull { background: rgba(74, 144, 217, 0.12); color: var(--accent-blue); }
.day-legs { background: rgba(76, 175, 124, 0.12); color: var(--accent-green); }
.day-swim { background: rgba(144, 112, 208, 0.12); color: var(--accent-purple); }
.day-rest { background: rgba(136, 136, 160, 0.1); color: var(--text-secondary); }

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 2px;
}

/* Utility classes */
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.text-sm { font-size: var(--font-sm); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
