/**
 * Run Back Home - Design System
 * White/light backgrounds with teal accents matching logo
 * Beautiful on desktop AND mobile
 */

/* Import desktop styles - must be at top */
@import url('desktop.css');

:root {
    /* Primary Teal Palette - From Logo */
    --primary-color: #2a6e78;        /* Main teal */
    --primary-light: #3a8a94;         /* Lighter teal */
    --primary-dark: #1e5a62;          /* Darker teal */
    --primary-darker: #154a52;        /* Deep teal */
    
    /* Accent Colors */
    --accent-yellow: #f7c548;          /* Warm yellow */
    --accent-yellow-light: #ffd966;
    --accent-yellow-dark: #e6b435;
    --accent-green: #4CAF50;            /* Success green */
    
    /* Background Colors - WHITE/LIGHT */
    --bg-primary: #ffffff;             /* Pure white */
    --bg-secondary: #f8f9fa;           /* Light gray */
    --bg-tertiary: #f0f2f5;            /* Slightly darker gray */
    --bg-hover: #e9ecef;               /* Hover state */
    
    /* Text Colors */
    --text-primary: #333333;           /* Dark text */
    --text-secondary: #666666;         /* Medium text */
    --text-tertiary: #999999;          /* Light text */
    --text-muted: #aaaaaa;             /* Muted text */
    --text-white: #ffffff;             /* White text */
    
    /* Border & Divider */
    --border-color: #e0e0e0;           /* Light border */
    --border-color-light: #f0f0f0;    /* Very light border */
    --border-color-strong: #d0d0d0;    /* Stronger border */
    
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.15);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.2);
    
    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-2xl: 48px;
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 300ms ease;
    --transition-slow: 500ms ease;
    
    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    position: static; /* Don't create stacking context that could trap modals */
    overflow-x: hidden;
}/* Main content area */
.main-content {
    display: block;
    visibility: visible;
    opacity: 1;
    min-height: 100vh;
    background: var(--bg-secondary);
    position: relative;
    z-index: 0; /* Low z-index so modals (1050) are always above */
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    color: var(--text-primary);
    margin-bottom: var(--spacing-md);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.1rem; }
h6 { font-size: 1rem; }

p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color var(--transition-base);
}

a:hover {
    color: var(--primary-dark);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
    color: var(--text-white);
}

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

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--primary-color);
}

.btn-accent {
    background: var(--accent-yellow);
    color: var(--text-primary);
}

.btn-accent:hover {
    background: var(--accent-yellow-dark);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1.1rem;
}

/* Cards */
.card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

/* Forms */
.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all var(--transition-base);
    font-family: var(--font-family);
    line-height: 1.5;
    min-height: 42px;
    box-sizing: border-box;
}

.form-control select,
select.form-control,
select {
    line-height: 1.5;
    padding-top: 10px;
    padding-bottom: 10px;
    height: auto;
    vertical-align: middle;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(42, 110, 120, 0.1);
}

.form-control::placeholder {
    color: var(--text-tertiary);
}

/* Tables */
.table {
    width: 100%;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.table thead {
    background: var(--bg-tertiary);
}

.table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-color);
}

.table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color-light);
    color: var(--text-secondary);
}

.table tbody tr {
    transition: background var(--transition-fast);
}

.table tbody tr:hover {
    background: var(--bg-hover);
}

/* Navigation */
.sticky-header {
    position: relative;
    top: 0;
    z-index: 1;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    margin: 0 0 12px 0;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.sticky-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
    padding: var(--spacing-sm) var(--spacing-md);
    display: flex;
    justify-content: space-around;
    align-items: center;
}

/* Hide mobile footer on desktop */
@media (min-width: 768px) {
    .sticky-footer.mobile-only {
        display: none !important;
    }
}

/* Hide desktop sidebar on mobile */
@media (max-width: 767px) {
    .desktop-sidebar {
        display: none !important;
    }
    
    .main-content {
        width: 100% !important;
        margin-left: 0 !important;
        padding: 10px !important;
    }
    
    /* Fix logo size in sidebar if it shows */
    .desktop-sidebar .logo img {
        max-width: 120px !important;
        max-height: 40px !important;
    }
}

.sticky-footer .btn {
    flex: 1;
    flex-direction: column;
    gap: 4px;
    padding: 8px 2px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-family: var(--font-family);
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s ease;
    min-width: 0;
}

.sticky-footer .btn:hover {
    color: var(--primary-color);
    background: transparent;
}

.sticky-footer .btn.active {
    background: var(--primary-color) !important;
    color: white !important;
}

.sticky-footer .btn.active i {
    color: white !important;
}

.sticky-footer .btn i {
    font-size: 1.1rem;
    margin-bottom: 2px;
    transition: color 0.2s ease;
}

/* ============================================
   MODALS - Let Bootstrap Handle It
   ============================================ */

