/* Phase 1: Self-hosted fonts for performance */
@font-face {
    font-family: 'Inter';
    src: url('/static/fonts/inter-400.ttf') format('truetype');
    font-weight: 400;
    font-display: swap;
    font-style: normal;
}

@font-face {
    font-family: 'Inter';
    src: url('/static/fonts/inter-500.ttf') format('truetype');
    font-weight: 500;
    font-display: swap;
    font-style: normal;
}

@font-face {
    font-family: 'Inter';
    src: url('/static/fonts/inter-600.ttf') format('truetype');
    font-weight: 600;
    font-display: swap;
    font-style: normal;
}

@font-face {
    font-family: 'Inter';
    src: url('/static/fonts/inter-700.ttf') format('truetype');
    font-weight: 700;
    font-display: swap;
    font-style: normal;
}

:root {
    --primary-color: #dc2626;
    --secondary-color: #1f2937;
    --accent-color: #f59e0b;
    --success-color: #10b981;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --border-color: #e5e7eb;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Desktop containers maintain proper max-width for optimal readability */

/* Mobile Top Bar */
.mobile-top-bar {
    background-color: var(--bg-primary);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
    display: none;
    width: 100%;
}

.mobile-top-bar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 20px;
}

/* Mobile Sidebar Toggle */
.mobile-sidebar-toggle {
    display: flex;
    flex-direction: column;
    cursor: pointer;
    padding: 8px;
    background: none;
    border: none;
    z-index: 1001;
}

.mobile-sidebar-toggle span {
    width: 25px;
    height: 3px;
    background: var(--text-primary);
    margin: 3px 0;
    transition: all 0.3s ease;
    border-radius: 3px;
}

.mobile-sidebar-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.mobile-sidebar-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-sidebar-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* Mobile Sidebar Overlay */
.mobile-sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none; /* Prevent blocking touches when hidden */
}

.mobile-sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto; /* Re-enable touch events when overlay is active */
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 20px;
    position: relative;
}

.nav-brand h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
    font-weight: 700;
}

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

.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-links a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: var(--primary-color);
}

/* Mobile navigation toggle */
.mobile-nav-toggle {
    display: none;
    flex-direction: column;
    cursor: pointer;
    padding: 8px;
    background: none;
    border: none;
}

.mobile-nav-toggle span {
    width: 25px;
    height: 3px;
    background: var(--text-primary);
    margin: 3px 0;
    transition: all 0.3s ease;
    border-radius: 3px;
}

.mobile-nav-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.mobile-nav-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-nav-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* App Layout System */
.app-layout {
    display: grid;
    grid-template-columns: 250px minmax(0, 1200px) 1fr;
    grid-template-areas: "sidebar content empty";
    justify-content: center;
    min-height: 100vh;
    background-color: var(--bg-secondary);
}

/* Mobile/Desktop Responsive Classes */
.mobile-only {
    display: none;
}

.desktop-only {
    display: block;
}

/* Left Sidebar Navigation */
.sidebar {
    background-color: var(--secondary-color);
    color: white;
    padding: 0;
    box-shadow: var(--shadow-lg);
    position: fixed;
    top: 0;
    left: 0;
    width: 250px;
    height: 100vh;
    overflow-y: auto;
    z-index: 150;
}

