/* ===================================
   NossenCoaching - Main Stylesheet
   =================================== */

/* CSS Variables for easy theming */
:root {
    /* Professional gradient - clean slate/blue theme */
    --primary-gradient: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    --secondary-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --success-gradient: linear-gradient(135deg, #047857 0%, #059669 100%);
    --danger-gradient: linear-gradient(135deg, #b91c1c 0%, #dc2626 100%);
    --accent-gradient: linear-gradient(135deg, #0ea5e9 0%, #3b82f6 100%);

    /* Dark backgrounds - professional slate tones */
    --bg-dark: #0f172a;
    --bg-darker: #020617;
    --bg-card: #1e293b;
    --bg-card-hover: #334155;
    --bg-input: rgba(255, 255, 255, 0.04);
    --bg-input-hover: rgba(255, 255, 255, 0.06);
    --bg-secondary: rgba(255, 255, 255, 0.02);

    /* Text colors - higher contrast */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-accent: #3b82f6;

    /* Border colors - subtle */
    --border-color: rgba(148, 163, 184, 0.1);
    --border-hover: rgba(59, 130, 246, 0.3);
    --border-focus: rgba(59, 130, 246, 0.5);

    /* Accent colors - professional palette */
    --accent-primary: #3b82f6;
    --accent-teal: #14b8a6;
    --accent-cyan: #06b6d4;
    --accent-blue: #0ea5e9;
    --accent-purple: #8b5cf6;
    --accent-green: #10b981;
    --accent-emerald: #059669;
    --accent-red: #ef4444;
    --accent-orange: #f97316;
    --accent-yellow: #eab308;

    /* Refined shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.1);
    --shadow-glow-strong: 0 0 30px rgba(59, 130, 246, 0.2);

    /* Border radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* Light Mode Theme */
body.light-mode {
    /* Light backgrounds - clean white/gray tones */
    --bg-dark: #f8fafc;
    --bg-darker: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --bg-input: rgba(15, 23, 42, 0.04);
    --bg-input-hover: rgba(15, 23, 42, 0.06);
    --bg-secondary: rgba(15, 23, 42, 0.02);

    /* Text colors - inverted for readability */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-accent: #1e40af;

    /* Border colors */
    --border-color: rgba(15, 23, 42, 0.1);
    --border-hover: rgba(59, 130, 246, 0.4);
    --border-focus: rgba(59, 130, 246, 0.6);

    /* Refined shadows for light mode */
    --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.1);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.12);
    --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.08);
    --shadow-glow-strong: 0 0 30px rgba(59, 130, 246, 0.12);
}

/* Light mode specific component overrides */
body.light-mode .navbar {
    background: rgba(255, 255, 255, 0.95);
    border-bottom: 1px solid rgba(15, 23, 42, 0.1);
}

body.light-mode .nav-tab:hover {
    background: rgba(59, 130, 246, 0.08);
}

body.light-mode .nav-tab.active {
    background: rgba(59, 130, 246, 0.1);
}

body.light-mode .client-selector {
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

body.light-mode .client-selector:hover {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.35);
}

body.light-mode .user-role {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.25);
    color: #1e40af;
}

body.light-mode .theme-toggle,
body.light-mode .logout-btn {
    background: rgba(15, 23, 42, 0.04);
    border: 1px solid rgba(15, 23, 42, 0.1);
}

body.light-mode .theme-toggle:hover {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.3);
}

body.light-mode .logout-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: #dc2626;
}

/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Background Effect - subtle professional gradient */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse at 20% 10%, rgba(59, 130, 246, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 90%, rgba(14, 165, 233, 0.02) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

body.light-mode::before {
    background:
        radial-gradient(ellipse at 20% 10%, rgba(59, 130, 246, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 90%, rgba(14, 165, 233, 0.03) 0%, transparent 50%);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
}

a {
    color: var(--accent-teal);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-cyan);
}

/* ===================================
   Login Screen
   =================================== */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    position: relative;
}

.login-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 3rem;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    position: relative;
    overflow: hidden;
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary-gradient);
}

