/* TLC Job Management System - Main Styles */

:root {
    --bg-primary: #f8fafc;
    --bg-card: #ffffff;
    --bg-nav: linear-gradient(135deg, #1e3a5f 0%, #2d5a87 100%);
    --bg-nav-solid: #1e3a5f;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #64748b; /* WCAG AA: ~5.5:1 on white */
    --text-white: #ffffff;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #059669;
    --success-light: #d1fae5;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --info: #0891b2;
    --info-light: #cffafe;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #f1f5f9;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-sm: 4px;
    --radius-lg: 12px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SF Mono', SFMono-Regular, Consolas, monospace;
    --nav-height: 60px;
    --sub-nav-height: 48px;
    --sidebar-width: 240px;
    --xero-teal: #13B5EA;
    --xero-due: #ea580c;
    --xero-overdue: #dc2626;
    --xero-paid: #16a34a;
    --xero-due-bg: rgba(234, 88, 12, 0.08);
    --xero-overdue-bg: rgba(220, 38, 38, 0.08);
    --xero-paid-bg: rgba(22, 163, 74, 0.08);
    --inv-warning: #d97706;
    --inv-warning-bg: rgba(249, 115, 22, 0.08);
    --inv-gap: #dc2626;
    --inv-gap-bg: rgba(220, 38, 38, 0.08);
    --cam-dslr: #166534;
    --cam-micro: #1e40af;
    --text-on-primary: #fff;
    --success-dark: #059669;
    --toggle-track: #cbd5e1;
    --toggle-thumb: #94a3b8;
}

/* Dark Mode Variables */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-card: #1e293b;
    --bg-nav: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --bg-nav-solid: #0f172a;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #94a3b8; /* WCAG AA: ~4.6:1 on #1e293b card bg */
    --primary: #60a5fa;
    --primary-hover: #3b82f6;
    --primary-light: rgba(96, 165, 250, 0.15);
    --success: #4ade80;
    --success-light: rgba(74, 222, 128, 0.15);
    --warning: #fbbf24;
    --warning-light: rgba(251, 191, 36, 0.15);
    --danger: #f87171;
    --danger-light: rgba(248, 113, 113, 0.15);
    --info: #22d3ee;
    --info-light: rgba(34, 211, 238, 0.15);
    --bg-secondary: #1e1e2e;
    --bg-tertiary: #1e293b;
    --border: #334155;
    --border-light: #1e293b;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.3);
    --xero-teal: #38bdf8;
    --xero-due: #fb923c;
    --xero-overdue: #f87171;
    --xero-paid: #4ade80;
    --xero-due-bg: rgba(251, 146, 60, 0.12);
    --xero-overdue-bg: rgba(248, 113, 113, 0.12);
    --xero-paid-bg: rgba(74, 222, 128, 0.12);
    --inv-warning: #fbbf24;
    --inv-warning-bg: rgba(251, 191, 36, 0.12);
    --inv-gap: #f87171;
    --inv-gap-bg: rgba(248, 113, 113, 0.12);
    --cam-dslr: #22c55e;
    --cam-micro: #60a5fa;
    --text-on-primary: #fff;
    --success-dark: #047857;
    --toggle-track: #475569;
    --toggle-thumb: #64748b;
}

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    padding: 0;
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
table { border-collapse: collapse; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sub Navigation (project-specific, below shared admin nav) */
.sub-nav {
    background: var(--bg-nav);
    display: flex;
    align-items: center;
    padding: 0 24px;
    height: var(--sub-nav-height);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 900;
}
.sub-nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
    list-style: none;
    padding: 0;
    margin: 0;
}
.sub-nav-links a {
    color: rgba(255,255,255,0.8);
    padding: 6px 14px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
}
.sub-nav-links a:hover { background: rgba(255,255,255,0.12); color: white; text-decoration: none; }
.sub-nav-links a.active { background: rgba(255,255,255,0.2); color: white; }
.sub-nav-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}
[data-theme="dark"] .sub-nav {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.nav-search {
    position: relative;
}
.nav-search input {
    width: 280px;
    padding: 7px 12px 7px 36px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: var(--radius);
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 0.875rem;
    transition: all 0.2s;
}
.nav-search input::placeholder { color: rgba(255,255,255,0.5); }
.nav-search input:focus {
    outline: none;
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.4);
    width: 360px;
}
.nav-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255,255,255,0.5);
    pointer-events: none;
}
.nav-user {
    color: rgba(255,255,255,0.8);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 8px;
}
.nav-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.75rem;
    color: white;
}

