/* ==========================================================================
   MASTER STYLESHEET - PPM SYSTEM (GREY THEME + COLOR PRINTING FIXED)
   ========================================================================== */

/* --- 1. GLOBAL DEFAULTS & THEME --- */
:root {
    --brand-blue: #1F4E79; 
    --primary-blue: #007bff;
    --primary-dark: #0056b3;
    --success-green: #28a745;
    --warning-yellow: #ffc107;
    --danger-red: #dc3545;
    --info-teal: #17a2b8;
    --purple: #6f42c1;
    
    /* MODIFIED: Soft Grey Backgrounds (Anti-Glare) */
    --light-bg: #e2e6ea; 
    --card-bg: #fdfdfd; /* Off-white for cards to reduce contrast */
    --input-bg: #ffffff; /* Inputs stay white for readability */
    
    --border-color: #B0B0B0;
    --table-header-bg: #EAEAEA; 
}

body {
    background-color: var(--light-bg);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* Page Specific Body Layouts (Screen) */
.login-page, .setup-page { display: flex; align-items: center; justify-content: center; height: 100vh; }
.map-view-page { display: flex; flex-direction: column; height: 100vh; overflow: hidden; background: #f4f7f6; margin: 0; }
.builder-page { background-color: #f0f2f5; height: 100vh; overflow: hidden; display: flex; flex-direction: column; }

/* --- 2. GLOBAL OVERRIDES (SOFT GREY LOOK) --- */
/* Forces white cards to be slightly off-white to reduce glare */
.card, .bg-white, .modal-content, .list-group-item, .dropdown-menu, .navbar-light {
    background-color: var(--card-bg) !important;
    border-color: var(--border-color);
}

/* Keep Inputs White */
input.form-control, select.form-control, textarea.form-control, .form-control-premium {
    background-color: var(--input-bg) !important;
    border: 1px solid #ced4da;
}

/* Table Stripes (Slightly darker for visibility on grey) */
.table { background-color: transparent !important; }
.table-striped tbody tr:nth-of-type(odd) { background-color: rgba(0,0,0,0.04) !important; }
.table-hover tbody tr:hover { background-color: rgba(0,0,0,0.07) !important; }
.table td, .table th { border-top: 1px solid var(--border-color); }


/* --- 3. PRINT PREVIEW BASE STYLES (Screen Only) --- */
/* "Desk" look before printing */
body.pdf-preview-body, 
body.report-view-page,
body.public-quote-page { 
    background-color: #525659 !important; /* Dark Grey Background */
    font-family: 'Segoe UI', Arial, sans-serif; 
    color: #333; 
    margin: 0; 
    padding-bottom: 50px; 
    min-height: 100vh;
}

/* The "Paper" Container */
.quote-pdf-page, 
.public-quote-container { 
    background: white !important; 
    width: 210mm; 
    margin: 0 auto; 
    padding: 15mm; 
    box-shadow: 0 0 15px rgba(0,0,0,0.5); 
    min-height: 297mm; 
    box-sizing: border-box; 
    position: relative;
    font-size: 13px;
}

/* Report Page Width */
.report-page {
    background: white !important;
    width: 80%; 
    max-width: 1200px; 
    margin: 0 auto;
    padding: 15mm;
    box-shadow: 0 0 15px rgba(0,0,0,0.5);
    min-height: 297mm;
    box-sizing: border-box;
    position: relative;
    font-size: 13px;
}

.action-bar, .toolbar, .public-action-bar { 
    width: 210mm; margin: 20px auto 10px auto; text-align: right; display: flex; justify-content: flex-end; gap: 10px;
}
.report-view-page .toolbar { width: 80%; max-width: 1200px; }
.public-action-bar { justify-content: space-between; align-items: center; }

/* --- 4. UTILITIES --- */
.autocomplete-container { position: relative; }
.autocomplete-suggestions {
    border: 1px solid #ddd; background: #fff; overflow: auto; max-height: 200px;
    position: absolute; z-index: 9999 !important; width: 100%;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1); top: 100%; left: 0;
}
.autocomplete-suggestion { padding: 8px 10px; cursor: pointer; border-bottom: 1px solid #f0f0f0; }
.autocomplete-suggestion:hover { background: #e9ecef; }
.bg-selected-item { background-color: #f8f9fa; border-bottom: 1px solid #eee; }

.filter-form-container { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }
.filter-form-container .form-group { margin-bottom: 0; }
.filter-form-container .autocomplete-container { width: 250px; }

.app-logo { max-width: 150px; height: auto; }
.logo-wrapper { width: 100%; text-align: center; }

.status-badge { font-size: 0.8rem; padding: 4px 8px; border-radius: 12px; display: inline-block; min-width: 80px; text-align: center; }
.status-sent { background: #cce5ff; color: #004085; }
.status-viewed { background: #d4edda; color: #155724; font-weight: bold; border: 1px solid #c3e6cb; }

#draft-status { position: fixed; top: 70px; right: 20px; z-index: 9999; padding: 5px 12px; border-radius: 4px; font-weight: bold; color: white; display: none; font-size: 0.9rem; box-shadow: 0 2px 5px rgba(0,0,0,0.2); }
.status-saving { background-color: #ffc107; color: #333 !important; }
.status-saved { background-color: #28a745; }

.modal-premium-header { background: linear-gradient(135deg, #007bff 0%, #0056b3 100%); color: white; padding: 15px 20px; border-top-left-radius: 5px; border-top-right-radius: 5px; }
.form-section-card { background: white; border: 1px solid #e9ecef; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.03); padding: 20px; margin-bottom: 20px; position: relative; }
.section-label { font-size: 0.75rem; text-transform: uppercase; color: #6c757d; font-weight: 700; letter-spacing: 0.5px; margin-bottom: 15px; display: block; border-bottom: 1px solid #eee; padding-bottom: 5px; }
.form-control-premium { border: 1px solid #ced4da; border-radius: 6px; padding: 10px; font-size: 0.95rem; transition: all 0.2s; background-color: #fcfcfc; }
.form-control-premium:focus { background-color: #fff; border-color: #007bff; box-shadow: 0 0 0 3px rgba(0,123,255,0.1); }
.premium-label { font-weight: 600; color: #343a40; margin-bottom: 5px; display: block; }
.premium-label i { color: var(--primary-blue); margin-right: 5px; width: 20px; text-align: center; }

.file-card { border: 1px solid #eee; border-radius: 6px; padding: 10px; margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; background: #fff; transition: transform 0.1s; }
.file-card:hover { transform: translateX(2px); border-left: 3px solid #007bff; }
.file-icon { font-size: 1.2rem; color: #dc3545; margin-right: 10px; }

/* --- GLOBAL FREQUENCY COLORS (Used in Calendar & Planner) --- */
.bg-weekly, .freq-weekly { background-color: #3b82f6 !important; color: white !important; }
.bg-2weekly, .freq-2_weekly, .freq-2-weekly { background-color: #596570 !important; color: white !important; }
.bg-custom, .freq-custom, .freq-4_weekly, .freq-6_weekly, .freq-8_weekly { background-color: #3c96a8 !important; color: white !important; }
.bg-monthly, .freq-monthly { background-color: #50a545 !important; color: white !important; }
.bg-quarterly, .freq-quarterly { background-color: #ed7d31 !important; color: white !important; }
.bg-biannually, .freq-bi_annually, .freq-bi-annually { background-color: #6043b3 !important; color: white !important; }
.bg-triannually, .freq-tri_annually, .freq-tri-annually { background-color: #c93c8d !important; color: white !important; }
.bg-annually, .freq-annually { background-color: #c00000 !important; color: white !important; }

/* Status Text Colors */
.status-pass, .pill-done { color: #2E7D32; font-weight: bold; } 
.status-fail, .pill-missed { color: #C62828; font-weight: bold; }
.cell-missed { background-color: #c00000 !important; color: white !important; }
.cell-unable, .pill-unable { background-color: #ffc107 !important; color: #212529 !important; font-weight: bold; }

/* --- 5. MODULE: SCHEDULER (scheduler.php) --- */
/* Main Timeline Scroll Box - LIGHT GREY */
.scheduler-page #timelineScrollBox { 
    width: 100%; overflow-x: scroll; overflow-y: visible; 
    background: #f0f0f0; /* Soft Grey Background */
    border: 1px solid #e0e0e0; 
    position: relative; white-space: nowrap; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.05); border-radius: 8px; scrollbar-width: none; 
}
.scheduler-page #timelineScrollBox::-webkit-scrollbar { height: 0px; background: transparent; }

/* Top Scrollbar - DOUBLE SIZE & GREY */
.scheduler-page #top-scroll-container { 
    width: 100%; overflow-x: auto; overflow-y: hidden; margin-bottom: 0px; 
    border: 1px solid #e0e0e0; 
    background: #e9ecef; 
    border-top-left-radius: 8px; border-top-right-radius: 8px; 
}
.scheduler-page #top-scroll-container::-webkit-scrollbar { height: 24px; } /* Double Size */
.scheduler-page #top-scroll-container::-webkit-scrollbar-thumb { background-color: #adb5bd; border-radius: 12px; border: 4px solid #e9ecef; }
.scheduler-page #top-scroll-container::-webkit-scrollbar-track { background: #e9ecef; }

.scheduler-page #ui-datepicker-div { z-index: 99999 !important; }
.scheduler-page .hidden-date-trigger { position: absolute; top: 0; left: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 10; }
.scheduler-page .scheduler-canvas { position: relative; } 
.scheduler-page .scheduler-header-row { height: 45px; background: #2c3e50; color: white; position: sticky; top: 30px; z-index: 60; display: flex; flex-wrap: nowrap; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
.scheduler-page .scheduler-time-nav { height: 30px; background: #e9ecef; border-bottom: 1px solid #dee2e6; position: sticky; top: 0; z-index: 70; display: flex; cursor: pointer; margin-left: 220px; } 
.scheduler-page .scheduler-eng-col { position: sticky; left: 0; width: 220px; z-index: 102; background-color: inherit; border-right: 1px solid #d0d0d0; display: inline-block; vertical-align: top; height: 100%; box-shadow: 4px 0 5px rgba(0,0,0,0.05); }
.scheduler-page .header-eng-corner { width: 220px; padding: 12px 15px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; font-size: 0.85rem; background: #2c3e50; border-right: 1px solid #34495e; position: sticky; left: 0; top: 30px; z-index: 105; flex-shrink: 0; }
.scheduler-page .eng-name-cell { width: 220px; padding: 10px 15px; font-weight: 600; display: flex; align-items: center; height: 100%; flex-shrink: 0; color: #495057; }
.scheduler-page .eng-avatar { width: 35px; height: 35px; background: #007bff; color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.9rem; margin-right: 12px; font-weight: bold; text-shadow: 0 1px 1px rgba(0,0,0,0.1); }
.scheduler-page .eng-text { font-size: 0.95rem; line-height: 1.2; }
.scheduler-page .eng-skills { display: block; font-size: 0.65rem; color: #6c757d; font-style: italic; font-weight: normal; margin-top: 2px; white-space: normal; }
.scheduler-page .header-time-track { display: flex; flex-grow: 1; flex-wrap: nowrap; }
.scheduler-page .nav-hour { flex: 1; border-right: 1px solid #e9ecef; font-size: 0.75rem; color: #6c757d; text-align: center; line-height: 30px; font-weight: 600; }
.scheduler-page .nav-hour:hover { background: #e9ecef; color: #007bff; }
.scheduler-page .time-header-cell { text-align: center; border-right: 1px solid #34495e; line-height: 45px; font-weight: 600; flex-shrink: 0; font-size: 0.85rem; display: inline-block; } 

/* SCHEDULER ROW COLORS (GREY THEME) */
.scheduler-page .scheduler-row { border-bottom: 1px solid #e0e0e0; position: relative; width: 100%; display: flex; transition: background 0.2s; }
.scheduler-page .scheduler-row:nth-child(even) { background-color: #f9f9f9; } /* Off-White */
.scheduler-page .scheduler-row:nth-child(odd) { background-color: #ececec; } /* Light Grey */
.scheduler-page .scheduler-row:hover { background-color: #e2e6ea !important; }

.scheduler-page .scheduler-row-unassigned { background: repeating-linear-gradient(45deg, #fff0f0, #fff0f0 10px, #fff5f5 10px, #fff5f5 20px) !important; }
.scheduler-page .scheduler-row-unassigned .scheduler-eng-col { background-color: #fff0f0 !important; z-index: 105; }
.scheduler-page .scheduler-track-area { position: relative; flex-grow: 1; height: 100%; background-image: linear-gradient(90deg, rgba(0,0,0,0.03) 1px, transparent 1px); }

.scheduler-page .scheduler-job-block { z-index: 150; /* Base level for jobs */ position: absolute; border-radius: 6px; padding: 0 8px; font-size: 0.8rem; box-shadow: 0 2px 4px rgba(0,0,0,0.15); cursor: pointer; overflow: visible; white-space: nowrap; z-index: 10; display: flex; align-items: center; transition: transform 0.1s, box-shadow 0.1s, z-index 0.1s; } 
.scheduler-page .scheduler-job-block:hover { z-index: 10000; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.25); }
.scheduler-page .job-icon { margin-right: 6px; font-size: 0.9rem; opacity: 0.7; }
.scheduler-page .job-content-wrapper { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; }
.scheduler-page .fc-event { margin: 2px 0 !important; border-radius: 4px !important; overflow: hidden !important; padding: 0 !important; box-shadow: 0 1px 2px rgba(0,0,0,0.1) !important; cursor: pointer; border: none !important; }
.scheduler-page .fc-event-main-frame, .scheduler-page .fc-event-title, .scheduler-page .fc-event-main { color: inherit !important; } 
.scheduler-page .fc-daygrid-event-dot { display: none !important; }
.scheduler-page .fc-event-time { display: none !important; }
.scheduler-page #calendar { min-height: 500px; margin-bottom: 20px; }
.scheduler-page .pill-completed, .status-completed { background-color: #d4edda !important; border-left: 5px solid #28a745 !important; color: #155724 !important; border-top: 1px solid #c3e6cb; border-right: 1px solid #c3e6cb; border-bottom: 1px solid #c3e6cb; }
.scheduler-page .pill-missed, .status-missed, .status-overdue { background-color: #f8d7da !important; border-left: 5px solid #dc3545 !important; color: #721c24 !important; border-top: 1px solid #f5c6cb; border-right: 1px solid #f5c6cb; border-bottom: 1px solid #f5c6cb; }
.scheduler-page .pill-pending, .status-pending { background-color: #cce5ff !important; border-left: 5px solid #007bff !important; color: #004085 !important; border-top: 1px solid #b8daff; border-right: 1px solid #b8daff; border-bottom: 1px solid #b8daff; }
.scheduler-page .pill-in_progress, .status-in_progress { background-color: #f3e8ff !important; border-left: 5px solid #a855f7 !important; color: #581c87 !important; border-top: 1px solid #e9d5ff; border-right: 1px solid #e9d5ff; border-bottom: 1px solid #e9d5ff; }
.scheduler-page .pill-unable_to_complete, .status-unable_to_complete { background-color: #fff3cd !important; border-left: 5px solid #ffc107 !important; color: #856404 !important; border-top: 1px solid #ffeeba; border-right: 1px solid #ffeeba; border-bottom: 1px solid #ffeeba; }
.hover-desc { display: none; position: absolute; padding: 12px 14px; border-radius: 8px; z-index: 99999; width: 280px; white-space: normal; box-shadow: 0 8px 25px rgba(0,0,0,0.25); bottom: 140%; left: 0px; font-size: 0.85rem; pointer-events: none; line-height: 1.4; border: 1px solid #ccc; background-color: #fff; color: #333; }
.hover-desc::after { content: " "; position: absolute; top: 100%; left: 20px; margin-left: -5px; border-width: 8px; border-style: solid; border-color: #fff transparent transparent transparent; }
.scheduler-job-block:hover .hover-desc { display: block; }
.hover-desc.force-bottom { bottom: auto; top: 140%; }
.hover-desc.force-bottom::after { top: auto; bottom: 100%; border-color: transparent transparent #fff transparent; }
.scheduler-page .pill-completed .hover-desc, .status-completed .hover-desc { background-color: #d4edda; border-color: #28a745; color: #155724; }
.scheduler-page .pill-completed .hover-desc::after { border-top-color: #d4edda; }
.scheduler-page .pill-completed .hover-desc.force-bottom::after { border-top-color: transparent; border-bottom-color: #d4edda; }
.scheduler-page .pill-missed .hover-desc, .status-overdue .hover-desc, .status-missed .hover-desc { background-color: #f8d7da; border-color: #dc3545; color: #721c24; }
.scheduler-page .pill-missed .hover-desc strong { color: #721c24; }
.scheduler-page .pill-missed .hover-desc::after { border-top-color: #f8d7da; }
.scheduler-page .pill-missed .hover-desc.force-bottom::after { border-top-color: transparent; border-bottom-color: #f8d7da; }
.scheduler-page .pill-pending .hover-desc, .status-pending .hover-desc { background-color: #cce5ff; border-color: #007bff; color: #004085; }
.scheduler-page .pill-pending .hover-desc::after { border-top-color: #cce5ff; }
.scheduler-page .pill-pending .hover-desc.force-bottom::after { border-top-color: transparent; border-bottom-color: #cce5ff; }
.scheduler-page .pill-in_progress .hover-desc, .status-in_progress .hover-desc { background-color: #f3e8ff; border-color: #a855f7; color: #581c87; }
.scheduler-page .pill-in_progress .hover-desc::after { border-top-color: #f3e8ff; }
.scheduler-page .pill-in_progress .hover-desc.force-bottom::after { border-top-color: transparent; border-bottom-color: #f3e8ff; }
.scheduler-page .pill-unable_to_complete .hover-desc, .status-unable_to_complete .hover-desc { background-color: #fff3cd; border-color: #ffc107; color: #856404; }
.scheduler-page .pill-unable_to_complete .hover-desc::after { border-top-color: #fff3cd; }
.scheduler-page .pill-unable_to_complete .hover-desc.force-bottom::after { border-top-color: transparent; border-bottom-color: #fff3cd; }
.hover-desc strong { font-weight: 700; opacity: 0.9; }
.hover-desc i { opacity: 0.7; }
.hover-desc .border-top { border-top-color: rgba(0,0,0,0.1) !important; }
.job-icon.text-warning { color: #856404 !important; opacity: 1; }
.filter-select { min-width: 160px; max-width: 200px; }
.filter-group-icon { background: #e9ecef; border: 1px solid #ced4da; border-right: none; color: #495057; display: flex; align-items: center; padding: 0 10px; border-top-left-radius: 4px; border-bottom-left-radius: 4px; }
.filter-group-select { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.sidebar-day-header { background: #343a40; color: white; padding: 15px; border-top-left-radius: 8px; border-top-right-radius: 8px; font-weight: bold; text-align: center; }
.sidebar-job-list { height: calc(85vh - 60px); overflow-y: auto; padding: 10px; background: #f8f9fa; border: 1px solid #ddd; border-top: none; border-bottom-left-radius: 8px; border-bottom-right-radius: 8px; }
.sidebar-job-card { background: white; padding: 12px; margin-bottom: 10px; border-radius: 4px; box-shadow: 0 2px 4px rgba(0,0,0,0.05); cursor: pointer; transition: all 0.2s; border-left: 5px solid #ccc; }
.sidebar-job-card:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.1); }
.fc-header-toolbar { margin-bottom: 1rem !important; padding: 0 10px; }

/* Scheduler Mobile Overrides - RESTORED STICKY + WHITE BOX FIX */
@media screen and (max-width: 1024px) {
    .scheduler-page .scheduler-canvas { 
        width: 6140px !important; /* 24hr * 250px + 140px sidebar */
        min-width: 6140px !important; 
        display: block !important; 
        overflow: visible !important; 
    }
    .scheduler-page .eng-avatar { display: none !important; }
    
    .scheduler-page .scheduler-eng-col { 
        width: 140px !important; 
        min-width: 140px !important; 
        position: sticky !important; 
        left: 0 !important; 
        z-index: 1005 !important; 
        background-color: #fff; 
        display: flex; 
        align-items: center; 
        flex-shrink: 0 !important; 
        align-self: stretch !important; 
        transform: translateZ(0); 
        -webkit-transform: translateZ(0);
    }
    
    .scheduler-page .header-eng-corner { 
        width: 140px !important; 
        min-width: 140px !important; 
        font-size: 0.75rem; 
        padding: 12px 2px; 
        text-align: center; 
        position: sticky !important; 
        left: 0 !important; 
        z-index: 1010 !important; 
        background: #2c3e50; 
        flex-shrink: 0 !important;
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
    }
    
    .scheduler-page .eng-name-cell { width: 140px !important; padding-left: 5px !important; justify-content: flex-start; }
    .scheduler-page .eng-text { font-size: 0.8rem; font-weight: 600; white-space: normal; line-height: 1.2; }
    .scheduler-page .eng-skills { display: none !important; }
    
    /* Force exact pixel widths so mobile browsers don't cull the backgrounds early */
    .scheduler-page .scheduler-time-nav { 
        margin-left: 140px !important; 
        width: 6000px !important; 
        min-width: 6000px !important; 
    }
    
    .scheduler-page .scheduler-row, 
    .scheduler-page .scheduler-header-row { 
        width: 6140px !important; 
        min-width: 6140px !important; 
        display: flex !important; 
        flex-wrap: nowrap !important;
        position: relative; 
    }

    .scheduler-page .scheduler-track-area {
        width: 6000px !important; 
        min-width: 6000px !important; 
        flex-shrink: 0 !important;
    }
}

/* --- 4. MODULE: CALENDAR (calendar.php) --- */
.calendar-page .fc-event { border: none !important; border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,0.15); margin-bottom: 3px !important; border-left: 10px solid rgba(0,0,0,0.1) !important; }
.calendar-page .fc-event-main { cursor: pointer; font-size: 0.8rem; padding: 4px 6px 4px 8px; line-height: 1.3; white-space: normal; color: #fff !important; display: flex; flex-direction: column; justify-content: space-between; height: 100%; background: transparent !important; }
.calendar-page .fc-event-title-wrapper { font-weight: 600; margin-bottom: 4px; word-wrap: break-word; }
.calendar-page .fc-event.status-border-completed { border: 2px solid #2e7d32 !important; border-left: 10px solid #2e7d32 !important; box-shadow: 0 2px 4px rgba(0,0,0,0.2); }
.calendar-page .fc-event.status-border-unable { border: 2px solid #ffc107 !important; border-left: 10px solid #ffc107 !important; }
.calendar-page .fc-event.status-border-missed { border: 2px solid #c00000 !important; border-left: 10px solid #c00000 !important; }
.calendar-page .fc-event.status-border-pending { border: 2px solid #2d6cdf !important; border-left: 10px solid #2d6cdf !important; }
.calendar-page .event-status-icon { float: right; margin-left: 6px; font-size: 1.3em; text-shadow: 0 1px 2px rgba(0,0,0,0.3); }
.calendar-page .event-attach-icon { margin-right: 5px; color: #fff; font-size: 1.2em; font-weight: bold; text-shadow: 0 1px 3px rgba(0,0,0,0.8); }
.calendar-page .fc-event-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.calendar-page .fc-event-actions .btn { font-size: 0.75rem; padding: 2px 10px; line-height: 1.3; color: white; border: 1px solid rgba(255,255,255,0.3); box-shadow: 0 2px 5px rgba(0,0,0,0.4); font-weight: 600; }
.calendar-page .fc-event-actions .btn:hover { filter: brightness(0.9); text-decoration: none; transform: translateY(-1px); box-shadow: 0 4px 6px rgba(0,0,0,0.5); }
.calendar-page .fc-event-actions .btn-reset { background: #e2e6ea !important; color: #333 !important; border: 1px solid #adb5bd !important; }
.calendar-page .fc-event-actions .btn-warning { color: #212529 !important; background-color: #ffc107 !important; border-color: #ffc107 !important; }

/* LEGEND & STATUS KEYS */
.calendar-legend { display: flex; align-items: center; flex-wrap: wrap; gap: 15px; margin-top: 15px; font-size: 0.9rem; }
.calendar-legend-pill { padding: 0.25em 0.6em; border-radius: 0.25rem; color: white; font-weight: bold; font-size: 75%; text-transform: capitalize; }
.calendar-status-pill { padding: 5px 12px; border-radius: 4px; font-weight: bold; display: flex; align-items: center; gap: 5px; font-size: 0.85rem; box-shadow: 0 1px 2px rgba(0,0,0,0.1); }

body.calendar-page .calendar-page .status-key-complete,
body.calendar-page .calendar-page .badge-success, 
body.calendar-page .calendar-page .status-completed { background-color: #2e7d32 !important; color: white !important; }

body.calendar-page.calendar-page .status-key-pending,
body.calendar-page.calendar-page .badge-primary, 
body.calendar-page.calendar-page .status-pending { background-color: #3b82f6 !important; color: white !important; }

body.calendar-page .calendar-page .status-key-unable,
.calendar-page .badge-warning, 
.calendar-page .status-unable, 
.calendar-page .status-unable_to_complete { background-color: #ffc107 !important; color: #212529 !important; }

.fc-day-other:nth-child(odd), .fc-daygrid-day:nth-child(odd) { background-color: #f0f0f0; }
.fc-day-other:nth-child(even), .fc-daygrid-day:nth-child(even) { background-color: #ffffff; }
.fc-toolbar-title { cursor: pointer; user-select: none; }
#month-jumper-container { position: absolute; z-index: 1000; display: none; }
#month-jumper-container.show { display: block; }
.highlight-event { animation: flash-shadow 1.5s infinite; z-index: 1000 !important; border: 2px solid #000 !important; background-color: #ffff99 !important; }
@keyframes flash-shadow { 0% { box-shadow: 0 0 8px 3px rgba(255, 0, 0, 0.7); } 50% { box-shadow: 0 0 8px 3px rgba(255, 0, 0, 0); } 100% { box-shadow: 0 0 8px 3px rgba(255, 0, 0, 0.7); } }

/* --- 5. MODULE: WORKER JOBS (worker_jobs.php) --- */
.worker-page .job-card, .worker-page .worker-job-card { border-left: 5px solid #ccc; border-radius: 4px; transition: all 0.2s; background: white; margin-bottom: 15px; }
.worker-page .worker-job-card:active { transform: scale(0.99); }
.worker-page .border-success { border-left-color: var(--success-green) !important; }
.worker-page .border-danger { border-left-color: var(--danger-red) !important; }
.worker-page .border-primary { border-left-color: var(--primary-blue) !important; }
.worker-page .border-warning { border-left-color: var(--warning-yellow) !important; }
.worker-page .border-purple { border-left-color: #a855f7 !important; }
.worker-page .bg-light-yellow { background-color: #fff3cd !important; }
.worker-page .bg-light-blue { background-color: #e6f0ff !important; }
.worker-page .bg-light-red { background-color: #fff5f5 !important; }
.worker-page .bg-light-success { background-color: #f0fff4 !important; }
.worker-page .bg-light-purple { background-color: #f3e8ff !important; }
.worker-page .bg-light-purple .job-title { color: #581c87 !important; }
.worker-page .nav-tabs .nav-link.active { color: var(--primary-blue); border-bottom: 3px solid var(--primary-blue); font-weight: bold; }
.worker-page .loading-sentinel { text-align: center; padding: 20px; color: #666; font-style: italic; display: block; visibility: hidden; height: 50px; }
.worker-page .loading-sentinel.active { visibility: visible; }

/* --- 6. MODULE: MAP VIEW (map_view.php) --- */
.map-view-page .map-container { flex: 1; position: relative; width: 100%; height: 100%; z-index: 1; }
.map-view-page #map { height: 100%; width: 100%; background: #e9e9e9; }
.map-view-page .map-controls-overlay { position: absolute; top: 20px; left: 20px; bottom: 20px; width: 380px; background: rgba(255, 255, 255, 0.98); border-radius: 8px; z-index: 1000; display: flex; flex-direction: column; box-shadow: 0 4px 20px rgba(0,0,0,0.15); }
.map-view-page .overlay-header { padding: 15px; border-bottom: 1px solid #eee; background: #fff; flex-shrink: 0; }
.map-view-page .date-nav { display: flex; align-items: center; background: #f8f9fa; border-radius: 6px; padding: 4px; border: 1px solid #e9ecef; }
.map-view-page .date-nav button { border: none; background: none; color: #6c757d; padding: 5px 12px; cursor: pointer; transition: 0.2s; }
.map-view-page .date-nav button:hover { color: #007bff; background: #e2e6ea; border-radius: 4px; }
.map-view-page .date-nav input { border: none; background: transparent; text-align: center; font-weight: 600; color: #333; width: 100%; outline: none; }
.map-view-page #engineer-list { flex: 1; overflow-y: auto; padding: 15px; background: #f9f9f9; }
.map-view-page .tech-group { margin-bottom: 25px; }
.map-view-page .tech-header { font-weight: 700; font-size: 11px; color: #6c757d; padding-bottom: 5px; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 2px solid #e9ecef; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.map-view-page .map-job-card { background: white; border: 1px solid #eef0f3; border-radius: 6px; margin-bottom: 10px; padding: 12px; cursor: pointer; transition: all 0.2s ease; border-left: 4px solid #ccc; position: relative; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.02); }
.map-view-page .map-job-card:hover { border-color: #007bff; box-shadow: 0 4px 12px rgba(0,0,0,0.08); transform: translateY(-2px); }
.map-view-page .map-job-card.status-completed { border-left-color: #28a745; }
.map-view-page .map-job-card.status-in-progress { border-left-color: #a855f7; }
.map-view-page .map-job-card.status-pending { border-left-color: #007bff; }
.map-view-page .map-job-card.status-missed { border-left-color: #dc3545; }
.map-view-page .map-job-card.status-issue { border-left-color: #ffc107; }
.map-view-page .job-type-tag { font-size: 10px; font-weight: bold; padding: 2px 6px; border-radius: 4px; text-transform: uppercase; float: right; margin-left: 5px; }
.map-view-page .tag-ppm { background: #e3f2fd; color: #0d47a1; }
.map-view-page .tag-reactive { background: #fff3e0; color: #e65100; border: 1px solid #ffe0b2; }
.map-view-page .map-legend { background: #fff; padding: 10px 15px; border-top: 1px solid #eee; font-size: 11px; flex-shrink: 0; }
.map-view-page .legend-item { display: inline-flex; align-items: center; margin-right: 12px; }
.map-view-page .legend-dot { width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; display: inline-block; }
.map-view-page .custom-pin-marker { background-color: #fff; border-radius: 50%; border: 2px solid #666; width: 14px; height: 14px; box-shadow: 0 2px 4px rgba(0,0,0,0.3); }
.map-view-page .pin-completed { background-color: #28a745; border-color: #1e7e34; }
.map-view-page .pin-in-progress { background-color: #a855f7; border-color: #7e22ce; }
.map-view-page .pin-pending { background-color: #007bff; border-color: #0056b3; }
.map-view-page .pin-missed { background-color: #dc3545; border-color: #bd2130; }
.map-view-page .pin-issue { background-color: #ffc107; border-color: #d39e00; }
.map-view-page .pulse-ring { border: 3px solid #a855f7; border-radius: 50%; height: 30px; width: 30px; position: absolute; left: -8px; top: -8px; animation: pulsate 1.5s ease-out infinite; opacity: 0.0; }
@keyframes pulsate { 0% {transform: scale(0.1, 0.1); opacity: 0.0;} 50% {opacity: 1.0;} 100% {transform: scale(1.2, 1.2); opacity: 0.0;} }
.map-view-page .leaflet-popup-content-wrapper { padding: 0; overflow: hidden; border-radius: 6px; }
.map-view-page .leaflet-popup-content { margin: 0; width: 320px !important; }
.map-view-page .leaflet-popup-close-button { color: #fff !important; font-size: 24px !important; top: 8px !important; right: 8px !important; }
.map-view-page .custom-popup-wrapper { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; display: flex; flex-direction: column; }
.map-view-page .cp-header { background-color: #343a40; color: white; padding: 12px 15px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #444; }
.map-view-page .cp-header-title { font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: 0.5px; }
.map-view-page .cp-body { max-height: 250px; overflow-y: auto; background-color: #f8f9fa; }
.map-view-page .cp-job-item { background: white; padding: 15px; border-bottom: 1px solid #e9ecef; transition: background 0.2s; }
.map-view-page .cp-job-item:hover { background: #fff; }
.map-view-page .cp-badges { display: flex; justify-content: space-between; margin-bottom: 8px; }
.map-view-page .cp-status-badge { font-size: 10px; font-weight: bold; padding: 3px 8px; border-radius: 4px; color: white; text-transform: uppercase; }
.map-view-page .cp-type-badge { font-size: 10px; font-weight: bold; padding: 3px 8px; border-radius: 4px; background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.map-view-page .cp-title { font-size: 14px; font-weight: 700; color: #212529; margin-bottom: 4px; line-height: 1.4; }
.map-view-page .cp-address { font-size: 12px; color: #6c757d; margin-bottom: 12px; display: block; }
.map-view-page .cp-footer { display: flex; justify-content: space-between; align-items: center; }
.map-view-page .cp-view-btn { background: #007bff; color: white; border: none; padding: 6px 14px; font-size: 12px; font-weight: 600; border-radius: 4px; text-decoration: none; display: inline-block; }
.map-view-page .cp-view-btn:hover { background: #0056b3; color: white; text-decoration: none; }
.map-view-page .cp-tech { font-size: 11px; color: #adb5bd; font-style: italic; }

@media (max-width: 1024px) { 
    .map-view-page .map-controls-overlay { 
        top: auto !important; bottom: 0 !important; left: 0 !important; 
        width: 100% !important; height: 32vh !important; border-radius: 20px 20px 0 0 !important; 
        box-shadow: 0 -4px 15px rgba(0,0,0,0.15) !important; z-index: 1000 !important;
    }
    .map-view-page .overlay-header { padding: 8px 15px !important; }
    .map-view-page #engineer-list { padding: 8px 15px !important; }
    .map-view-page .leaflet-bottom { bottom: 33vh !important; } 
}

/* --- 7. MODULE: QUOTE BUILDER (quote_builder.php) --- */
.builder-wrapper { flex: 1; display: flex; overflow: hidden; height: calc(100vh - 130px); }
.builder-source-panel { width: 20%; background: #fff; border-right: 1px solid #ddd; overflow-y: auto; padding: 20px; } 
.builder-canvas-panel { width: 80%; padding: 20px; overflow-y: auto; background: #f0f2f5; }
.builder-quote-sheet { background: white; padding: 40px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); border-radius: 8px; width: 95%; margin: 0 auto; min-height: 800px; position: relative; }
.builder-info-card { background: #f8f9fa; border: 1px solid #e9ecef; margin-bottom: 15px; border-radius: 6px; }
.builder-toolbar { background: white; padding: 10px 20px; border-bottom: 1px solid #ddd; display: flex; justify-content: space-between; align-items: center; z-index: 100; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.source-header { padding: 10px 15px; font-weight: bold; border-bottom: 1px solid #e9ecef; display: flex; justify-content: space-between; align-items: center; }
.line-item-row { border-bottom: 1px solid #eee; }
.currency-input { text-align: right; font-family: monospace; font-weight: bold; }
#rolled-up-hint { display: none; background-color: #e3f2fd; color: #0c5460; border: 1px solid #b8daff; padding: 10px; border-radius: 5px; margin-bottom: 15px; font-size: 0.9rem; }
#manual-save-alert { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 1050; width: 300px; text-align: center; display: none; }
#lightboxModal .modal-content { background-color: transparent; border: none; }
#lightboxModal .modal-body { padding: 0; text-align: center; position: relative; }
#lightboxModal img { max-width: 100%; max-height: 90vh; box-shadow: 0 0 20px rgba(0,0,0,0.5); border: 3px solid white; }

/* --- 8. MODULE: YEAR PLANNER (year_planner.php) --- */
/* Page Wrapper Class */
.planner-page .year-planner-table-container { overflow-x: auto; }
.planner-page .year-planner-table { border-collapse: collapse; width: 100%; min-width: 1800px; }
.planner-page .year-planner-table th, .planner-page .year-planner-table td { border: 1px solid #dee2e6; text-align: center; padding: 0.25rem; font-size: 0.8rem; }
.planner-page .year-planner-table thead th { background-color: #f8f9fa; position: sticky; top: 0; z-index: 10; }
.planner-page .year-planner-table thead tr:first-child th { background-color: #e9ecef; font-size: 0.9rem; font-weight: bold; }
.planner-page .year-planner-table thead tr:nth-child(2) th, .planner-page .year-planner-table thead tr:nth-child(3) th { background-color: #ced4da; font-weight: bold; }
.planner-page .year-planner-task-header { min-width: 250px; text-align: left; position: sticky; left: 0; background-color: inherit; z-index: 11; font-weight: bold; font-size: calc(0.8rem + 1px); }
.planner-page .year-planner-table tbody tr:nth-child(odd) .year-planner-task-header { background-color: #f2f2f2; }
.planner-page .year-planner-table tbody tr:nth-child(even) .year-planner-task-header { background-color: #ffffff; }
.planner-page .year-planner-month-header { font-weight: bold; }
.planner-page .year-planner-week-cell { min-width: 35px; }
.planner-page .year-planner-table tbody tr:nth-child(odd) td { background-color: #f2f2f2; }
.planner-page .year-planner-table tbody tr:nth-child(even) td { background-color: #ffffff; }
.planner-page .planner-status-marker { display: inline-block; width: 100%; height: 100%; min-height: 24px; line-height: 24px; border-radius: 3px; color: white; }
.planner-page .month-boundary-right { border-right: 2px solid #343a40 !important; }
.planner-page .planner-legend ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 15px; }
.planner-page .planner-legend .planner-legend-marker { width: 24px; height: 24px; border-radius: 3px; margin-right: 6px; text-align: center; line-height: 24px; font-size: 1rem; display: inline-block; color: white; }
.planner-page .print-header-info { margin-bottom: 20px; border-bottom: 2px solid #333; padding-bottom: 10px; }

/* Year Planner Specific Status Colors (Separate from Calendar) */
.planner-page .legend-marker-complete { background-color: #50a545 !important; color: white !important; } /* Monthly Green */
.planner-page .legend-marker-pending { background-color: #50a545 !important; color: white !important; opacity: 0.6; } /* Pending Greenish */
.planner-page .legend-marker-unable { background-color: #ffc107 !important; color: #212529 !important; }

/* --- 9. MODULE: MANAGE CLIENTS/PROJECTS/SUPPLIERS (Shared Admin Styles) --- */
.clients-page .nav-tabs .nav-link, .projects-page .nav-tabs .nav-link, .suppliers-page .nav-tabs .nav-link {
    border: 1px solid transparent; border-top-left-radius: 0.25rem; border-top-right-radius: 0.25rem; color: #6c757d; font-weight: 500; padding: 0.75rem 1.25rem; margin-right: 2px;
}
.clients-page .nav-tabs .nav-link.active, .projects-page .nav-tabs .nav-link.active, .suppliers-page .nav-tabs .nav-link.active {
    color: #495057; background-color: #fff; border-color: #dee2e6 #dee2e6 #fff; border-top: 3px solid var(--primary-blue); font-weight: bold;
}
.clients-page .nav-tabs::-webkit-scrollbar, .clients-page .table-responsive::-webkit-scrollbar { display: none; }
.clients-page .nav-tabs, .clients-page .table-responsive { -ms-overflow-style: none; scrollbar-width: none; }
.projects-page .progress { height: 10px; border-radius: 10px; background-color: #e9ecef; }
.suppliers-page .supplier-contact-row { background: #f9f9f9; padding: 10px; border: 1px solid #eee; margin-bottom: 5px; border-radius: 4px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.suppliers-page .remove-row-btn { cursor: pointer; color: red; font-weight: bold; font-size: 1.2rem; }
.suppliers-page .supplier-verify-card { border-left: 4px solid var(--warning-yellow); transition: transform 0.2s; }
.suppliers-page .supplier-verify-card:hover { transform: translateY(-2px); box-shadow: 0 4px 8px rgba(0,0,0,0.1); }
.clients-page .client-search-container, .projects-page .project-search-container, .buildings-page .building-search-container { max-width: 400px; }

/* --- 10. MODULE: MANAGE TEMPLATES (manage_templates.php) --- */
.templates-page .field-row { display: flex; align-items: center; border-bottom: 1px solid #eee; padding: 8px 0; background: #fff; transition: all 0.3s; flex-wrap: wrap; }
.templates-page .field-row:last-child { border-bottom: none; }
.templates-page .col-sort { width: 30px; text-align:center; }
.templates-page .col-label { width: 25%; padding: 0 5px; }
.templates-page .col-type { width: 15%; padding: 0 5px; }
.templates-page .col-opts { width: 20%; padding: 0 5px; }
.templates-page .col-req { width: 60px; text-align:center; }
.templates-page .col-actions { flex-grow: 1; text-align: right; padding: 0 5px; white-space: nowrap; }
.templates-page .template-section-card { border: 1px solid var(--primary-blue); margin-bottom: 25px; border-radius: 0.25rem; overflow: hidden; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.templates-page .template-section-header { background-color: var(--primary-blue); color: white; padding: 10px 15px; display: flex; justify-content: space-between; align-items: center; cursor: move; }
.templates-page .template-section-body { background-color: #fff; padding: 15px; min-height: 50px; }
.templates-page .blueprint-card { border-left: 4px solid var(--success-green); transition: transform 0.2s; }
.templates-page .logic-row { width: 100%; padding: 5px 0 5px 40px; background-color: #f1f8ff; font-size: 0.85rem; border-top: 1px dashed #ccc; display:none; }
.templates-page .logic-row.active { display: flex; align-items: center; gap: 10px; }
.templates-page .soft-deleted { opacity: 0.6; background-color: #f2f2f2 !important; filter: grayscale(100%); border-left: 4px solid #dc3545; }
.templates-page .template-card.archived { opacity: 0.5; background-color: #e9ecef; filter: grayscale(100%); border: 1px dashed #6c757d; }
.templates-page .nav-tabs { border-bottom: 1px solid #dee2e6; background: #fff; padding-top: 8px; }
.templates-page .nav-tabs .nav-link { border: 1px solid transparent; border-bottom: none; border-top-left-radius: 0.25rem; border-top-right-radius: 0.25rem; color: #6c757d; font-weight: 500; padding: 0.75rem 1.25rem; margin-right: 2px; transition: all 0.2s; }
.templates-page .nav-tabs .nav-link.active { color: #495057 !important; background-color: #fff !important; border-color: #dee2e6 #dee2e6 #fff !important; border-top: 3px solid #007bff !important; font-weight: bold; }
.templates-page .drag-handle { cursor: move; color: #aaa; font-size: 18px; }
.templates-page .glob-check-wrapper { margin-left: 20px; color: white; display: flex; align-items: center; }
.templates-page .glob-check-wrapper label { margin: 0; font-weight: normal; font-size: 0.9em; margin-left: 5px; cursor: pointer; }

/* --- 11. MODULE: USERS & SETTINGS (users.php, settings.php) --- */
.users-page .users-tabs .nav-link.active { border-top: 3px solid var(--success-green); font-weight: bold; }
.users-page .skill-badge { font-size: 0.75rem; margin-right: 2px; }
.users-page .building-item { transition: all 0.2s; }
.settings-page .settings-preview-img { max-width: 200px; max-height: 80px; border: 1px solid #ddd; padding: 5px; margin-top: 10px; background: #fff; display:block; }

/* --- 12. MODULE: TICKETS (create_ticket.php, edit_ticket.php, complete_job.php) --- */
.create-ticket-page .ticket-scope-box, .edit-ticket-page .ticket-scope-box { background: #e3f2fd; border: 1px solid #90caf9; border-radius: 5px; padding: 10px; margin-bottom: 15px; }
.create-ticket-page .ticket-lock-alert, .edit-ticket-page .ticket-lock-alert { font-size: 0.9rem; margin-top: 5px; }
.complete-job-page .job-section-card { border: 1px solid #ccc; margin-bottom: 20px; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.complete-job-page .job-section-header { background-color: #343a40; color: white; padding: 10px 15px; font-weight: bold; }
.complete-job-page .job-section-body { padding: 15px; }
.complete-job-page .req-star { color: red; }
.complete-job-page .sig-pad-box { border: 2px dashed #ccc; background: #fff; height: 150px; position: relative; width: 100%; }
.complete-job-page .sig-overlay { position: absolute; top:0; left:0; width:100%; height:100%; background:rgba(255,255,255,0.8); display:none; align-items:center; justify-content:center; z-index: 10; }
.complete-job-page canvas { display: block; width: 100%; height: 100%; }
.complete-job-page .existing-sig-img { max-height: 100px; display: block; margin-bottom: 10px; border: 1px solid #ddd; }
.complete-job-page .validation-error { border: 2px solid #dc3545 !important; background-color: #fff0f0 !important; }
.complete-job-page .validation-error-wrapper { 
    border: 2px dashed #dc3545 !important; 
    background-color: #fff5f5 !important; 
    padding: 10px; 
    border-radius: 6px; 
    margin-bottom: 10px; 
}
.create-ticket-page input[disabled], .edit-ticket-page input[disabled] { background-color: #e9ecef; color: #495057; cursor: not-allowed; opacity: 0.7; }

/* --- 13. MODULE: PREVIEWS AND REPORTS (CSS Class Based) --- */

/* QUOTE PDF PREVIEW SPECIFIC STYLES */
.pdf-preview-body .custom-header { width: 100%; margin-bottom: 20px; border: none; }
.pdf-preview-body .info-table { width: 100%; border-collapse: collapse; margin-bottom: 30px; }
.pdf-preview-body .info-table td { vertical-align: top; }
.pdf-preview-body .col-company { width: 50%; padding-right: 20px; }
.pdf-preview-body .col-client { width: 50%; padding-left: 20px; }
.pdf-preview-body .logo { max-width: 250px; max-height: 100px; margin-bottom: 15px; display: block; }
.pdf-preview-body .company-details { font-size: 13px; line-height: 1.5; color: #555; }
.pdf-preview-body .client-header { font-weight: bold; margin-bottom: 5px; color: #000; }
.pdf-preview-body .meta-grid { width: 100%; border-collapse: collapse; margin-top: 15px; }
.pdf-preview-body .meta-grid td { border: 1px solid #ddd; padding: 6px; font-size: 12px; }
.pdf-preview-body .meta-key { background-color: #f9f9f9; font-weight: bold; width: 35%; color: #333; }
.pdf-preview-body .items-table { width: 100%; border-collapse: collapse; margin-top: 20px; }
.pdf-preview-body .items-table th { background: #e9ecef; padding: 8px; border: 1px solid #ccc; text-align: left; font-weight: 600; color: #333; }
.pdf-preview-body .items-table td { padding: 10px; border-bottom: 1px solid #eee; border-left: 1px solid #eee; border-right: 1px solid #eee; }
.pdf-preview-body .totals-box { width: 250px; float: right; margin-top: 20px; border: 1px solid #ddd; }
.pdf-preview-body .totals-box td { padding: 6px 10px; }
.pdf-preview-body .totals-key { font-weight: bold; background: #f9f9f9; width: 50%; }
.pdf-preview-body .totals-val { text-align: right; }
.pdf-preview-body .custom-footer { width: 100%; margin-top: 40px; border-top: 1px solid #eee; padding-top: 20px; clear: both; }

/* JOB REPORT SPECIFIC STYLES (view_report.php) */
.report-view-page .header-box { display: flex; justify-content: space-between; border-bottom: 4px solid var(--brand-blue); padding-bottom: 10px; margin-bottom: 25px; }
.report-view-page .logo-img { max-height: 60px; max-width: 250px; }
.report-view-page .report-info { text-align: right; color: #333; }
.report-view-page .report-info h1 { margin: 0; font-size: 20px; color: #333; font-weight: 800; text-transform: uppercase; }
.report-view-page .info-table, .report-view-page .check-table { width: 100%; border-collapse: collapse; margin-bottom: 30px; font-size: 13px; }
.report-view-page .info-table th, .report-view-page .check-table th { background: var(--table-header-bg); text-align: left; padding: 6px 10px; border: 1px solid var(--border-color); font-weight: 700; color: #444; }
.report-view-page .info-table td, .report-view-page .check-table td { border: 1px solid var(--border-color); padding: 6px 10px; color: #000; vertical-align: top;}
.report-view-page .info-table th { width: 15%; }
.report-view-page .info-table td { width: 35%; }
.report-view-page .section-bar { background-color: var(--brand-blue); color: white; font-weight: 700; padding: 6px 10px; text-transform: uppercase; font-size: 13px; margin-top: 25px; border: 1px solid var(--brand-blue); }
.report-view-page .status-pass { font-weight: bold; color: #2E7D32; } 
.report-view-page .status-fail { font-weight: bold; color: #C62828; } 
.report-view-page .engineer-header { background-color: #f8f9fa; border: 1px solid #ddd; padding: 10px; margin-top: 30px; font-weight: bold; font-size: 14px; color: #333; border-left: 5px solid var(--brand-blue); display: flex; justify-content: space-between; align-items: center; }
.report-view-page .sig-row { display: flex; justify-content: space-between; margin-top: 20px; padding-top: 10px; }
.report-view-page .sig-col { width: 48%; }
.report-view-page .sig-label { font-weight: 700; font-size: 12px; margin-bottom: 10px; color: #333; }
.report-view-page .sig-img { max-height: 60px; max-width: 200px; display: block; }
.report-view-page .sig-unavailable { border: 1px dashed #d9534f; background: #fdf7f7; color: #d9534f; text-align: center; padding: 15px; font-style: italic; font-size: 11px; }
.report-view-page .photo-grid { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 10px; }
.report-view-page .photo-frame { width: 32%; border: 1px solid #ccc; padding: 4px; background: #fff; break-inside: avoid; }
.report-view-page .photo-frame img { width: 100%; height: auto; display: block; }
.report-view-page .btn-custom { padding: 10px 25px; font-weight: 600; font-size: 15px; border-radius: 5px; border: 1px solid var(--brand-blue); background: var(--brand-blue); color: white; margin: 0 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.2); transition: all 0.2s ease; cursor: pointer; text-decoration: none; display: inline-block; }

/* PUBLIC QUOTE STYLES */
.public-status-banner { padding: 10px 20px; border-radius: 5px; font-weight: bold; color: white; text-align: center; margin-bottom: 15px; }
.status-accepted { background-color: #28a745; }
.status-rejected { background-color: #dc3545; }

body.calendar-page .calendar-legend { display: flex !important; flex-wrap: nowrap !important; align-items: center !important; flex-direction: row !important; gap: 20px !important; width: 100% !important; overflow-x: visible !important; }
body.calendar-page .legend-group { display: flex !important; flex-direction: row !important; align-items: center !important; white-space: nowrap !important; margin-left: 0 !important; }

/* ==========================================================================
   UNIFIED PRINT SETTINGS (FORCES WHITE PAPER + KEEPS COLORS)
   ========================================================================== */
@media print {
    /* 1. Force Page Background White (Saves Ink) */
    body, 
    body.planner-page, 
    body.report-view-page, 
    body.pdf-preview-body,
    body.public-quote-page { 
        background-color: white !important; 
        background: white !important;
        margin: 0 !important; 
        padding: 0 !important;
        color: black !important;
        /* CRITICAL: Allows background colors (like green/blue pills) to print */
        -webkit-print-color-adjust: exact !important; 
        print-color-adjust: exact !important;
    }

    /* 2. Force Containers White (Override Grey Theme) */
    .year-planner-table-container,
    .card, 
    .card-body,
    .bg-light,
    .bg-white,
    .form-section-card {
        background-color: white !important;
        background: white !important;
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }

    /* Remove outer border from actual printed documents */
    .quote-pdf-page, 
    .public-quote-container,
    .report-page {
        background-color: white !important;
        background: white !important;
        box-shadow: none !important;
        border: none !important; /* Kills the page border */
    }

    /* 3. Hide Navigation & Tools */
    .no-print, 
    .action-bar, 
    .toolbar, 
    .public-action-bar, 
    nav, 
    .navbar, 
    .btn { 
        display: none !important; 
    }

    /* 4. Report & Quote Specifics */
    .report-view-page .report-page,
    .pdf-preview-body .quote-pdf-page { 
        width: 100% !important; 
        max-width: 100% !important; 
        margin: 0 !important; 
        padding: 10mm !important; 
        min-height: auto !important; 
    }

    /* Increase Quote Font Sizes for Printing */
    .pdf-preview-body .quote-pdf-page {
        font-size: 16px !important;
    }
    .pdf-preview-body .company-details {
        font-size: 15px !important;
    }
    .pdf-preview-body .meta-grid td {
        font-size: 14px !important;
        padding: 8px !important; /* Extra breathing room */
    }
    .pdf-preview-body .items-table th,
    .pdf-preview-body .items-table td {
        font-size: 15px !important;
        padding: 12px !important; /* Taller rows */
    }
    .pdf-preview-body .totals-box td {
        font-size: 16px !important;
        padding: 10px !important;
    }
	
	/* ==========================================================================
   PRINTER-FRIENDLY TABLE BORDER FIX
   ========================================================================== */
@media print {
    /* 1. JOB REPORTS: Info Table & Check Table */
    .report-page .info-table th, .report-page .info-table td,
    .report-page .check-table th, .report-page .check-table td,
    .report-page .history-table th, .report-page .history-table td {
        border: 1px solid #999999 !important;
    }

    /* 2. QUOTES / ESTIMATES: Items, Meta, and Totals (Skips the layout tables) */
    .quote-pdf-page .items-table th, .quote-pdf-page .items-table td,
    .public-quote-page .items-table th, .public-quote-page .items-table td,
    .quote-pdf-page .meta-grid td, .public-quote-page .meta-grid td,
    .quote-pdf-page .totals-box td, .public-quote-page .totals-box td {
        border: 1px solid #999999 !important;
    }

    /* 3. Force headers to print with a solid light-grey background */
    .report-page .info-table th,
    .report-page .check-table th,
    .report-page .history-table th,
    .quote-pdf-page .items-table th,
    .public-quote-page .items-table th,
    .quote-pdf-page .meta-key,
    .public-quote-page .meta-key,
    .quote-pdf-page .totals-key,
    .public-quote-page .totals-key {
        background-color: #f0f0f0 !important;
        color: #000000 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}

    /* 5. Year Planner Specifics */
    .planner-page .year-planner-table-container { overflow-x: visible; padding: 0; }
    .planner-page .year-planner-table { min-width: 0; width: 100% !important; font-size: 0.65rem; }
    
    /* 6. Headers */
    .section-bar { 
        background: var(--brand-blue) !important; 
        color: white !important; 
    }
    
    /* 7. Page Size */
    @page { size: auto; margin: 5mm; }
}

/* ==========================================================================
   WORKER PAGE MOBILE OPTIMIZATIONS
   (Paste this at the very bottom of style.css)
   ========================================================================== */
@media screen and (max-width: 768px) {
    
    /* 1. Maximize Screen Width for Cards */
    .worker-page .container, 
    .worker-page .container-fluid { 
        padding-left: 4px !important; 
        padding-right: 4px !important; 
        width: 100% !important; 
    }
    .worker-page .card { 
        margin-left: 0 !important; 
        margin-right: 0 !important; 
        width: 100% !important; 
        border-radius: 0 !important; 
    }

    /* 2. Fix Job Card Header Alignment */
    .worker-job-card .d-flex.justify-content-between {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: flex-start !important;
    }

    /* 3. Make Bottom Action Buttons (Start/Complete/Files) Huge */
    .worker-job-card .mt-3.d-flex {
        display: flex !important;
        gap: 8px !important;
        width: 100% !important;
    }
    .worker-job-card .mt-3.d-flex .btn {
        flex: 1 !important;
        padding: 12px 0 !important;
        font-size: 14px !important;
        margin-right: 0 !important;
    }

    /* 4. BIGGER CONTACT BUTTONS (David Smith Phone/Whatsapp) */
    /* Target the container holding the client contact info */
    .worker-job-card .small.mt-2.p-1.border.rounded.bg-light {
        display: flex !important;       /* Use Flexbox to align items */
        align-items: center !important;
        flex-wrap: wrap !important;
        padding: 10px !important;       /* More padding inside the box */
        margin-top: 10px !important;
        background-color: #f8f9fa !important;
        width: 100% !important;         /* Full width box */
    }

    /* Target the Contact Name text to ensure it takes its own line if needed */
    .worker-job-card .small.mt-2.p-1.border.rounded.bg-light strong {
        font-size: 1rem !important;     /* Larger text for name */
        margin-right: auto !important;  /* Push buttons to the right */
        padding-right: 10px;
    }

    /* Target the Phone and WhatsApp icons/links specifically */
    .worker-job-card .small.mt-2.p-1.border.rounded.bg-light a {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        width: 45px !important;         /* Fixed large width */
        height: 45px !important;        /* Fixed large height */
        font-size: 1.4rem !important;   /* Large Icon */
        margin-left: 8px !important;
        border: 1px solid #ccc !important;
        border-radius: 8px !important;  /* Rounded corners */
        background-color: #fff !important;
        text-decoration: none !important;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    /* Active State (Visual feedback when tapped) */
    .worker-job-card .small.mt-2.p-1.border.rounded.bg-light a:active {
        background-color: #e9ecef !important;
        transform: scale(0.95);
    }
    
    /* Specific colors for icons inside these new buttons */
    .worker-job-card .small.mt-2.p-1.border.rounded.bg-light a .fa-phone { color: #007bff; }
    .worker-job-card .small.mt-2.p-1.border.rounded.bg-light a .fa-whatsapp { color: #28a745; }
}

/* ==========================================================================
   REPORT VIEW MOBILE OPTIMIZATIONS
   (Paste this at the very bottom of style.css)
   ========================================================================== */
@media screen and (max-width: 768px) {

    /* 1. Hide Toolbar (Print/Back buttons) */
    .report-view-page .toolbar {
        display: none !important;
    }

    /* 2. Full Screen Width (Remove "Paper" look) */
    body.report-view-page {
        background-color: #ffffff !important; /* Remove grey background */
        padding: 0 !important;
    }

    .report-view-page .report-page {
        width: 100% !important;
        max-width: 100% !important;
        padding: 10px !important; /* Minimal padding */
        margin: 0 !important;
        box-shadow: none !important;
        border: none !important;
    }

    /* 3. Reduce Font Size */
    .report-view-page, 
    .report-view-page table, 
    .report-view-page .section-bar, 
    .report-view-page .engineer-header {
        font-size: 11px !important;
    }
    
    .report-view-page h1 {
        font-size: 18px !important; /* Smaller Header */
    }

    /* 4. Responsive Info Table (Transform 4 columns to 2 columns) */
    /* This forces the row to wrap, so you see Label | Value on one line */
    .report-view-page .info-table tr {
        display: flex;
        flex-wrap: wrap;
    }
    .report-view-page .info-table th, 
    .report-view-page .info-table td {
        width: 50% !important; /* Force 2 columns */
        box-sizing: border-box;
        display: block; 
        padding: 4px 6px !important;
    }
    /* Add border to separate the stacked rows visually */
    .report-view-page .info-table td {
        border-bottom: 1px solid #eee;
    }

    /* 5. Stack Signatures Vertically */
    .report-view-page .sig-row {
        flex-direction: column !important;
        gap: 15px;
    }
    .report-view-page .sig-col {
        width: 100% !important;
    }

    /* 6. Photo Grid (2 per row instead of 3 squashed ones) */
    .report-view-page .photo-frame {
        width: 48% !important; 
        margin-bottom: 5px;
    }
    
    /* 7. Header Adjustments */
    .report-view-page .header-box {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .report-view-page .report-info {
        text-align: center !important;
        margin-top: 10px;
    }
    .report-view-page .logo-img {
        max-width: 180px; 
    }
    
    /* 8. History Table Compactness */
    .report-view-page .history-table th, 
    .report-view-page .history-table td {
        padding: 4px !important;
    }
	/* 1. Reset the toolbar container so it is visible */
    .report-view-page .toolbar {
        display: block !important; 
        width: 100% !important;
        text-align: center !important;
        padding: 10px 0 !important;
    }

    /* 2. THIS HIDES THE PRINT BUTTON (The <button> element) */
    .report-view-page .toolbar button {
        display: none !important;
    }

    /* 3. THIS SHOWS THE BACK BUTTON (The <a> link) & makes it full width */
    .report-view-page .toolbar a.btn-custom {
        display: block !important;
        width: 100% !important;
        margin: 0 !important;
        box-sizing: border-box !important;
    }
}

/* ==========================================================================
   ENGINEER UNAVAILABILITY & SKILLS STYLES (v3.0)
   ========================================================================== */

/* 1. Scheduler Unavailability Blocks */
.scheduler-unavail-block {
    position: absolute;
    top: 5px;
    bottom: 5px;
    z-index: 5; /* Sits behind jobs (usually z-index 10+) */
    border-radius: 4px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: all 0.2s;
}

/* Hover Effect */
.scheduler-unavail-block:hover {
    opacity: 1;
    z-index: 50 !important; /* Bring to front on hover so you can click it */
    transform: scaleY(1.05);
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

/* Diagonal Stripe Pattern (The "Hazard" Look) */
.scheduler-unavail-block::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: linear-gradient(45deg,rgba(255,255,255,.2) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.2) 50%,rgba(255,255,255,.2) 75%,transparent 75%,transparent);
    background-size: 1rem 1rem;
    pointer-events: none;
}

/* Text Label inside the block */
.scheduler-unavail-block span {
    background: rgba(0,0,0,0.4);
    padding: 2px 6px;
    border-radius: 4px;
    pointer-events: none;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    max-width: 95%;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* 2. Conflict Resolution Modal */
.conflict-item {
    border-left: 4px solid #dc3545;
    background-color: #fff5f5;
    padding: 12px;
    margin-bottom: 12px;
    border-radius: 4px;
    border: 1px solid #f5c6cb;
    border-left-width: 4px;
}

.conflict-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-weight: bold;
    color: #721c24;
}

.conflict-actions {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #f5c6cb;
    display: flex;
    gap: 10px;
    align-items: center;
}

/* 3. Worker Page "Blocked" Banner */
.worker-blocked-banner {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 6px;
    font-weight: bold;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.worker-blocked-banner i {
    font-size: 1.5rem;
}

/* New: Highlight the row when dragging a job over it */
.track-hover-active {
    background-color: rgba(0, 123, 255, 0.08) !important;
    box-shadow: inset 0 0 10px rgba(0, 123, 255, 0.1);
    outline: 2px dashed #007bff;
    z-index: 10;
}

/* --- BUILDING MANAGER STYLES (Light Mode) --- */
.building-header {
    background-color: #f8f9fa; /* Light Grey Header */
    color: #333;
    border-bottom: 1px solid #dee2e6;
}

.building-body {
    background-color: #ffffff; /* White Body */
    color: #333;
}

.building-table {
    background-color: #ffffff;
    color: #212529;
}
.building-table thead th {
    background-color: #e9ecef;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
}
.building-table td, .building-table th {
    border-top: 1px solid #dee2e6;
}
.building-table tbody tr:hover {
    background-color: rgba(0,0,0,0.05);
}

.existing-photo-wrapper {
    width: 100px;
    height: 100px;
}

.delete-photo-overlay {
    position: absolute;
    top: 0;
    right: 0;
    background: rgba(220, 53, 69, 0.85); /* Bootstrap Danger Red */
    color: white;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom-left-radius: 8px;
    cursor: pointer;
    z-index: 5;
    transition: background 0.2s;
}

.delete-photo-overlay:hover {
    background: rgba(220, 53, 69, 1);
}

/* Visual feedback when the photo is marked for deletion */
.photo-marked-delete img {
    filter: grayscale(1) blur(1px);
    opacity: 0.5;
    border: 2px solid #dc3545 !important;
}

.photo-marked-delete .delete-photo-overlay {
    background: #000; /* Turns black to show it's "selected" for removal */
}

/* ==========================================================================
   FINAL Z-INDEX & TOOLTIP FIXES
   ========================================================================== */

/* 1. JOB LAYERING: Keep jobs under the Engineer Sidebar (1005) */
.scheduler-page .scheduler-job-block {
    z-index: 500 !important; 
}
.scheduler-page .scheduler-job-block:hover {
    z-index: 600 !important; /* Above other jobs, but safely under the sidebar */
}

/* 2. FORCE TIME OFF LOW: Disable 'transform' to prevent layer jumping */
.scheduler-unavail-block {
    z-index: 10 !important;
}
.scheduler-unavail-block:hover {
    z-index: 20 !important; /* Must be lower than 500 */
    transform: none !important; /* CRITICAL: Prevents it from jumping on top */
    opacity: 1 !important;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

/* 3. PORTAL TOOLTIP STYLES (Floats on top of headers/scrollbars) */
.scheduler-portal-tooltip {
    position: fixed; /* This makes it float over EVERYTHING */
    z-index: 999999 !important;
    background: #fff;
    border: 1px solid #ccc;
    padding: 12px 14px;
    border-radius: 8px;
    width: 280px;
    font-size: 0.85rem;
    line-height: 1.4;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    pointer-events: none; /* Let clicks pass through */
    font-family: 'Segoe UI', sans-serif;
}

/* 4. TOOLTIP COLORS (Matches your job colors) */
.scheduler-portal-tooltip.portal-completed { background-color: #d4edda; border-color: #28a745; color: #155724; }
.scheduler-portal-tooltip.portal-completed * { color: #155724 !important; }

.scheduler-portal-tooltip.portal-missed { background-color: #f8d7da; border-color: #dc3545; color: #721c24; }
.scheduler-portal-tooltip.portal-missed * { color: #721c24 !important; }

.scheduler-portal-tooltip.portal-pending { background-color: #cce5ff; border-color: #007bff; color: #004085; }
.scheduler-portal-tooltip.portal-pending * { color: #004085 !important; }

.scheduler-portal-tooltip.portal-in_progress { background-color: #f3e8ff; border-color: #a855f7; color: #581c87; }
.scheduler-portal-tooltip.portal-in_progress * { color: #581c87 !important; }

.scheduler-portal-tooltip.portal-unable { background-color: #fff3cd; border-color: #ffc107; color: #856404; }
.scheduler-portal-tooltip.portal-unable * { color: #856404 !important; }

/* ==========================================================================
   FIXED Z-INDEX LAYERING (Visible Time Bubble)
   ========================================================================== */

/* 1. Top Left Corner (Must be the highest to cover everything) */
body.scheduler-page .header-eng-corner {
    z-index: 1010 !important;
}

/* 2. Engineer Sidebar (Sticky Left)
   Must be higher than the Red Line so the line slides BEHIND it when scrolling */
body.scheduler-page .scheduler-eng-col {
    z-index: 10005 !important;
    position: sticky !important;
}

/* 3. Red Current Time Line & Bubble
   Must be higher than the Header (1000) so the bubble pops out on top,
   but lower than the Sidebar (1005) */
#current-time-line {
    z-index: 1002 !important;
}

/* 4. Time Headers (Sticky Top)
   Base level for the frame */
body.scheduler-page .scheduler-header-row,
body.scheduler-page .scheduler-time-nav {
    z-index: 1000 !important;
}

/* 5. Job Cards (Lowest active layer) */
body.scheduler-page .scheduler-job-block {
    z-index: 500 !important;
}

/* Find your navbar class, usually .navbar */
.navbar {
    position: sticky !important; /* Ensures it stays at the top */
    top: 0;
    z-index: 1111 !important;    /* Forces it to the highest priority */
}

/* Also ensure the dropdown menus stay on top of everything */
.navbar .dropdown-menu {
    z-index: 10000 !important;   /* One step higher than the bar itself */
}
/* ==========================================================================
   PORTAL TOOLTIP FIX (Escapes Scrollbars)
   ========================================================================== */

/* 1. Disable the old trapped CSS hover */
body.scheduler-page .scheduler-job-block:hover .hover-desc {
    display: none !important; 
}

/* 2. Style the new free-floating Portal Tooltip */
.scheduler-portal-tooltip {
    position: fixed; /* Escapes all containers */
    z-index: 999999 !important; /* Maximum priority */
    background: #fff;
    border: 1px solid #ccc;
    padding: 12px 14px;
    border-radius: 8px;
    width: 280px;
    font-size: 0.85rem;
    line-height: 1.4;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    pointer-events: none; /* Lets you click through it */
    font-family: 'Segoe UI', sans-serif;
    color: #333;
}

.scheduler-portal-tooltip strong { font-weight: 700; opacity: 0.9; }
.scheduler-portal-tooltip i { opacity: 0.7; }
.scheduler-portal-tooltip .border-top { border-top-color: rgba(0,0,0,0.1) !important; }

/* 3. The CSS Arrow */
.scheduler-portal-tooltip::after {
    content: " "; position: absolute; left: 50%; margin-left: -8px; 
    border-width: 8px; border-style: solid;
}

/* Open UPWARDS (Default) */
.scheduler-portal-tooltip::after { top: 100%; border-color: #fff transparent transparent transparent; }

/* Open DOWNWARDS */
.scheduler-portal-tooltip.force-bottom::after { top: auto; bottom: 100%; border-color: transparent transparent #fff transparent; }

/* 4. Color Matching */
.scheduler-portal-tooltip.portal-completed { background-color: #d4edda; border-color: #28a745; color: #155724; }
.scheduler-portal-tooltip.portal-completed::after { border-top-color: #d4edda; }
.scheduler-portal-tooltip.portal-completed.force-bottom::after { border-top-color: transparent; border-bottom-color: #d4edda; }
.scheduler-portal-tooltip.portal-completed * { color: #155724 !important; }

.scheduler-portal-tooltip.portal-missed { background-color: #f8d7da; border-color: #dc3545; color: #721c24; }
.scheduler-portal-tooltip.portal-missed::after { border-top-color: #f8d7da; }
.scheduler-portal-tooltip.portal-missed.force-bottom::after { border-top-color: transparent; border-bottom-color: #f8d7da; }
.scheduler-portal-tooltip.portal-missed * { color: #721c24 !important; }

.scheduler-portal-tooltip.portal-pending { background-color: #cce5ff; border-color: #007bff; color: #004085; }
.scheduler-portal-tooltip.portal-pending::after { border-top-color: #cce5ff; }
.scheduler-portal-tooltip.portal-pending.force-bottom::after { border-top-color: transparent; border-bottom-color: #cce5ff; }
.scheduler-portal-tooltip.portal-pending * { color: #004085 !important; }

.scheduler-portal-tooltip.portal-in_progress { background-color: #f3e8ff; border-color: #a855f7; color: #581c87; }
.scheduler-portal-tooltip.portal-in_progress::after { border-top-color: #f3e8ff; }
.scheduler-portal-tooltip.portal-in_progress.force-bottom::after { border-top-color: transparent; border-bottom-color: #f3e8ff; }
.scheduler-portal-tooltip.portal-in_progress * { color: #581c87 !important; }

.scheduler-portal-tooltip.portal-unable { background-color: #fff3cd; border-color: #ffc107; color: #856404; }
.scheduler-portal-tooltip.portal-unable::after { border-top-color: #fff3cd; }
.scheduler-portal-tooltip.portal-unable.force-bottom::after { border-top-color: transparent; border-bottom-color: #fff3cd; }
.scheduler-portal-tooltip.portal-unable * { color: #856404 !important; }

/* Modal Theming for Worker Jobs */
.modal-client-header {
    background: #007bff; /* Primary Blue like Scheduler */
    color: white;
    padding: 15px 20px;
    border-radius: 4px 4px 0 0;
}

.label-text {
    display: block;
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 700;
    color: #6c757d;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

.detail-icon {
    width: 25px;
    display: inline-block;
    text-align: center;
}

#info-additional-contacts-list .card {
    transition: transform 0.2s;
}

#info-additional-contacts-list .card:hover {
    transform: translateY(-2px);
    border-color: #007bff;
}

/* ==========================================================================
   FIXED Z-INDEX LAYERING (Visible Time Bubble)
   ========================================================================== */

/* 1. Top Left Corner (Must be the highest to cover everything) */
body.scheduler-page .header-eng-corner {
    z-index: 1010 !important;
}

/* 2. Engineer Sidebar (Sticky Left)
   Must be higher than the Red Line so the line slides BEHIND it when scrolling */
body.scheduler-page .scheduler-eng-col {
    z-index: 1005 !important; /* FIXED TYPO: Was previously 10005 */
    position: sticky !important;
}

/* 3. Red Current Time Line & Bubble
   Must be higher than the Header (1000) so the bubble pops out on top,
   but lower than the Sidebar (1005) */
#current-time-line {
    z-index: 1002 !important;
}

/* 4. Time Headers (Sticky Top)
   Base level for the frame */
body.scheduler-page .scheduler-header-row,
body.scheduler-page .scheduler-time-nav {
    z-index: 1000 !important;
}

/* 5. Job Cards (Lowest active layer) */
body.scheduler-page .scheduler-job-block {
    z-index: 500 !important;
}

/* 6. Navbar */
.navbar {
    position: sticky !important; 
    top: 0;
    z-index: 1030 !important; /* Bootstrap standard: Above the grid (1010), but below Modals (1050) */
}

/* 7. Dropdown menus */
.navbar .dropdown-menu {
    z-index: 1035 !important; 
}

.settings-page, 
.settings-page .form-control, 
.settings-page .list-group-item {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif !important;
}
/* Fix for invisible text on selected tabs in Light Mode */
.settings-page .list-group-item.active {
    background-color: var(--primary-blue) !important; /* Forces a blue background */
    border-color: var(--primary-blue) !important;
    color: #ffffff !important; /* Forces white text on the blue background */
}

/* Optional: Improve hover visibility */
.settings-page .list-group-item-action:hover {
    background-color: #e9ecef !important;
    color: var(--primary-blue) !important;
}
/* --- UNCONFIRMED APPOINTMENTS (ORANGE) --- */
/* The Pill on the Scheduler */
.scheduler-page .pill-unconfirmed { 
    background-color: #fff3cd !important; 
    border-left: 5px solid #fd7e14 !important; 
    color: #856404 !important; 
    border-top: 1px solid #ffeeba; 
    border-right: 1px solid #ffeeba; 
    border-bottom: 1px solid #ffeeba; 
}
body.dark-mode .scheduler-page .pill-unconfirmed {
    background-color: #5a3c05 !important; 
    border-left: 5px solid #fd7e14 !important; 
    color: #ffffff !important; 
    border-top: 1px solid #735308 !important; 
    border-right: 1px solid #735308 !important; 
    border-bottom: 1px solid #735308 !important; 
}

/* The Hover Tooltip */
.scheduler-portal-tooltip.portal-unconfirmed { 
    background-color: #fff3cd !important; 
    border-color: #fd7e14 !important; 
    color: #856404 !important; 
}
.scheduler-portal-tooltip.portal-unconfirmed::after { border-top-color: #fff3cd !important; }
.scheduler-portal-tooltip.portal-unconfirmed.force-bottom::after { border-top-color: transparent !important; border-bottom-color: #fff3cd !important; }

body.dark-mode .scheduler-portal-tooltip.portal-unconfirmed { 
    background-color: #5a3c05 !important; 
    border-color: #fd7e14 !important; 
    color: #ffffff !important; 
}
body.dark-mode .scheduler-portal-tooltip.portal-unconfirmed::after { border-top-color: #5a3c05 !important; }
body.dark-mode .scheduler-portal-tooltip.portal-unconfirmed.force-bottom::after { border-top-color: transparent !important; border-bottom-color: #5a3c05 !important; }
body.dark-mode .scheduler-portal-tooltip.portal-unconfirmed * { color: #ffffff !important; }

/* ==========================================================================
   MODERN DRAG-TO-SCROLL (HIDE NATIVE SCROLLBARS)
   ========================================================================== */

/* 1. Completely hide the redundant top scrollbar */
#top-scroll-container {
    display: none !important;
}

/* 2. Hide scrollbars on the main canvas but keep it scrollable */
#timelineScrollBox {
    overflow-x: auto !important; 
    -ms-overflow-style: none !important;  /* IE and Edge */
    scrollbar-width: none !important;  /* Firefox */
    cursor: grab; /* Show the open hand cursor */
}

/* Hide scrollbar for Chrome, Safari and Opera */
#timelineScrollBox::-webkit-scrollbar {
    display: none !important;
}

/* 3. Visual feedback when actively dragging */
#timelineScrollBox.is-dragging {
    cursor: grabbing !important; /* Show the closed hand cursor */
}

/* Prevent accidental text highlighting while dragging the grid */
#timelineScrollBox.is-dragging * {
    user-select: none !important;
}

        /* 1. LAYOUT ARCHITECTURE - Seamless Alignment */
        .scheduler-layout-wrapper { display: flex; align-items: stretch; width: 100%; border: 1px solid rgba(0,0,0,0.1); border-radius: 8px; overflow: hidden; background: #fff; box-shadow: 0 4px 12px rgba(0,0,0,0.05); }
        
        /* FIXED: Explicitly kill the internal scrollbox border and radius that caused the 1px drift */
        #timelineScrollBox.scheduler-grid-scrollbox { 
            flex-grow: 1; 
            overflow-x: auto; 
            position: relative; 
            background: #f0f0f0; 
            scrollbar-width: none; 
            border: none !important;      /* Removes the "White Line" */
            border-radius: 0 !important; /* Removes inner rounded corners */
            box-shadow: none !important;
        }

        .scheduler-sidebar-decoupled { 
            width: 220px; 
            flex-shrink: 0; 
            background: #fff; 
            z-index: 100; 
            border-right: 1px solid rgba(0,0,0,0.08); 
            display: flex; 
            flex-direction: column; 
            border-radius: 0 !important; 
        }

        /* BOX MODEL RESET - Kills the "White Line" and Drift */
        .decoupled-row { box-sizing: border-box; border-bottom: 1px solid rgba(0,0,0,0.08); display: flex; align-items: center; overflow: hidden; margin:0 !important; padding:0 !important; border-radius:0 !important; }

        /* 2. GUARANTEED ZEBRA PARITY (Via PHP Classes) */
        .lane-odd { background-color: #eeeeee !important; }
        .lane-even { background-color: #f7f7f7 !important; }
		
		/* NEW: Sidebar specific padding to create the 'inner border' for text blocks */
        .scheduler-sidebar-decoupled .decoupled-row,
        .scheduler-sidebar-decoupled .header-bottom-row {
            padding-left: 20px !important; /* Creates the breathing room you see in the 'TEAM' box */
        }

        /* 3. HEADERS - Centered & Borderless internal */
        .header-top-row { height: 30px; background: #f8fafc; color: #475569; border: none !important; display: flex !important; align-items: center; }
        .header-bottom-row { height: 45px; background: #2c3e50; color: #ffffff; border: none !important; display: flex !important; align-items: center; }
		
		/* FIXED: Add the vertical divider to the Grid Headers to match the lanes below */
        #timelineScrollBox .header-top-row,
        #timelineScrollBox .header-bottom-row {
            border-left: 1px solid rgba(0,0,0,0.08) !important; /* Completes the line seen in your 'Unassigned' table */
        }
        
        /* Dark Mode adjustment for the vertical divider */
        body.dark-mode #timelineScrollBox .header-top-row,
        body.dark-mode #timelineScrollBox .header-bottom-row {
            border-left: 1px solid rgba(255,255,255,0.08) !important;
        }

        /* 4. UNASSIGNED STRIPE RESTORATION */
        .unassigned-row-sidebar { background-color: #fff0f0 !important; color: #dc3545 !important; }
        .unassigned-row-grid { background: repeating-linear-gradient(45deg, #fff0f0, #fff0f0 10px, #fff5f5 10px, #fff5f5 20px) !important; }
        
        /* 5. DARK MODE SUPPORT */
        body.dark-mode .scheduler-layout-wrapper { background: #121212; border-color: #333; }
        body.dark-mode .scheduler-sidebar-decoupled { background: #1f1f1f; border-color: #333; }
        body.dark-mode .scheduler-grid-scrollbox { background: #121212; }
        
        /* Dark Mode Zebra */
        body.dark-mode .lane-odd { background-color: #1e1e1e !important; }
        body.dark-mode .lane-even { background-color: #181818 !important; }
        body.dark-mode .decoupled-row { border-color: #333 !important; }

        /* Dark Mode Headers - Kills the white "outline" */
        body.dark-mode .header-top-row { background: #1e1e1e; color: #cbd5e1; }
        body.dark-mode .header-bottom-row { background: #111827; color: #ffffff; }

        /* Dark Mode Unassigned */
        body.dark-mode .unassigned-row-sidebar { background-color: #2a1515 !important; color: #ffb3b3 !important; }
        body.dark-mode .unassigned-row-grid { background: repeating-linear-gradient(45deg, #2a1515, #2a1515 10px, #331a1a 10px, #331a1a 20px) !important; }

		/* FIXED: Removes the tiny extra line at the very end (24:00 mark) of the headers */
        .header-top-row div:last-child,
        .header-bottom-row div:last-child {
            border-right: none !important;
        }
        /* 6. MOBILE COMPACT OVERRIDES */
        @media screen and (max-width: 1024px) {
            h3.text-dark { font-size: 1.1rem !important; margin-bottom: 5px !important; }
            .btn-sm { font-size: 0.7rem !important; padding: 4px 6px !important; margin: 1px !important; }
            .filter-group-select, .form-control-sm, .select2-container--default .select2-selection--single { height: 28px !important; font-size: 0.75rem !important; }
            .filter-group-select { min-width: 90px !important; max-width: 120px !important; }
            #mainFilterForm .shadow-sm[style*="min-width: 250px"] { min-width: 140px !important; flex-grow: 1; }
            .scheduler-sidebar-decoupled { width: 140px; }
            .eng-text { font-size: 0.75rem; }
        }
		
		/* ==========================================================================
   WORKER PAGE MOBILE TABS (SWIPEABLE)
   ========================================================================== */
@media screen and (max-width: 768px) {
    /* Make the tabs a swipeable horizontal row */
    .worker-tabs {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch; /* Smooth momentum scrolling on iOS */
        scrollbar-width: none; /* Hide scrollbar Firefox */
        -ms-overflow-style: none; /* Hide scrollbar IE/Edge */
        padding-bottom: 2px !important; 
    }
    
    /* Hide scrollbar for Chrome, Safari and Opera */
    .worker-tabs::-webkit-scrollbar {
        display: none !important;
    }
    
    /* Prevent the text inside the tabs from wrapping */
    .worker-tabs .nav-item {
        white-space: nowrap !important;
    }
    
    /* Stop the top buttons (Refresh, Offline) from squishing the page title */
    .worker-page .container > .d-flex.justify-content-between.align-items-center.mb-3 {
        flex-wrap: wrap !important;
        gap: 12px;
    }
}

/* ==========================================================================
   LIGHT MODE PRINT FIX: YEAR PLANNER (PAPER READY)
   ========================================================================== */
@media print {
    /* 1. Force the Table and Grid to White */
    .year-planner-table,
    .year-planner-table td,
    .year-planner-table th,
    .year-planner-task-header {
        background-color: #ffffff !important;
        color: #000000 !important;
        border: 1px solid #cccccc !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* 2. Remove the Stray Box/Border around the Legend/Status Key */
    .planner-page .bg-white.border.rounded.shadow-sm,
    .planner-legend {
        border: none !important;
        box-shadow: none !important;
        background-color: transparent !important;
        padding: 0 !important;
        margin-bottom: 10px !important;
    }

    /* 3. Header Row - Light Grey Tint for Readability */
    .year-planner-table thead th,
    .year-planner-table .year-planner-task-header {
        background-color: #f0f0f0 !important;
        color: #000000 !important;
    }

    /* 4. Subtle Zebra Striping for the Grid */
    .year-planner-table tbody tr:nth-child(odd) td {
        background-color: #f9f9f9 !important;
    }

    /* 5. Ensure Status Icons and Frequency Badges Keep Their Colors */
    .planner-status-marker, 
    .badge,
    .planner-legend-marker {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        border: 1px solid rgba(0,0,0,0.1) !important;
    }

    /* 6. Hide navigation and non-essential UI */
    .no-print, 
    .navbar, 
    #filter-form {
        display: none !important;
    }
}

/* ==========================================================================
   PORTAL TOOLTIP - INFO BOXES (LIGHT MODE)
   ========================================================================== */

/* 1. Client Instructions (Light Blue Box) */
.scheduler-portal-tooltip .client-instruction-box {
    background-color: #e7f3ff !important;
    border-color: #b8daff !important;
    color: #212529 !important; /* Standard dark text */
    padding: 4px !important;   /* Replicates p-1 */
}

/* 2. Site Access / Notes (Light Pink Box) */
.scheduler-portal-tooltip .site-access-box {
    background-color: #f8d7da !important;
    border-color: #f5c6cb !important;
    color: #212529 !important; /* Standard dark text */
    padding: 4px !important;   /* Replicates p-1 */
}

/* Ensure labels inside are slightly more prominent for readability */
.scheduler-portal-tooltip .client-instruction-box strong,
.scheduler-portal-tooltip .site-access-box strong {
    color: #000000 !important;
}

/* Ensure the icons retain their standard Bootstrap colors */
.scheduler-portal-tooltip .client-instruction-box i { color: #17a2b8 !important; } /* info blue */
.scheduler-portal-tooltip .site-access-box i { color: #dc3545 !important; }      /* danger red */

.dropzone {
    background: #fff; /* Default for light mode */
}

body.dark-mode .dropzone {
    background-color: #1a1a1a !important;
    background: #1a1a1a !important;
}

/* --- Targeted Page Tab Styling (Excludes Top Navbar) --- */

/* 1. Set the blue top line ONLY for tabs inside a .nav-tabs container */
.nav-tabs .nav-link.active {
    color: #212529 !important; /* Bold dark text */
    background-color: #fff !important;
    
    /* Keep the side borders but add the thick blue top line */
    border-color: #dee2e6 #dee2e6 #fff !important; 
    border-top: 3px solid #007bff !important; 
    
    font-weight: 700 !important;
    margin-bottom: -1px; /* Prevents the double-line look at the bottom */
}

/* 2. Style the hover state for these specific tabs */
.nav-tabs .nav-link:hover:not(.active) {
    border-color: #e9ecef #e9ecef #dee2e6;
    background-color: #f8f9fa;
    color: #007bff;
}

/* 3. Safety Reset for Top Navbar */
/* This ensures standard navbar links never get these borders */
.navbar-nav .nav-link {
    border: none !important;
    border-top: none !important;
    border-bottom: none !important;
}

/* --- 1. DEFAULT: THE FOLDER LOOK (Blue Line on Top) --- */
/* This covers Site Documents, Clients, and General Admin */
.nav-tabs .nav-link.active {
    border-top: 3px solid #007bff !important; 
    border-bottom: 1px solid #fff !important;
    border-left: 1px solid #dee2e6 !important;
    border-right: 1px solid #dee2e6 !important;
    background-color: #fff !important;
    color: #212529 !important;
    font-weight: 700 !important;
    margin-bottom: -1px;
}

/* --- 2. THE FLIP: WORKER TASKS (Blue Line on Bottom) --- */
/* We target the tabs ONLY when followed by the Job Search bar container */
.nav-tabs:has(+ .card-body .input-group) .nav-link.active,
.nav-tabs:has(+ .input-group) .nav-link.active,
.nav-tabs:has(+ .job-search-container) .nav-link.active {
    border-top: 1px solid #dee2e6 !important; /* Move line from top... */
    border-bottom: 3px solid #007bff !important; /* ...to the bottom */
}

/* --- 3. NAVBAR PROTECTION --- */
/* Ensures the top menu stays clean */
.navbar-nav .nav-link, 
.navbar-nav .nav-link.active {
    border: none !important;
    border-top: none !important;
    border-bottom: none !important;
    padding-top: 0.5rem !important;
}

/* --- 4. BASE LINE --- */
.nav-tabs {
    border-bottom: 1px solid #dee2e6 !important;
}

/* --- Unifying Live Map, New Job, and Admin Menu ONLY --- */

/* 1. Target exactly these three specific elements */
.navbar .btn-primary, 
.navbar .btn-danger,
.navbar .user-profile-wrapper,
.navbar #userDropdown {
    height: 40px !important;
    border-radius: 50px !important; /* The Live Map pill curve */
    padding: 0 20px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-weight: 700 !important;
    font-size: 14px !important;
    border: none !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
    margin-left: 10px !important;
    transition: all 0.2s ease !important;
}

/* 2. Specific fix for the User/Admin Menu box in Light Mode */
.navbar .user-profile-wrapper,
.navbar #userDropdown {
    background-color: #ffffff !important;
    border: 1px solid #dee2e6 !important;
    color: #333 !important;
}

/* 3. Icon and Text Spacing */
.navbar .btn-primary i, 
.navbar .btn-danger i,
.navbar .user-profile-wrapper i {
    margin-right: 8px !important;
}

/* 4. Hover Effects */
.navbar .btn-primary:hover, 
.navbar .btn-danger:hover,
.navbar .user-profile-wrapper:hover {
    filter: brightness(0.95);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1) !important;
}

/* 5. Dark Mode Adjustments for the Admin Pill */
body.dark-mode .navbar .user-profile-wrapper,
body.dark-mode .navbar #userDropdown {
    background-color: #2b2b2b !important;
    border-color: #444 !important;
    color: #ffffff !important;
}

/* Prevent phones from trying to highlight text or open menus on long-press */
.scheduler-job-block {
    -webkit-touch-callout: none; /* Stops the iOS popup menu */
    -webkit-user-select: none;   /* Stops Safari text highlighting */
    -moz-user-select: none;      /* Stops Firefox text highlighting */
    -ms-user-select: none;       /* Stops Edge text highlighting */
    user-select: none;           /* Standard syntax */
}