.login-logo {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    background: var(--primary-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    box-shadow: var(--shadow-md), 0 0 30px rgba(139, 92, 246, 0.3);
}

.login-title {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-subtitle {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 1rem;
}

.role-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.role-btn {
    padding: 1.25rem 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.role-btn:hover {
    background: var(--primary-gradient);
    border-color: transparent;
    transform: translateY(-3px);
    box-shadow: var(--shadow-md), 0 0 30px rgba(139, 92, 246, 0.3);
}

.role-btn .icon {
    font-size: 1.25rem;
}

/* Login Form Styles */
.login-card .form-group {
    text-align: left;
    margin-bottom: 1rem;
}

.login-card .form-label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.login-card .form-input {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.login-card .form-input:focus {
    outline: none;
    border-color: var(--accent-teal);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
}

.login-card .form-input::placeholder {
    color: var(--text-muted);
}

.login-switch {
    margin-top: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.login-switch a {
    color: var(--accent-teal);
    font-weight: 600;
}

.login-switch a:hover {
    color: var(--accent-cyan);
}

.login-error {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-md);
    color: var(--accent-red);
    font-size: 0.9rem;
    text-align: center;
}

.login-loading {
    margin-top: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: var(--text-secondary);
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-purple);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Invite Code Styles */
.invite-code-box {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    text-align: center;
}

.invite-code {
    font-size: 2rem;
    font-weight: 800;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.2em;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    padding: 0.5rem;
}

/* Subsection Styles */
.subsection-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

/* Client/User Card Styles */
.client-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
    transition: all var(--transition-fast);
}

.client-card:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
}

.client-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.client-avatar {
    width: 48px;
    height: 48px;
    background: var(--primary-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: white;
    font-weight: 700;
}

.client-details h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.client-details p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.client-status {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.client-status.active {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
}

.client-status.pending {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-orange);
}

/* Invite Card Styles */
.invite-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
}

.invite-card-info {
    flex: 1;
}

.invite-card-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.invite-card-code {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: var(--accent-teal);
    font-weight: 600;
}

.invite-card-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.invite-card-actions {
    display: flex;
    gap: 0.5rem;
}

/* ===================================
   App Container
   =================================== */
.app-container {
    display: none;
}

.app-container.active {
    display: block;
}

/* ===================================
   Navbar
   =================================== */
.navbar {
    background: rgba(15, 20, 25, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 2rem 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Top row: logo left, user-info right */
.navbar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding-bottom: 0.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 800;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-gradient);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.logo-text {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-tabs {
    display: flex;
    gap: 0.25rem;
    background: var(--bg-input);
    padding: 0.25rem;
    border-radius: var(--radius-md);
}

.nav-tab {
    padding: 0.625rem 1.25rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-normal);
    white-space: nowrap;
}

.nav-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-tab.active {
    background: var(--primary-gradient);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.user-role {
    padding: 0.35rem 0.8rem;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.35);
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 700;
    color: #a5b4fc;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.85rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal);
    font-size: 0.82rem;
    font-family: inherit;
}

.logout-btn:hover {
    background: rgba(248, 113, 113, 0.12);
    border-color: rgba(248, 113, 113, 0.4);
    color: #fca5a5;
}

/* Theme Toggle Button */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-normal);
    padding: 0;
}

.theme-toggle:hover {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.4);
    color: #60a5fa;
    transform: rotate(180deg);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
    transition: transform var(--transition-normal);
}

/* Client Selector (Coach Only) */
.client-selector {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.38rem 0.75rem;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 20px;
    transition: all var(--transition-fast);
}

.client-selector:hover {
    background: rgba(99, 102, 241, 0.14);
    border-color: rgba(99, 102, 241, 0.45);
}

.client-selector-icon {
    color: var(--accent-primary);
    flex-shrink: 0;
    opacity: 0.8;
}

.client-selector-chevron {
    color: var(--text-muted);
    flex-shrink: 0;
    pointer-events: none;
}

.client-select {
    background: transparent;
    border: none;
    color: #a5b4fc;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
    min-width: 120px;
    max-width: 180px;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
}

.client-select option {
    background: #161b2e;
    color: var(--text-primary);
}

.client-select:focus {
    outline: none;
}

/* Active client indicator */
.client-selector.has-client {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.5);
}

/* ===================================
   Main Content
   =================================== */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.section {
    display: none;
}

.section.active {
    display: block;
    animation: fadeIn 0.4s ease-out;
}

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

/* ===================================
   Cards
   =================================== */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: all var(--transition-normal);
}