/* CRITICAL: Force onboarding overlay below modals (Bootstrap modals are z-index 1050) */
#onboarding-overlay {
    z-index: 1039 !important; /* Below Bootstrap modal backdrop (1040) and modal (1050) */
}

/* Hide onboarding overlay when modal is open */
body.modal-open #onboarding-overlay {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    z-index: -1 !important;
    pointer-events: none !important;
}

/* Modal header */
.modal-header {
    flex-shrink: 0 !important;
    padding: 1rem !important;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-header .close {
    padding: 0;
    margin: 0;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    opacity: 0.5;
}

.modal-header .close:hover {
    opacity: 1;
}

/* Modal body - fit content exactly */
.modal-body {
    flex: 1 1 auto !important;
    padding: 1rem !important;
    overflow-y: auto !important;
    height: auto !important;
    min-height: auto !important;
}

/* Override for sliding panel modals */
#addMenuItemModal .modal-body {
    padding: 0 !important;
}
    max-height: none !important;
}

/* Modal footer */
.modal-footer {
    flex-shrink: 0 !important;
    padding: 1rem !important;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
}

/* Bootstrap handles modal form elements - no overrides needed */

/* Ensure onboarding overlay doesn't block when hidden */
#onboarding-overlay[style*="display: none"],
#onboarding-overlay:not([style*="display: flex"]) {
    pointer-events: none !important;
    z-index: -1 !important;
}

/* Ensure page buttons are always clickable when modal is closed */
body:not(.modal-open) button,
body:not(.modal-open) .btn,
body:not(.modal-open) a.btn {
    pointer-events: auto !important;
    cursor: pointer !important;
}

/* Ensure main content is clickable */
.main-content {
    pointer-events: auto !important;
}

/* CRITICAL: Bootstrap modal z-index - override any Bootstrap inline styles */
.modal-backdrop,
.modal-backdrop.fade,
.modal-backdrop.show {
    z-index: 1040 !important;
}

.modal,
.modal.fade,
.modal.show {
    z-index: 1050 !important;
}

/* Bootstrap's modal structure: modal (pointer-events: none) allows backdrop clicks */
/* modal-dialog (pointer-events: auto) catches content clicks */
.modal.show {
    pointer-events: none;
}

.modal.show .modal-dialog {
    pointer-events: auto !important;
}

.main-content button,
.main-content .btn,
.main-content a,
.main-content input[type="button"],
.main-content input[type="submit"] {
    pointer-events: auto !important;
    cursor: pointer !important;
}

/* Tabs */
.nav-tabs {
    display: flex;
    gap: var(--spacing-sm);
    border-bottom: 2px solid var(--border-color);
    margin-bottom: var(--spacing-lg);
}

.nav-link {
    padding: var(--spacing-sm) var(--spacing-md);
    color: var(--text-secondary);
    border: none;
    border-bottom: 3px solid transparent;
    background: transparent;
    cursor: pointer;
    transition: all var(--transition-base);
    font-weight: 500;
}

.nav-link:hover {
    color: var(--text-primary);
    border-bottom-color: var(--border-color);
}

.nav-link.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.badge-accent {
    background: var(--accent-yellow);
    color: var(--text-primary);
}

/* Desktop Optimizations */
@media (min-width: 768px) {
    body {
        font-size: 1rem;
    }
    
    .container {
        max-width: 1200px;
        margin: 0 auto;
        padding: var(--spacing-lg);
    }
    
    .sticky-footer {
        display: none; /* Hide on desktop, use sidebar nav */
    }
    
    .table {
        font-size: 0.95rem;
    }
}

/* Mobile Optimizations */
@media (max-width: 767px) {
    html {
        font-size: 14px;
    }
    
    .container {
        padding: var(--spacing-md);
        padding-bottom: 80px; /* Space for footer */
    }
    
    .sticky-header {
        padding: var(--spacing-sm) var(--spacing-md);
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .action-bar {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .form-control {
        font-size: 16px; /* Prevents iOS zoom */
    }
    
    .btn {
        min-height: 44px; /* Touch target */
    }
}

/* Utility Classes */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-white { color: var(--text-white); }

.bg-primary { background: var(--bg-primary); }
.bg-secondary { background: var(--bg-secondary); }

.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

.rounded { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }

/* Engagement Features */
.streak-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: linear-gradient(135deg, var(--accent-yellow) 0%, var(--accent-yellow-light) 100%);
    color: var(--text-primary);
    border-radius: var(--radius-full);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

.achievement-badge {
    display: inline-block;
    padding: var(--spacing-xs) var(--spacing-sm);
    background: var(--primary-color);
    color: var(--text-white);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    margin-right: var(--spacing-xs);
}

.progress-bar-container {
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    height: 8px;
    overflow: hidden;
    margin-top: var(--spacing-sm);
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--primary-light) 100%);
    border-radius: var(--radius-full);
    transition: width var(--transition-base);
}