.sidebar-header {
    padding: 2rem 1.5rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(135deg, var(--secondary-color) 0%, #111827 100%);
}

.sidebar-header h2 {
    color: var(--primary-color);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.sidebar-tagline {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.875rem;
    font-weight: 400;
}

.sidebar-menu {
    padding: 1rem 0;
}

.menu-section {
    margin-bottom: 1.5rem;
}

.menu-section-header {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 0.5rem;
}

.menu-section-header .menu-icon {
    margin-right: 0.75rem;
    font-size: 1rem;
}

.menu-items {
    list-style: none;
    padding: 0;
    margin: 0;
}

.menu-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.2s ease;
    font-weight: 400;
    border-left: 3px solid transparent;
}

.menu-link:hover {
    background-color: rgba(220, 38, 38, 0.1);
    color: white;
    border-left-color: var(--primary-color);
    transform: translateX(2px);
}

.menu-link.active {
    background-color: rgba(220, 38, 38, 0.2);
    color: white;
    border-left-color: var(--primary-color);
    font-weight: 500;
}

.menu-link .menu-icon {
    margin-right: 0.75rem;
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

.menu-link .menu-text {
    font-size: 0.875rem;
}

/* Main Content Area */
.main-content {
    grid-area: content;
    margin: 0;
    min-height: 100vh;
    background-color: var(--bg-secondary);
}

.content-container {
    max-width: none;
    margin: 0;
    padding: 2rem;
    width: 100%;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 4rem 0;
}

.hero h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.lead {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 3rem;
}

/* Features */
.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.feature-card {
    background: var(--bg-primary);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.feature-card h3 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

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

.btn-primary:hover {
    background-color: #b91c1c;
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: #111827;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.cta-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Training Pillars */
.training-pillars {
    padding: 3rem 0;
}

.training-pillars h2 {
    text-align: center;
    margin-bottom: 2rem;
    font-size: 2rem;
}

.pillars-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.pillar {
    text-align: center;
    padding: 1.5rem;
    background: var(--bg-primary);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.pillar h4 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

/* Forms */
.profile-container {
    max-width: 800px; /* Professional form width */
    margin: 2rem auto; /* Center the form */
    background: var(--bg-primary);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.profile-form {
    margin-top: 2rem;
}

.form-section {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.form-section:last-child {
    border-bottom: none;
}

.form-section h3 {
    margin-bottom: 1rem;
    color: var(--secondary-color);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group {
    margin-bottom: 1rem;
}

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

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.equipment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
}

.form-actions {
    margin-top: 2rem;
    text-align: center;
}

/* Workout Page */
.workout-container {
    max-width: 900px; /* Optimal workout display width */
    margin: 2rem auto; /* Center the workout */
    padding: 0 2rem;
}

.workout-header {
    background: var(--bg-primary);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.workout-meta {
    display: flex;
    gap: 2rem;
    margin-top: 1rem;
    color: var(--text-secondary);
}

.exercise-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.exercise-card {
    background: var(--bg-primary);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

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

.exercise-header h3 {
    color: var(--text-primary);
    font-size: 1.25rem;
}

.difficulty {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
}

.difficulty-beginner {
    background-color: #d1fae5;
    color: #065f46;
}

.difficulty-intermediate {
    background-color: #fef3c7;
    color: #92400e;
}

.difficulty-advanced {
    background-color: #fee2e2;
    color: #991b1b;
}

.exercise-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
}

.detail-row {
    display: flex;
    gap: 0.5rem;
}

.detail-row .label {
    font-weight: 500;
    color: var(--text-secondary);
}

.detail-row .value {
    color: var(--text-primary);
}

.notes {
    margin-top: 1rem;
    padding: 0.75rem;
    background-color: var(--bg-secondary);
    border-radius: 4px;
}

.note {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Exercise Logging */
.exercise-log {
    margin-top: 1rem;
    padding: 1rem;
    background-color: var(--bg-secondary);
    border-radius: 4px;
}

.exercise-log h4 {
    margin-bottom: 1rem;
    color: var(--secondary-color);
}

.log-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.log-form input,
.log-form textarea {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.set-row {
    display: grid;
    grid-template-columns: auto 1fr 1fr;
    gap: 0.5rem;
    align-items: center;
}

.set-row label {
    font-weight: 500;
    color: var(--text-secondary);
}

.workout-actions {
    margin-top: 2rem;
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Footer */
footer {
    background-color: var(--secondary-color);
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: 4rem;
}

/* Responsive */
@media (max-width: 768px) {
    .hero h1 {
        font-size: 2rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .nav-links {
        gap: 1rem;
    }
    
    .cta-buttons {
        flex-direction: column;
        align-items: center;
    }
}

/* 🚀 PROFESSIONAL MOBILE-FIRST IMPROVEMENTS */

/* Better mobile typography */
html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

/* Improved mobile scrolling */
body {
    -webkit-overflow-scrolling: touch;
    overflow-x: hidden;
}

/* Professional button styles */
.btn {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 12px 24px;
    border-radius: 8px;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn:active {
    transform: translateY(0);
}

/* Mobile-optimized form inputs */
input[type="text"], 
input[type="number"], 
input[type="email"],
input[type="password"],
select, 
textarea {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 12px;
    border-radius: 8px;
    border: 2px solid #e1e5e9;
    transition: border-color 0.2s ease;
}

input:focus, 
select:focus, 
textarea:focus {
    border-color: #007bff;
    outline: none;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.1);
}

/* Professional card shadows */
.card, .form-section, .workout-card {
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border-radius: 12px;
    transition: box-shadow 0.3s ease;
}

.card:hover, .form-section:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

/* Mobile responsive grid improvements */
@media (max-width: 768px) {
    /* Mobile Layout Switching */
    .mobile-only {
        display: block !important;
        visibility: visible !important;
    }
    
    .mobile-top-bar {
        display: block !important;
        background-color: var(--bg-primary) !important;
        border-bottom: 2px solid var(--primary-color);
    }
    
    .app-layout {
        grid-template-columns: 1fr;
        grid-template-areas: "content";
    }
    
    .main-content {
        margin-left: 0;
    }
    
    /* Mobile Sidebar */
    .sidebar {
        position: fixed !important;
        top: 0;
        left: -250px; /* Hidden by default */
        width: 250px;
        height: 100vh;
        z-index: 999;
        transition: left 0.3s ease;
    }
    
    .sidebar.mobile-open {
        left: 0; /* Slide in when active */
    }
    
    body.sidebar-open {
        overflow: hidden; /* Prevent scrolling when sidebar is open */
    }
    
    .container, .content-container {
        padding: 20px; /* Match backup's more generous mobile padding */
        max-width: 100%;
    }
    
    /* Mobile Navigation */
    .mobile-nav-toggle {
        display: flex !important;
        z-index: 1001;
        position: relative;
    }
    
    .nav-links {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bg-primary);
        flex-direction: column;
        box-shadow: var(--shadow);
        transform: translateY(-100%);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        padding: 20px;
        gap: 1rem;
    }
    
    .nav-links.active {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }
    
    .nav-links a {
        display: block;
        padding: 12px;
        border-radius: 8px;
        transition: all 0.2s ease;
    }
    
    .nav-links a:hover {
        background: var(--bg-secondary);
    }
    
    /* Enhanced Mobile Buttons */
    .btn {
        width: 100%;
        margin-bottom: 16px;
        padding: 16px 20px;
        font-size: 16px;
        font-weight: 600;
    }
    
    .btn-small {
        padding: 12px 16px;
        font-size: 14px;
    }
    
    /* Form Layout Improvements */
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .form-group {
        margin-bottom: 20px;
    }
    
    .form-group label {
        font-size: 16px;
        font-weight: 600;
        margin-bottom: 8px;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 16px;
        font-size: 16px;
        border-radius: 12px;
        border: 2px solid var(--border-color);
        transition: all 0.2s ease;
    }
    
    /* Better mobile typography */
    h1 {
        font-size: 1.75rem;
        line-height: 1.3;
    }
    
    h2 {
        font-size: 1.5rem;
        line-height: 1.3;
    }
    
    h3 {
        font-size: 1.25rem;
        line-height: 1.4;
    }
    
    /* Mobile Workout Cards */
    .exercise-card {
        margin-bottom: 20px;
        padding: 20px;
        border-radius: 12px;
    }
    
    .exercise-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .exercise-details {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .detail-row {
        padding: 8px 0;
        border-bottom: 1px solid var(--border-color);
    }
    
    .detail-row:last-child {
        border-bottom: none;
    }
    
    /* Mobile Workout Actions */
    .workout-actions {
        flex-direction: column;
        gap: 16px;
        position: sticky;
        bottom: 20px;
        background: var(--bg-primary);
        padding: 20px;
        border-radius: 12px;
        box-shadow: var(--shadow-lg);
    }
    
    /* Mobile Profile Container */
    .profile-container {
        margin: 16px auto;
        padding: 20px;
        border-radius: 12px;
    }
    
    /* Mobile Equipment Grid */
    .equipment-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    
    .checkbox-label {
        padding: 12px;
        background: var(--bg-secondary);
        border-radius: 8px;
        border: 2px solid transparent;
        transition: all 0.2s ease;
    }
    
    .checkbox-label:hover {
        background: var(--bg-primary);
        border-color: var(--primary-color);
    }
    
    /* Mobile Workout Header */
    .workout-header {
        padding: 20px;
        margin-bottom: 20px;
        border-radius: 12px;
    }
    
    .workout-meta {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }
}

/* CRITICAL: Touch-friendly interactive elements */
@media (max-width: 768px) {
    .btn, .equipment-item, button, [role="button"], .menu-link, .set-btn, .exercise-option {
        min-height: 44px; /* iOS recommended touch target */
        min-width: 44px;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1); /* Show tap feedback */
        -webkit-touch-callout: none; /* Disable callout */
        -webkit-user-select: none; /* Disable text selection */
        user-select: none; /* Disable text selection */
    }
    
    /* CRITICAL: Ensure z-index doesn't interfere with touches */
    .btn, button, .set-btn, .exercise-option {
        position: relative;
        z-index: 10; /* Above most overlays but below modals */
    }
    
    /* CRITICAL: Fix sidebar z-index hierarchy */
    .sidebar {
        z-index: 999; /* Higher than default but lower than overlays when active */
    }
    
    /* CRITICAL: Improve button visibility and clickability */
    .btn {
        background-color: var(--primary-color) !important;
        color: white !important;
        border: 2px solid transparent !important;
        font-weight: 600 !important;
        text-align: center !important;
        cursor: pointer !important;
        display: inline-block !important;
        text-decoration: none !important;
    }
    
    /* CRITICAL: Fix specific button types */
    .btn-secondary {
        background-color: var(--secondary-color) !important;
    }
    
    .btn-success {
        background-color: var(--success-color) !important;
    }
    
    .btn-primary {
        background-color: var(--primary-color) !important;
    }
    
    /* Mobile-specific scroll improvements */
    .exercise-list {
        scroll-behavior: smooth;
    }
    
    /* Enhanced mobile forms */
    .form-section {
        margin-bottom: 24px;
        padding: 24px;
        border-radius: 16px;
    }
    
    /* Mobile exercise logging */
    .exercise-log {
        margin-top: 16px;
        padding: 20px;
        border-radius: 12px;
        box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
    }
    
    .log-form {
        gap: 16px;
    }
    
    .set-row {
        grid-template-columns: auto 1fr 1fr;
        gap: 12px;
        padding: 12px;
        background: var(--bg-primary);
        border-radius: 8px;
        margin-bottom: 8px;
    }
    
    /* Mobile notifications */
    .notification {
        bottom: 100px;
        left: 20px;
        right: 20px;
        border-radius: 12px;
        padding: 16px;
        font-size: 16px;
    }
}

/* Tablet Layout (769px to 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        padding: 24px;
    }
    
    .form-row {
        grid-template-columns: 1fr 1fr;
        gap: 20px;
    }
    
    .equipment-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }
    
    .exercise-details {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    
    .workout-actions {
        flex-direction: row;
        justify-content: center;
        gap: 20px;
    }
    
    .btn {
        width: auto;
        min-width: 140px;
    }
}

/* Enhanced Mobile Interactions */
@media (max-width: 768px) {
    /* CRITICAL: Fix hover states on touch devices */
    .btn:hover,
    .menu-link:hover,
    .set-btn:hover,
    .exercise-option:hover,
    .checkbox-label:hover,
    button:hover,
    a:hover {
        /* Only apply hover effects when using mouse (not touch) */
        transform: none !important;
        background: initial !important;
        border-color: initial !important;
        box-shadow: none !important;
        opacity: 1 !important;
    }
    
    /* Replace hover effects with active (tap) states for better mobile UX */
    .btn:active {
        transform: scale(0.95);
        opacity: 0.8;
    }
    
    .menu-link:active {
        background-color: rgba(220, 38, 38, 0.2) !important;
    }
    
    .set-btn:active {
        transform: scale(0.95);
        border-color: var(--primary-color) !important;
    }

    /* Swipe indicators for horizontal scrolling */
    .horizontal-scroll::after {
        content: "← Swipe →";
        position: absolute;
        top: 50%;
        right: 16px;
        font-size: 12px;
        color: var(--text-secondary);
        opacity: 0.7;
    }
    
    /* Enhanced focus states for accessibility */
    .btn:focus,
    input:focus,
    select:focus,
    textarea:focus {
        outline: 3px solid var(--primary-color);
        outline-offset: 2px;
    }
    
    /* Mobile-optimized modals/overlays */
    .loading-overlay .loading-modal {
        margin: 20px;
        max-width: calc(100vw - 40px);
        border-radius: 16px;
    }
    
    /* Better mobile error states */
    .error {
        border-color: #ef4444 !important;
        background: #fef2f2;
    }
    
    /* Mobile success states */
    .success {
        border-color: var(--success-color) !important;
        background: #f0fdf4;
    }
    
    /* Mobile Exercise Search Modal */
    #exerciseModal {
        z-index: 9999;
    }
    
    #exerciseModal > div {
        margin: 10px auto !important;
        max-height: 90vh !important;
        width: 95% !important;
        max-width: 95% !important;
    }
    
    #exerciseSearchInput {
        font-size: 16px !important; /* Prevent zoom on iOS */
        padding: 16px !important;
        border-radius: 12px !important;
        border: 2px solid #e5e7eb !important;
        width: 100% !important;
        box-sizing: border-box;
    }
    
    #exerciseSearchInput:focus {
        border-color: var(--primary-color) !important;
        outline: none;
        box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
    }
    
    .exercise-option {
        margin-bottom: 12px !important;
        padding: 16px !important;
        border-radius: 12px !important;
        border: 2px solid transparent !important;
        transition: all 0.2s ease !important;
        cursor: pointer;
        min-height: 60px;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    
    .exercise-option:hover {
        border-color: var(--primary-color) !important;
        background: var(--bg-secondary) !important;
        transform: translateY(-2px);
        box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    }
    
    .exercise-option:active {
        transform: translateY(0);
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    .exercise-option-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 16px;
    }
    
    .exercise-option-details {
        font-size: 14px;
        line-height: 1.5;
    }
    
    /* Search results highlighting */
    mark {
        background-color: #fef08a !important;
        font-weight: bold !important;
        padding: 1px 2px;
        border-radius: 2px;
    }
}

/* Professional loading animations */
.loading-equipment {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Loading spinner */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-modal {
    background: var(--bg-primary);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    text-align: center;
    min-width: 200px;
}

.loading-modal .loading-spinner {
    width: 24px;
    height: 24px;
    border-width: 3px;
    margin-right: 0;
    margin-bottom: 12px;
}

.loading-modal p {
    margin: 0;
    color: var(--text-primary);
    font-weight: 500;
}

/* Loading states for elements */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.btn.loading {
    position: relative;
    color: transparent !important;
}

.btn.loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid #ffffff;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* CRITICAL MOBILE BUTTON FIXES - MUST BE LAST TO OVERRIDE */
@media (max-width: 768px) {
    /* Fix for Safari iOS touch delay and 300ms click delay */
    * {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
        -webkit-touch-callout: none;
        touch-action: manipulation; /* Removes 300ms delay */
    }
    
    /* Ensure all clickable elements are properly touchable */
    a, button, .btn, .menu-link, .set-btn, input[type="button"],
    input[type="submit"], [onclick], [role="button"] {
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1) !important;
        cursor: pointer !important;
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 12px 16px !important;
        position: relative !important;
        z-index: 1 !important;
    }

    /* Exception: Allow finish workout button to be hidden until ready */
    #finishBtn[style*="display: none"],
    #finishBtn[style*="display:none"] {
        display: none !important;
    }

    /* Fix for buttons inside forms or containers */
    .btn, button {
        background: var(--primary-color) !important;
        color: white !important;
        border: none !important;
        border-radius: 8px !important;
        font-size: 16px !important;
        font-weight: 600 !important;
        text-decoration: none !important;
        box-sizing: border-box !important;
    }
    
    /* Specific fixes for different button types */
    .btn-primary {
        background: var(--primary-color) !important;
    }
    
    .btn-secondary {
        background: var(--secondary-color) !important;
    }
    
    .btn-success {
        background: var(--success-color) !important;
    }
    
    /* Fix menu links in sidebar */
    .menu-link {
        display: flex !important;
        align-items: center !important;
        padding: 12px 24px !important;
        color: rgba(255, 255, 255, 0.8) !important;
        text-decoration: none !important;
        min-height: 44px !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: rgba(220, 38, 38, 0.2) !important;
    }
    
    /* Fix set buttons */
    .set-btn {
        padding: 12px 16px !important;
        border: 2px solid #dee2e6 !important;
        background: white !important;
        border-radius: 8px !important;
        cursor: pointer !important;
        font-weight: bold !important;
        min-height: 44px !important;
        min-width: 60px !important;
        touch-action: manipulation !important;
    }
    
    /* Fix timer controls */
    #smartControls button, #restOnlyControls button, #standardControls button {
        min-height: 44px !important;
        min-width: 80px !important;
        padding: 12px 16px !important;
        margin: 4px !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1) !important;
    }
    
    /* Remove any remaining hover effects that interfere */
    *:hover {
        -webkit-tap-highlight-color: transparent !important;
    }
    
    /* Ensure overlay doesn't block touches when inactive */
    .mobile-sidebar-overlay:not(.active) {
        pointer-events: none !important;
        display: none !important;
    }
    
    /* Fix any disabled buttons */
    button:disabled, .btn:disabled {
        opacity: 0.6 !important;
        cursor: not-allowed !important;
        background-color: #6c757d !important;
    }
    
    /* Critical: Fix JavaScript click events */
    [onclick] {
        cursor: pointer !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1) !important;
    }
}

/* ========================
   Authentication Modals (Phase 2)
   ======================== */

.modal {
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--bg-primary);
    margin: auto;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease;
}

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

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

.modal-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-weight: 600;
}

.modal-close {
    font-size: 28px;
    font-weight: bold;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.form-group small {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
    display: block;
}

.form-group .btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-right: 8px;
}

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

.btn-primary:hover {
    background-color: #b91c1c;
}

.btn-secondary {
    background-color: var(--text-secondary);
    color: white;
}

.btn-secondary:hover {
    background-color: #4b5563;
}

.status-message {
    padding: 12px;
    border-radius: 8px;
    margin-top: 16px;
    font-weight: 500;
}

.status-message.success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.status-message.error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.status-message.info {
    background-color: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

/* Mobile responsiveness for modals */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-width: none;
        margin: 10px;
    }

    .modal-header, .modal-body {
        padding: 16px;
    }
}



/* ========================================
   TUTORIAL MODAL STYLES
   ======================================== */

/* Tutorial Modal Overlay */
.tutorial-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2500; /* Between auth modals (2000) and workout progress (10000) */
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tutorial-modal-overlay[style*="display: flex"] {
    opacity: 1;
}

/* Tutorial Modal Content */
.tutorial-modal-content {
    background: var(--bg-primary);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    max-width: 700px;
    width: 90%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    outline: none; /* For focus */
}

/* Tutorial Modal Header */
.tutorial-modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
    color: white;
}