.card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-title .icon {
    font-size: 1.5rem;
}

/* ===================================
   Buttons
   =================================== */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-normal);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary-gradient);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md), 0 0 30px rgba(139, 92, 246, 0.3);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--accent-teal);
    border: 1px solid rgba(20, 184, 166, 0.3);
}

.btn-secondary:hover {
    background: rgba(20, 184, 166, 0.15);
    border-color: var(--accent-teal);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-red);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: var(--accent-red);
    border-color: var(--accent-red);
    color: var(--text-primary);
}

.btn-success {
    background: var(--success-gradient);
    color: var(--text-primary);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md), 0 0 30px rgba(16, 185, 129, 0.3);
}

/* ===================================
   Forms
   =================================== */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: all var(--transition-fast);
}

.form-textarea {
    resize: vertical;
    min-height: 120px;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent-teal);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}

.form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6,9 12,15 18,9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1rem;
    padding-right: 2.5rem;
}

.form-select option {
    background: var(--bg-dark);
    color: var(--text-primary);
}

/* Range Input Slider */
.form-range {
    width: 100%;
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.form-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.4);
}

.form-range::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 10px rgba(99, 102, 241, 0.6);
}

.form-range::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.4);
}

.form-range::-moz-range-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 10px rgba(99, 102, 241, 0.6);
}

/* Check-in Item */
.checkin-item {
    transition: background-color 0.2s ease;
}

.checkin-item:hover {
    background: var(--bg-card-hover);
}

/* ===================================
   Modal
   =================================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 1000;
    padding: 2rem;
    overflow-y: auto;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 2rem;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
}

.close-btn {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 1.25rem;
}

.close-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--accent-red);
    color: var(--accent-red);
}

/* ===================================
   Stats Grid
   =================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    transition: all var(--transition-normal);
}

.stat-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary-gradient);
}

.stat-card.cyan::before {
    background: var(--secondary-gradient);
}

.stat-card.green::before {
    background: var(--success-gradient);
}

.stat-card.orange::before {
    background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
}

.stat-icon {
    width: 48px;
    height: 48px;
    background: rgba(139, 92, 246, 0.15);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.stat-card.cyan .stat-icon {
    background: rgba(6, 182, 212, 0.15);
}

.stat-card.green .stat-icon {
    background: rgba(16, 185, 129, 0.15);
}

.stat-card.orange .stat-icon {
    background: rgba(245, 158, 11, 0.15);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2.25rem;
    font-weight: 800;
    margin-bottom: 0.25rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-card.cyan .stat-value {
    background: var(--secondary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-card.green .stat-value {
    background: var(--success-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-card.orange .stat-value {
    background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-change {
    font-size: 0.875rem;
    color: var(--text-muted);
}

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

.progress-fill {
    height: 100%;
    background: var(--primary-gradient);
    border-radius: 4px;
    transition: width var(--transition-slow);
}

/* ===================================
   Items (Workout, Meal, Test)
   =================================== */
.workout-item,
.meal-item,
.test-item {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1rem;
    transition: all var(--transition-normal);
}

.workout-item:hover,
.meal-item:hover,
.test-item:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    gap: 1rem;
}

.item-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.item-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.item-actions {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    padding: 0.5rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 1rem;
}

.icon-btn:hover {
    background: rgba(20, 184, 166, 0.15);
    border-color: var(--accent-teal);
    color: var(--accent-teal);
}

.icon-btn.delete:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--accent-red);
    color: var(--accent-red);
}

/* Exercise List */
.exercise-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.exercise-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    gap: 0.5rem;
}

.exercise-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--accent-teal);
    border-radius: 50%;
}

/* Macros Display */
.macros-display {
    display: flex;
    gap: 1rem;
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.macro-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.macro-item.protein { color: var(--accent-red); }
.macro-item.carbs { color: var(--accent-orange); }
.macro-item.fat { color: var(--accent-cyan); }

/* Status Badge */
.status-badge {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.875rem;
}

.status-badge.excellent {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
}

.status-badge.good {
    background: rgba(6, 182, 212, 0.15);
    color: var(--accent-cyan);
}

.status-badge.average {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-orange);
}

.status-badge.needs-improvement {
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
}

/* ===================================
   Chat
   =================================== */
.chat-container {
    height: 500px;
    display: flex;
    flex-direction: column;
}