/* Main content */
.main-content {
    padding: 24px;
    width: 100%;
    max-width: 1600px;
    margin-left: auto;
    margin-right: auto;
}
.main-content.wide { max-width: none; }

/* Page header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}
.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 2px;
}
.page-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Search results dropdown */
.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xl);
    margin-top: 4px;
    max-height: 400px;
    overflow-y: auto;
    display: none;
    z-index: 1001;
}
.search-dropdown.active { display: block; }
.search-dropdown-section {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.search-dropdown-section:last-child { border-bottom: none; }
.search-dropdown-label {
    padding: 4px 16px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}
.search-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.1s;
    color: var(--text-primary);
    text-decoration: none;
}
.search-dropdown-item:hover { background: var(--bg-primary); text-decoration: none; }
.search-dropdown-item .job-num { font-weight: 600; font-size: 0.875rem; white-space: nowrap; }
.search-dropdown-item .job-info { color: var(--text-secondary); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Utility classes */
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-primary-color { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-mono { font-family: var(--font-mono); }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.hidden { display: none !important; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Loading state */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
.loading-spinner.lg { width: 40px; height: 40px; border-width: 3px; }
.loading-spinner-inline { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin 0.6s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

.page-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    padding: 80px 20px;
    color: var(--text-secondary);
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: calc(var(--nav-height) + 12px);
    right: 16px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 12px 16px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 300px;
    max-width: 450px;
    animation: slideIn 0.3s ease;
    border-left: 4px solid var(--primary);
    font-size: 0.875rem;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast-close {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    font-size: 1.2rem;
    line-height: 1;
}
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Hamburger Button */
.hamburger-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    flex-shrink: 0;
    z-index: 910;
}
.hamburger-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: rgba(255,255,255,0.9);
    margin: 5px 0;
    border-radius: 2px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}
.hamburger-btn.active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.hamburger-btn.active span:nth-child(2) {
    opacity: 0;
}
.hamburger-btn.active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Responsive */
@media (max-width: 1024px) {
    .nav-search input { width: 200px; }
    .nav-search input:focus { width: 240px; }
    .main-content { padding: 16px; }
}

@media (max-width: 768px) {
    .hamburger-btn { display: block; }
    .sub-nav {
        height: auto;
        padding: 8px 16px;
        flex-wrap: wrap;
        position: sticky;
        top: 0;
        z-index: 900;
    }
    .sub-nav-links {
        display: none;
        flex-direction: column;
        width: 100%;
        gap: 2px;
        padding-top: 8px;
        order: 3;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease, padding 0.3s ease;
    }
    .sub-nav-links.open {
        display: flex;
        max-height: 500px;
        padding-top: 12px;
        padding-bottom: 4px;
    }
    .sub-nav-links li { width: 100%; }
    .sub-nav-links a {
        display: block;
        padding: 10px 14px;
        font-size: 0.9rem;
        border-radius: var(--radius-sm);
    }
    .sub-nav-links a:hover,
    .sub-nav-links a.active {
        background: rgba(255,255,255,0.15);
    }
    .sub-nav-right { margin-left: auto; }
    .nav-search { display: none; }
    .sub-nav-links.open ~ .sub-nav-right .nav-search {
        display: block;
        width: 100%;
        margin-top: 8px;
    }
    .nav-search input { width: 100%; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .main-content { padding: 12px; }
}

@media (max-width: 480px) {
    .sub-nav { padding: 6px 12px; }
}

/* Skip navigation link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary);
    color: #fff;
    padding: 8px 16px;
    z-index: 10000;
    transition: top 0.2s;
}
.skip-link:focus {
    top: 0;
}

/* Dark mode: hamburger */
[data-theme="dark"] .hamburger-btn span {
    background: rgba(255,255,255,0.8);
}

/* Screen reader only - visually hide but keep accessible */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
