/* ============================================
   FitTrack - Workout Application Styles
   ============================================ */

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #10b981;
    --accent: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --bg-input: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --sidebar-width: 260px;
    --topbar-height: 65px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.4);
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============ SIDEBAR ============ */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: var(--transition);
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary-light);
}

.logo i {
    font-size: 1.6rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-user {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
}

.user-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: white;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sidebar-nav {
    list-style: none;
    padding: 10px 12px;
    flex: 1;
}

.sidebar-nav .nav-section {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    padding: 15px 12px 8px;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
}

.sidebar-nav li a:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-light);
}

.sidebar-nav li.active a {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(16, 185, 129, 0.1));
    color: var(--primary-light);
    font-weight: 600;
}

.sidebar-nav li a i {
    width: 20px;
    text-align: center;
    font-size: 0.95rem;
}

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    border-radius: var(--radius-sm);
    color: var(--danger);
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    width: 100%;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
}

/* ============ MAIN CONTENT ============ */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: var(--transition);
}

.top-bar {
    position: sticky;
    top: 0;
    height: var(--topbar-height);
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 25px;
    gap: 15px;
    z-index: 100;
}

.top-bar-title h4 {
    font-weight: 700;
    font-size: 1.1rem;
}

.top-bar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 15px;
}

.today-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.content-wrapper {
    padding: 25px;
    max-width: 1400px;
}

/* ============ CARDS ============ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    transition: var(--transition);
}

.card:hover {
    border-color: rgba(99, 102, 241, 0.3);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 18px 20px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

/* Stat Cards */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--card-accent, var(--primary));
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    margin-bottom: 12px;
}

.stat-card .stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ============ FORMS ============ */
.form-control, .form-select {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 10px 15px;
    font-size: 0.9rem;
    transition: var(--transition);
}

.form-control:focus, .form-select:focus {
    background: var(--bg-input);
    border-color: var(--primary);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.input-group-text {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}

/* ============ BUTTONS ============ */
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border: none;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark), #4338ca);
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, var(--secondary), #059669);
    border: none;
    font-weight: 600;
}

.btn-outline-primary {
    border-color: var(--primary);
    color: var(--primary-light);
}

.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    padding: 8px 16px;
    font-weight: 500;
    transition: var(--transition);
}

.btn-ghost:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

/* ============ TABLES ============ */
.table {
    color: var(--text-primary);
}

.table thead th {
    background: rgba(99, 102, 241, 0.05);
    border-bottom: 2px solid var(--border-color);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
    padding: 12px 15px;
}

.table tbody td {
    border-bottom: 1px solid var(--border-color);
    padding: 12px 15px;
    font-size: 0.9rem;
    vertical-align: middle;
}

.table tbody tr:hover {
    background: rgba(99, 102, 241, 0.03);
}

/* ============ BADGES ============ */
.badge-difficulty {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
}

.badge-beginner { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.badge-intermediate { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.badge-advanced { background: rgba(239, 68, 68, 0.15); color: #f87171; }

/* ============ PROGRESS ============ */
.progress {
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
    height: 8px;
    overflow: visible;
}

.progress-bar {
    border-radius: 10px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    position: relative;
    transition: width 0.5s ease;
}

/* ============ EXERCISE CARD ============ */
.exercise-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    transition: var(--transition);
    cursor: pointer;
    height: 100%;
}

.exercise-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.exercise-card .exercise-icon {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    margin-bottom: 12px;
}

.exercise-card h6 {
    font-weight: 700;
    margin-bottom: 5px;
}

.exercise-card .muscle-group {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============ CHALLENGE CARD ============ */
.challenge-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 22px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.challenge-card::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -30px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(99, 102, 241, 0.05);
}

.challenge-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* ============ CALENDAR ============ */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar-day-header {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: 8px 0;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.calendar-day:hover {
    background: var(--bg-card-hover);
}

.calendar-day.today {
    border: 2px solid var(--primary);
    font-weight: 700;
}

.calendar-day.has-workout {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    font-weight: 600;
}

.calendar-day.has-workout::after {
    content: '';
    position: absolute;
    bottom: 3px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--secondary);
}

.calendar-day.other-month {
    color: var(--text-muted);
    opacity: 0.3;
}

/* ============ WATER TRACKER ============ */
.water-glass {
    width: 45px;
    height: 55px;
    border: 2px solid var(--border-color);
    border-radius: 0 0 8px 8px;
    display: inline-flex;
    align-items: flex-end;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    margin: 3px;
    position: relative;
    overflow: hidden;
}

.water-glass.filled {
    border-color: var(--info);
}

.water-glass.filled::before {
    content: '';
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 85%;
    background: linear-gradient(180deg, rgba(6, 182, 212, 0.3), rgba(6, 182, 212, 0.6));
    border-radius: 0 0 6px 6px;
}

.water-glass:hover {
    transform: scale(1.1);
}

/* ============ MOOD ICONS ============ */
.mood-selector label {
    cursor: pointer;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 2px solid transparent;
    transition: var(--transition);
    text-align: center;
    font-size: 1.5rem;
}

.mood-selector input:checked + label {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

/* ============ AUTH PAGES ============ */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    padding: 20px;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-lg);
}

.auth-card .auth-logo {
    text-align: center;
    margin-bottom: 30px;
}

.auth-card .auth-logo i {
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-card .auth-logo h2 {
    font-weight: 800;
    margin-top: 10px;
    font-size: 1.5rem;
}

.auth-card .auth-logo p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ============ ALERTS ============ */
.alert {
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
}

.alert-success {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.alert-info {
    background: rgba(6, 182, 212, 0.15);
    color: #22d3ee;
}

/* ============ MODAL ============ */
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
}

.modal-footer {
    border-top: 1px solid var(--border-color);
}

.btn-close {
    filter: invert(1);
}

/* ============ EMPTY STATE ============ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.3;
}

.empty-state h5 {
    color: var(--text-secondary);
    font-weight: 600;
}

/* ============ PAGE HEADER ============ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.page-header h5 {
    font-weight: 700;
    margin: 0;
}

/* ============ FILTER TABS ============ */
.filter-tabs {
    display: flex;
    gap: 5px;
    background: var(--bg-card);
    padding: 4px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.filter-tab {
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-muted);
    border: none;
    background: none;
}

.filter-tab.active {
    background: var(--primary);
    color: white;
}

.filter-tab:hover:not(.active) {
    color: var(--text-primary);
}

/* ============ RESPONSIVE ============ */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
}

@media (max-width: 767.98px) {
    .content-wrapper {
        padding: 15px;
    }
    .stat-card .stat-value {
        font-size: 1.4rem;
    }
    .top-bar {
        padding: 0 15px;
    }
    .today-date {
        display: none;
    }
}

/* ============ ANIMATIONS ============ */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.4s ease forwards;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.pulse { animation: pulse 2s infinite; }

/* ============ FOOD LOG MEAL ICONS ============ */
.meal-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.meal-breakfast { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.meal-lunch { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.meal-dinner { background: rgba(99, 102, 241, 0.15); color: #818cf8; }
.meal-snack { background: rgba(236, 72, 153, 0.15); color: #f472b6; }

/* ============ NUMBER INPUTS ============ */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    opacity: 1;
}

/* Quick-add workout row */
.workout-row {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 15px;
    margin-bottom: 10px;
    transition: var(--transition);
}

.workout-row:hover {
    border-color: var(--primary);
}

.workout-row .remove-row {
    color: var(--danger);
    cursor: pointer;
    opacity: 0.6;
    transition: var(--transition);
}

.workout-row .remove-row:hover {
    opacity: 1;
}

/* Toasts */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}