.messages-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message {
    display: flex;
    gap: 0.75rem;
    max-width: 75%;
    animation: messageIn 0.3s ease-out;
}

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

.message.other {
    align-self: flex-start;
}

.message.own {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-content {
    background: var(--bg-input);
    padding: 0.875rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    line-height: 1.5;
    max-width: 100%;
}

.message.own .message-content {
    background: var(--primary-gradient);
    border: none;
    color: white;
}

.message-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
    text-align: right;
}

.message.other .message-time {
    text-align: left;
}

.message-input-area {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

.message-input {
    flex: 1;
    padding: 0.875rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: all var(--transition-fast);
}

.message-input:focus {
    outline: none;
    border-color: var(--accent-teal);
}

/* ===================================
   Empty State
   =================================== */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    font-size: 1rem;
    max-width: 300px;
    margin: 0 auto;
}

/* ===================================
   Calendar
   =================================== */
.calendar-container {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border-color);
}

.calendar-nav-btn {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.calendar-nav-btn:hover {
    background: rgba(20, 184, 166, 0.15);
    border-color: var(--accent-teal);
}

.calendar-month {
    font-size: 1.1rem;
    font-weight: 600;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.calendar-day-header {
    padding: 0.75rem;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-color);
}

.calendar-day {
    min-height: 80px;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-width: 0 1px 1px 0;
    transition: all var(--transition-fast);
}

.calendar-day:hover {
    background: rgba(20, 184, 166, 0.05);
}

.calendar-day.other-month {
    opacity: 0.3;
}

.calendar-day.today {
    background: rgba(20, 184, 166, 0.1);
}

.calendar-date {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.calendar-day.today .calendar-date {
    background: var(--primary-gradient);
    color: white;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.calendar-event {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.calendar-event.workout {
    background: rgba(20, 184, 166, 0.3);
    color: var(--accent-teal);
}

.calendar-event.meal {
    background: rgba(16, 185, 129, 0.3);
    color: var(--accent-green);
}

.calendar-event.test {
    background: rgba(6, 182, 212, 0.3);
    color: var(--accent-cyan);
}

/* ===================================
   Charts Container
   =================================== */
.chart-container {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.chart-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

/* ===================================
   Responsive Design
   =================================== */
@media (max-width: 768px) {
    .main-content {
        padding: 1rem;
    }

    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .nav-tab {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }

    .modal-content {
        padding: 1.5rem;
        margin: 1rem;
        border-radius: var(--radius-lg);
    }

    .message {
        max-width: 85%;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .stat-value {
        font-size: 1.75rem;
    }

    .calendar-day {
        min-height: 60px;
    }

    .calendar-event {
        font-size: 0.6rem;
    }
}

@media (max-width: 480px) {
    .login-card {
        padding: 2rem 1.5rem;
    }

    .login-title {
        font-size: 1.5rem;
    }

    .logo-text {
        display: none;
    }

    .user-info {
        flex-wrap: wrap;
        justify-content: center;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ===================================
   Scrollbar Styling
   =================================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ===================================
   Utilities
   =================================== */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-muted);
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* Loading Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-purple);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: toastIn 0.3s ease-out;
    min-width: 280px;
}

.toast.success {
    border-color: var(--accent-green);
}

.toast.error {
    border-color: var(--accent-red);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* ===================================
   Image Gallery
   =================================== */
.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.image-card {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--transition-normal);
    border: 1px solid var(--border-color);
}

.image-card:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-md);
    border-color: var(--accent-teal);
}

.image-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.75rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    color: white;
}

.image-card-date {
    font-size: 0.75rem;
    font-weight: 600;
}

.image-card-category {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.image-card-actions {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.image-card:hover .image-card-actions {
    opacity: 1;
}

.image-card-actions .icon-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    border: none;
}

/* Image Upload Area */
.image-upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 2rem;
    text-align: center;
    transition: all var(--transition-fast);
    cursor: pointer;
}

.image-upload-area:hover {
    border-color: var(--accent-teal);
    background: rgba(20, 184, 166, 0.05);
}

.image-upload-area.dragover {
    border-color: var(--accent-teal);
    background: rgba(20, 184, 166, 0.1);
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
}

.upload-placeholder p {
    margin: 0;
    font-weight: 500;
}

.image-preview {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--radius-md);
    object-fit: contain;
}

/* Image Viewer Modal */
.image-viewer-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.image-viewer-close {
    position: absolute;
    top: -50px;
    right: 0;
    background: rgba(0, 0, 0, 0.5);
}

.viewer-image {
    max-width: 100%;
    max-height: 70vh;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.viewer-info {
    margin-top: 1rem;
    text-align: center;
    color: var(--text-secondary);
}

.viewer-info p {
    margin: 0.25rem 0;
}

/* Empty Image Gallery State */
.image-gallery-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.image-gallery-empty svg {
    opacity: 0.3;
    margin-bottom: 1rem;
}

/* ===================================
   Client Logging Styles
   =================================== */

.food-logs-header,
.workout-logs-header {
    padding: 0.75rem 1rem;
    background: rgba(45, 212, 191, 0.1);
    border-bottom: 1px solid var(--border-color);
}

.food-logs-header h4,
.workout-logs-header h4 {
    margin: 0;
    font-size: 0.9rem;
    color: var(--accent-teal);
    font-weight: 500;
}

/* Plan-based workout logging rows */
.plan-log-exercise-row {
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

.plan-log-exercise-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
}

.plan-log-exercise-planned {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 0.6rem;
}

.plan-log-exercise-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.5rem;
}

.plan-log-input-group label {
    display: block;
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-bottom: 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.plan-log-input {
    padding: 0.4rem 0.5rem !important;
    font-size: 0.85rem !important;
    text-align: center;
}

.log-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s ease;
}

.log-item:hover {
    background: var(--bg-input-hover);
}

.log-item:last-child {
    border-bottom: none;
}

.log-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.log-type {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.log-description,
.log-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.log-stats {
    display: flex;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: var(--accent-cyan);
}

.log-stats span {
    white-space: nowrap;
}

/* Form row for side-by-side inputs */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 480px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* ===================================
   Bulk Workout/Meal Forms - Dark Mode
   =================================== */

.bulk-workout-form .form-input,
.bulk-workout-form .form-textarea,
.bulk-meal-form .form-input,
.bulk-meal-form .form-select {
    background: rgba(15, 23, 42, 0.6) !important;
    border: 2px solid rgba(45, 212, 191, 0.2) !important;
    color: #f1f5f9 !important;
    font-weight: 500;
}

.bulk-workout-form .form-input::placeholder,
.bulk-workout-form .form-textarea::placeholder,
.bulk-meal-form .form-input::placeholder {
    color: #64748b !important;
    font-weight: 400;
}

.bulk-workout-form .form-input:focus,
.bulk-workout-form .form-textarea:focus,
.bulk-meal-form .form-input:focus,
.bulk-meal-form .form-select:focus {
    outline: none !important;
    border-color: #2dd4bf !important;
    box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.2) !important;
    background: rgba(15, 23, 42, 0.8) !important;
}

.bulk-workout-form .form-label,
.bulk-meal-form .form-label {
    color: var(--text-secondary) !important;
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

/* Ensure select dropdowns match dark theme */
.bulk-meal-form .form-select option {
    background: var(--bg-dark);
    color: var(--text-primary);
}

/* ===================================
   Exercise Library
   =================================== */

.exercises-filters {
    margin-bottom: 1.5rem;
}

.exercise-category-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.filter-btn {
    padding: 0.35rem 0.85rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}

.filter-btn:hover {
    border-color: var(--accent-teal);
    color: var(--accent-teal);
}

.filter-btn.active {
    background: rgba(45, 212, 191, 0.15);
    border-color: var(--accent-teal);
    color: var(--accent-teal);
    font-weight: 600;
}

.exercises-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.exercise-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.exercise-card:hover {
    border-color: var(--accent-teal);
    background: rgba(45, 212, 191, 0.05);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(45, 212, 191, 0.15);
}

.exercise-card-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.exercise-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}

#exercisePickerModal {
    z-index: 1100;
}