.tutorial-modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.tutorial-modal-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 32px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.tutorial-modal-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Tutorial Modal Body */
.tutorial-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

/* Tutorial Accordion */
.tutorial-accordion-item {
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.tutorial-accordion-header {
    width: 100%;
    padding: 16px;
    background: var(--bg-secondary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    transition: background-color 0.2s;
    text-align: left;
}

.tutorial-accordion-header:hover {
    background-color: #f3f4f6;
}

.tutorial-accordion-icon {
    font-size: 0.9rem;
    transition: transform 0.3s;
}

.tutorial-accordion-content {
    padding: 20px;
    background: var(--bg-primary);
}

/* Tutorial Workflow Steps */
.tutorial-workflow-steps {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tutorial-step {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

.tutorial-step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    font-weight: 600;
    flex-shrink: 0;
}

.tutorial-step-content {
    flex: 1;
}

.tutorial-step-content strong {
    display: block;
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: 4px;
}

.tutorial-step-content p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

.tutorial-step-arrow {
    text-align: center;
    color: var(--accent-color);
    font-size: 1.5rem;
    font-weight: bold;
    padding: 4px 0;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .tutorial-modal-content {
        width: 95%;
        max-height: 90vh;
        margin: 20px 10px;
    }

    .tutorial-modal-header {
        padding: 16px;
    }

    .tutorial-modal-header h2 {
        font-size: 1.2rem;
    }

    .tutorial-modal-body {
        padding: 16px;
    }

    .tutorial-accordion-header {
        padding: 12px;
        font-size: 1rem;
    }

    .tutorial-step {
        padding: 12px;
        gap: 12px;
    }

    .tutorial-step-number {
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }

    .tutorial-step-content strong {
        font-size: 0.95rem;
    }

    .tutorial-step-content p {
        font-size: 0.85rem;
    }

    /* Full screen on very small devices */
    @media (max-width: 480px) {
        .tutorial-modal-content {
            width: 100%;
            height: 100vh;
            max-height: 100vh;
            border-radius: 0;
            margin: 0;
        }
    }
}
