/* ==========================================================================
   FixCraft Pro - Premium Design System & Styles
   ========================================================================== */

:root {
    --bg-main: #0b0f19;
    --bg-card: rgba(20, 27, 45, 0.75);
    --bg-card-hover: rgba(28, 38, 62, 0.85);
    --bg-input: rgba(15, 23, 42, 0.9);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(99, 102, 241, 0.6);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent-primary: #6366f1;
    --accent-primary-hover: #4f46e5;
    --accent-glow: rgba(99, 102, 241, 0.35);
    
    --color-emerald: #10b981;
    --color-amber: #f59e0b;
    --color-rose: #f43f5e;
    --color-blue: #3b82f6;
    --color-purple: #8b5cf6;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.45);
    --transition-fast: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Day/Night Theme Overrides */
body[data-theme="light"] {
    --bg-main: #f8fafc;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-hover: rgba(255, 255, 255, 0.98);
    --bg-input: #ffffff;
    --border-color: rgba(15, 23, 42, 0.12);
    --border-focus: rgba(99, 102, 241, 0.7);
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    
    --shadow-glass: 0 8px 32px 0 rgba(15, 23, 42, 0.08);
}
body[data-theme="light"] .jobs-table th {
    background: rgba(241, 245, 249, 0.8);
    color: #334155;
}
body[data-theme="light"] .jobs-table tr:hover {
    background: rgba(15, 23, 42, 0.03);
}
body[data-theme="light"] .modal-box {
    background: #ffffff;
    color: #0f172a;
}
body[data-theme="light"] .modal-footer {
    background: #f8fafc;
}
body[data-theme="light"] .btn-secondary {
    background: rgba(15, 23, 42, 0.05);
    color: #0f172a;
    border-color: rgba(15, 23, 42, 0.15);
}
body[data-theme="light"] .btn-secondary:hover {
    background: rgba(15, 23, 42, 0.1);
}
body[data-theme="light"] .status-pill {
    background: rgba(15, 23, 42, 0.04);
    color: #475569;
}
body[data-theme="light"] .status-pill:hover {
    background: rgba(15, 23, 42, 0.08);
    color: #0f172a;
}
body[data-theme="light"] .status-pill.active {
    color: #ffffff;
}

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

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-main);
    background-image: 
        radial-gradient(at 10% 20%, rgba(99, 102, 241, 0.12) 0px, transparent 50%),
        radial-gradient(at 90% 80%, rgba(16, 185, 129, 0.08) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    overflow-x: hidden;
}

/* Utilities */
.hidden { display: none !important; }
.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-glass);
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent-primary);
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.92rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideInToast 0.3s ease;
}
.toast.success { border-left-color: var(--color-emerald); }
.toast.error { border-left-color: var(--color-rose); }
@keyframes slideInToast {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ==========================================================================
   Buttons & Inputs
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition-fast);
}
.btn-sm { padding: 6px 12px; font-size: 0.82rem; border-radius: var(--radius-sm); }
.btn-primary {
    background: var(--accent-primary);
    color: #ffffff;
}
.btn-primary:hover {
    background: var(--accent-primary-hover);
    transform: translateY(-1px);
}
.primary-glow {
    box-shadow: 0 4px 18px var(--accent-glow);
}
.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-color: var(--border-color);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}
.btn-danger-soft {
    background: rgba(244, 63, 94, 0.12);
    color: #fda4af;
    border: 1px solid rgba(244, 63, 94, 0.25);
}
.btn-danger-soft:hover {
    background: rgba(244, 63, 94, 0.22);
}
.icon-btn {
    padding: 10px;
}