.exercise-badge-category {
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.exercise-badge-category.bryst   { background: rgba(239,68,68,0.12);   color: #ef4444; }
.exercise-badge-category.rygg    { background: rgba(59,130,246,0.12);  color: #3b82f6; }
.exercise-badge-category.skuldre { background: rgba(139,92,246,0.12);  color: #8b5cf6; }
.exercise-badge-category.armer   { background: rgba(245,158,11,0.12);  color: #f59e0b; }
.exercise-badge-category.ben     { background: rgba(16,185,129,0.12);   color: #10b981; }
.exercise-badge-category.kjerne  { background: rgba(20,184,166,0.15);  color: #2dd4bf; }
.exercise-badge-category.helkropp{ background: rgba(14,165,233,0.15);  color: #38bdf8; }
.exercise-badge-category.kondisjon{ background: rgba(249,115,22,0.15); color: #fb923c; }
.exercise-badge-category.custom  { background: rgba(139,92,246,0.15);  color: #a78bfa; }

/* Food category badges */
.exercise-badge-category.protein    { background: rgba(239,68,68,0.15);   color: #f87171; }
.exercise-badge-category.meieri     { background: rgba(59,130,246,0.15);  color: #93c5fd; }
.exercise-badge-category.kornvarer  { background: rgba(245,158,11,0.15);  color: #fbbf24; }
.exercise-badge-category.frukt      { background: rgba(16,185,129,0.12);   color: #10b981; }
.exercise-badge-category.gronnsaker { background: rgba(20,184,166,0.12);  color: #14b8a6; }
.exercise-badge-category.fett       { background: rgba(139,92,246,0.12);  color: #8b5cf6; }
.exercise-badge-category.nodter     { background: rgba(249,115,22,0.12);  color: #f97316; }
.exercise-badge-category.drikke     { background: rgba(14,165,233,0.12);  color: #0ea5e9; }
.exercise-badge-category.snacks     { background: rgba(236,72,153,0.15);  color: #f9a8d4; }

.exercise-badge-difficulty {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.exercise-badge-equipment {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* ===================================
   Exercise Form List (in workout modal)
   =================================== */

.exercise-form-list {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    min-height: 60px;
    padding: 0.5rem;
    background: rgba(15, 23, 42, 0.4);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.exercise-form-empty {
    color: var(--text-muted);
    font-size: 0.875rem;
    text-align: center;
    padding: 0.75rem;
}

.exercise-form-row {
    display: flex;
    align-items: center;
    background: rgba(45, 212, 191, 0.07);
    border: 1px solid rgba(45, 212, 191, 0.2);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    gap: 0.75rem;
    cursor: default;
    transition: opacity 0.15s, background 0.15s;
}

.exercise-form-row.dragging {
    opacity: 0.4;
}

.exercise-form-row.drag-over {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--accent-primary);
}

.exercise-drag-handle {
    cursor: grab;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    padding: 0.1rem 0.2rem;
    flex-shrink: 0;
    touch-action: none;
}

.exercise-drag-handle:active {
    cursor: grabbing;
}

.exercise-form-row-name {
    flex: 1;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.exercise-form-row-details {
    font-size: 0.82rem;
    color: var(--accent-teal);
    font-weight: 600;
    white-space: nowrap;
}

.exercise-form-row-delete {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0.2rem;
    display: flex;
    align-items: center;
    border-radius: 4px;
    transition: color 0.15s;
}

.exercise-form-row-delete:hover {
    color: #f87171;
}

/* ===================================
   Exercise Picker List
   =================================== */

.picker-exercise-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 0.4rem;
    cursor: pointer;
    transition: all 0.15s ease;
    background: var(--bg-secondary);
}

.picker-exercise-item:hover {
    border-color: var(--accent-teal);
    background: rgba(45, 212, 191, 0.07);
}

.picker-exercise-item-name {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.picker-exercise-item-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

@media (max-width: 600px) {
    .exercises-grid {
        grid-template-columns: 1fr;
    }
    .exercise-category-filters {
        gap: 0.35rem;
    }
    .filter-btn {
        font-size: 0.8rem;
        padding: 0.3rem 0.65rem;
    }
}

/* ===================================
   iPhone / Mobile PWA
   =================================== */

/* Safe areas for notch and home bar */
@supports (padding: env(safe-area-inset-top)) {
    @media (display-mode: standalone) {
        .navbar {
            padding-top: calc(0.75rem + env(safe-area-inset-top));
        }
        .main-content {
            padding-bottom: calc(1rem + env(safe-area-inset-bottom));
        }
    }
}

@media (max-width: 640px) {

    /* ---- Navbar ---- */
    .navbar {
        padding: 0.6rem 0.75rem 0;
    }

    .navbar-top {
        padding-bottom: 0.4rem;
    }

    .logo-icon {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    .logo-text {
        font-size: 0.9rem;
    }

    /* user-info: compact on mobile */
    .user-info {
        gap: 0.4rem;
        flex-wrap: nowrap;
    }

    .user-role {
        font-size: 0.72rem;
        max-width: 70px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Hide "Logg ut" text — show icon only */
    .logout-btn {
        padding: 0.4rem 0.45rem;
        min-height: 36px;
        gap: 0;
    }
    .logout-text { display: none; }

    /* Hide role badge (coach/client) — saves space on mobile */
    .user-role { display: none; }

    /* Client selector compact */
    .client-selector {
        max-width: 130px;
    }
    .client-select {
        font-size: 0.75rem;
        padding: 0.25rem 1.4rem 0.25rem 0.5rem;
    }

    /* Tabs: horizontal scroll */
    .nav-tabs {
        background: transparent;
        padding: 0;
        border-radius: 0;
        gap: 0;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        flex-wrap: nowrap;
        border-top: 1px solid var(--border-color);
    }
    .nav-tabs::-webkit-scrollbar { display: none; }

    .nav-tab {
        flex-shrink: 0;
        padding: 0.55rem 0.9rem;
        font-size: 0.78rem;
        border-bottom: 2px solid transparent;
        border-radius: 0;
        white-space: nowrap;
        background: transparent;
    }
    .nav-tab.active {
        border-bottom-color: var(--accent-primary);
        background: transparent;
        color: var(--accent-primary);
    }

    /* ---- Main content ---- */
    .main-content {
        padding: 0.75rem;
    }

    /* ---- Cards ---- */
    .card {
        border-radius: 10px;
        margin-bottom: 0.75rem;
    }
    .card-header {
        padding: 0.875rem 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    .card-title {
        font-size: 0.95rem;
    }

    /* ---- Buttons ---- */
    .btn {
        min-height: 44px;
        padding: 0.55rem 1rem;
        font-size: 0.85rem;
    }
    .btn-sm {
        min-height: 38px;
        padding: 0.4rem 0.7rem;
        font-size: 0.78rem;
    }
    .icon-btn {
        min-width: 44px;
        min-height: 44px;
        padding: 0.5rem;
    }

    /* ---- Stats: 2 columns ---- */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }
    .stat-card { padding: 0.75rem; }
    .stat-value { font-size: 1.4rem; }
    .stat-label { font-size: 0.68rem; }
    .stat-change { font-size: 0.68rem; }

    /* ---- Forms: font-size 16px prevents iOS zoom ---- */
    .form-input,
    .form-select,
    .form-textarea {
        font-size: 16px;
        min-height: 44px;
    }
    .form-group { margin-bottom: 0.875rem; }
    .form-label { font-size: 0.82rem; }

    /* ---- Modals: slide up from bottom ---- */
    .modal { align-items: flex-end; }
    .modal-content {
        margin: 0;
        border-radius: 20px 20px 0 0;
        max-height: 90vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0 1rem 1.5rem;
        width: 100%;
    }
    .modal-content::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        background: var(--border-color);
        border-radius: 2px;
        margin: 0.75rem auto 1rem;
    }
    .modal-title { font-size: 1.05rem; }

    /* ---- Lists ---- */
    .workout-item, .meal-item { padding: 0.75rem; }
    .item-title { font-size: 0.875rem; }
    .item-subtitle { font-size: 0.78rem; }
    .exercise-badge { font-size: 0.72rem; padding: 0.2rem 0.45rem; }
    .macros-display { gap: 0.4rem; }
    .macro-item { font-size: 0.72rem; padding: 0.18rem 0.4rem; }

    /* ---- Chat, Calendar, misc ---- */
    .chat-input { font-size: 16px; }
    .calendar-day { min-height: 48px; padding: 0.2rem; }
    .calendar-day-number { font-size: 0.72rem; }
    .calendar-event { font-size: 0.58rem; }
    .empty-state { padding: 1.5rem 1rem; }
    .empty-state-icon svg { width: 36px; height: 36px; }
}

/* iPhone SE and smaller */
@media (max-width: 375px) {
    .nav-tab { padding: 0.5rem 0.65rem; font-size: 0.72rem; }
    .logo-text { font-size: 0.82rem; }
}