input, select, textarea {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.92rem;
    transition: var(--transition-fast);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* ==========================================================================
   LOCK SCREEN
   ========================================================================== */
.lock-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    background: radial-gradient(circle at center, #111827 0%, #030712 100%);
    padding: 20px;
}
.lock-card {
    width: 100%;
    max-width: 380px;
    padding: 36px 30px;
    border-radius: var(--radius-xl);
    text-align: center;
}
.brand-logo {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--accent-primary), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4);
}
.brand-icon { width: 32px; height: 32px; color: #fff; }
.lock-header h1 { font-size: 1.6rem; font-weight: 700; }
.lock-header p { font-size: 0.88rem; color: var(--text-secondary); margin-top: 4px; margin-bottom: 24px; }

.pin-display-wrapper { margin-bottom: 12px; }
.pin-input {
    text-align: center;
    font-size: 1.4rem;
    letter-spacing: 6px;
    padding: 12px;
    border-radius: var(--radius-md);
    font-family: 'JetBrains Mono', monospace;
}
.error-msg {
    color: var(--color-rose);
    font-size: 0.84rem;
    margin-bottom: 12px;
}
.numpad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 18px;
}
.num-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 0;
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}
.num-btn:hover { background: rgba(255, 255, 255, 0.12); transform: scale(1.03); }
.num-btn:active { transform: scale(0.96); }
.submit-btn { background: var(--accent-primary); color: #fff; border-color: var(--accent-primary); }
.lock-footer {
    margin-top: 24px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ==========================================================================
   MAIN APPLICATION HEADER & METRICS
   ========================================================================== */
.main-app {
    max-width: 1540px;
    margin: 0 auto;
    padding: 24px;
}
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}
.header-logo {
    display: flex;
    align-items: center;
    gap: 14px;
}
.logo-icon {
    width: 40px;
    height: 40px;
    color: var(--accent-primary);
    padding: 8px;
    background: rgba(99, 102, 241, 0.12);
    border-radius: var(--radius-md);
}
.header-left h2 { font-size: 1.4rem; font-weight: 700; }
.badge-subtitle { font-size: 0.8rem; color: var(--text-secondary); }
.header-actions { display: flex; gap: 10px; }

/* Metrics Section */
.metrics-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition-fast);
}
.metric-card:hover { transform: translateY(-3px); }
.metric-icon {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.card-glow-blue .metric-icon { background: rgba(59, 130, 246, 0.15); color: var(--color-blue); }
.card-glow-emerald .metric-icon { background: rgba(16, 185, 129, 0.15); color: var(--color-emerald); }
.card-glow-purple .metric-icon { background: rgba(139, 92, 246, 0.15); color: var(--color-purple); }
.card-glow-amber .metric-icon { background: rgba(245, 158, 11, 0.15); color: var(--color-amber); }
.metric-label { font-size: 0.84rem; color: var(--text-secondary); font-weight: 500; }
.metric-content h3 { font-size: 1.55rem; font-weight: 700; margin-top: 2px; }

/* ==========================================================================
   TOOLBAR & FILTER BAR
   ========================================================================== */
.toolbar-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.search-box {
    position: relative;
    flex: 1;
    min-width: 280px;
}
.search-box input {
    padding-left: 42px;
    padding-right: 36px;
    border-radius: var(--radius-md);
}
.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}
.clear-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}

.status-pills {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.status-pill {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 99px;
    padding: 7px 14px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}
.status-pill:hover { background: rgba(255, 255, 255, 0.08); color: var(--text-primary); }
.status-pill.active {
    background: var(--accent-primary);
    color: #fff;
    border-color: var(--accent-primary);
    box-shadow: 0 0 12px var(--accent-glow);
}

/* ==========================================================================
   TABLE & CARDS VIEW
   ========================================================================== */
.jobs-container {
    min-height: 380px;
}
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: var(--bg-card);
    border: 1px dashed rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-lg);
}
.empty-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.04);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}
.empty-state h3 { font-size: 1.2rem; margin-bottom: 6px; }
.empty-state p { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 20px; }

/* Desktop Table */
.table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow-x: auto;
}
.jobs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}
.jobs-table th {
    text-align: left;
    padding: 14px 18px;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.5);
}
.jobs-table td {
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    vertical-align: top;
}
.jobs-table tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.job-code {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.12);
    padding: 3px 8px;
    border-radius: 6px;
    display: inline-block;
    margin-bottom: 6px;
}
.job-photo-thumb {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition-fast);
}
.job-photo-thumb:hover { transform: scale(1.1); }

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.badge-pending { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.badge-progress { background: rgba(99, 102, 241, 0.18); color: #818cf8; }
.badge-ready { background: rgba(16, 185, 129, 0.18); color: #34d399; }
.badge-delivered { background: rgba(148, 163, 184, 0.15); color: #cbd5e1; }
.badge-returned { background: rgba(244, 63, 94, 0.18); color: #fb7185; }

/* Payment Status Badges */
.pay-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}
.pay-paid { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.pay-advance { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.pay-unpaid { background: rgba(244, 63, 94, 0.15); color: #fb7185; }

.action-buttons { display: flex; gap: 6px; justify-content: flex-end; }

/* Mobile Card View (Hidden on large desktop) */
.mobile-cards-grid {
    display: none;
    grid-template-columns: 1fr;
    gap: 14px;
}
.job-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}
.card-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    font-size: 0.88rem;
    margin-bottom: 14px;
}

/* Responsive breakpoint */
@media (max-width: 960px) {
    .table-wrapper { display: none; }
    .mobile-cards-grid { display: grid; }
    .main-app { padding: 14px; }
}

/* ==========================================================================
   MODALS
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(3, 7, 18, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 16px;
    animation: fadeInModal 0.2s ease;
}
@keyframes fadeInModal {
    from { opacity: 0; }
    to { opacity: 1; }
}
.modal-box {
    background: #111827;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}
.modal-lg { max-width: 820px; }
.modal-md { max-width: 580px; }
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}
.modal-title-wrap { display: flex; align-items: center; gap: 10px; }
.modal-icon { color: var(--accent-primary); }
.modal-header h3 { font-size: 1.2rem; font-weight: 600; }
.btn-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
}
.btn-close:hover { color: #fff; }

.modal-body { padding: 24px; }
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.mt-3 { margin-top: 12px; }

.section-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.form-group label {
    display: block;
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

/* Photo upload box */
.photo-upload-wrapper {
    background: rgba(15, 23, 42, 0.6);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
}
.photo-preview-box img {
    max-height: 160px;
    border-radius: var(--radius-sm);
    margin: 0 auto 12px;
    display: block;
}
.photo-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    padding: 20px 0;
}
.photo-actions { display: flex; justify-content: center; gap: 10px; margin-top: 10px; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 18px 24px;
    border-top: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.4);
}

/* Photo Viewer Modal */
.photo-lightbox-body {
    padding: 16px;
    text-align: center;
}
.photo-lightbox-body img {
    max-width: 100%;
    max-height: 75vh;
    border-radius: var(--radius-md);
}

/* ==========================================================================
   PRINT JOB SHEET / RECEIPT DESIGN
   ========================================================================== */
.printable-sheet {
    padding: 28px;
    background: #ffffff;
    color: #1e293b;
    font-family: 'Outfit', sans-serif;
}
.sheet-header {
    display: flex;
    justify-content: space-between;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 16px;
    margin-bottom: 20px;
}
.sheet-shop-info h2 { font-size: 1.5rem; color: #0f172a; margin-bottom: 4px; }
.sheet-shop-info p { font-size: 0.86rem; color: #64748b; }
.sheet-job-badge { text-align: right; }
.sheet-job-id {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.3rem;
    font-weight: 700;
    color: #4f46e5;
}

.sheet-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}
.sheet-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 16px;
}
.sheet-box h5 { font-size: 0.78rem; text-transform: uppercase; color: #64748b; margin-bottom: 6px; }
.sheet-box p { font-size: 0.95rem; font-weight: 600; color: #0f172a; margin-bottom: 4px; }

.sheet-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}
.sheet-table th {
    background: #f1f5f9;
    padding: 10px 14px;
    text-align: left;
    font-size: 0.82rem;
    color: #475569;
}
.sheet-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.92rem;
}
.sheet-totals {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 24px;
}
.totals-table td {
    padding: 6px 12px;
    font-size: 0.92rem;
}
.totals-table .total-bold { font-weight: 700; font-size: 1.05rem; }

.sheet-footer {
    border-top: 1px dashed #cbd5e1;
    padding-top: 16px;
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    color: #64748b;
}

/* ==========================================================================
   Google Sheets Cloud Sync & Header Badge Styles
   ========================================================================== */
.header-subtitle-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 2px;
    flex-wrap: wrap;
}
.sync-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 0.76rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    border: 1px solid var(--border-color);
}
.sync-badge:hover { transform: scale(1.03); }
.sync-badge.status-offline {
    background: rgba(148, 163, 184, 0.12);
    color: var(--text-secondary);
}
.sync-badge.status-connected {
    background: rgba(16, 185, 129, 0.18);
    color: var(--color-emerald);
    border-color: rgba(16, 185, 129, 0.35);
}
.sync-badge.status-syncing {
    background: rgba(59, 130, 246, 0.18);
    color: var(--color-blue);
    border-color: rgba(59, 130, 246, 0.35);
    animation: pulseSync 1.5s infinite;
}
.sync-badge.status-error {
    background: rgba(244, 63, 94, 0.18);
    color: var(--color-rose);
}
@keyframes pulseSync {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.url-input-wrapper {
    display: flex;
    gap: 8px;
}
.url-input-wrapper input {
    flex: 1;
}
.display-block { display: block !important; }

/* Print Specific rules */
@media print {
    body * { visibility: hidden; }
    #modal-invoice, #printable-sheet, #printable-sheet * {
        visibility: visible;
    }
    #modal-invoice {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: auto;
        background: none;
        padding: 0;
    }
    .modal-box { box-shadow: none; border: none; max-width: 100%; }
    .no-print { display: none !important; }
}
