/* 
 * UK Care Home Automated Rota Calculator - Modern & Clean Stylesheet
 * Supports 2 or 3 shifts with independent working hours
 */

:root {
    --primary: #1e3a8a;          /* Deep UK NHS/Healthcare Navy */
    --primary-light: #3b82f6;
    --primary-dark: #172554;
    --bg-main: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    
    /* Role Badges */
    --senior-bg: #fef3c7;
    --senior-text: #92400e;
    --senior-border: #f59e0b;
    
    --carer-bg: #e0f2fe;
    --carer-text: #0369a1;
    --carer-border: #38bdf8;
    
    /* Shift Themes */
    --early-color: #d97706;
    --late-color: #0284c7;
    --night-color: #4f46e5;
    --day-color: #d97706;
    
    /* Status indicators */
    --success: #10b981;
    --success-bg: #ecfdf5;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    
    --radius: 8px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Header & Top Bar */
.app-header {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    color: #ffffff;
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow-md);
}

.header-inner {
    max-width: 1440px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-icon {
    font-size: 2rem;
    background: rgba(255, 255, 255, 0.15);
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius);
}

.brand h1 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0;
}

.brand p {
    font-size: 0.85rem;
    opacity: 0.85;
    margin: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Primary Container */
.container {
    max-width: 1440px;
    margin: 1.5rem auto;
    padding: 0 1.5rem;
}

/* Navigation & Controls Bar */
.controls-bar {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.week-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.current-week-display {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-dark);
    padding: 0 0.5rem;
    min-width: 250px;
    text-align: center;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    text-decoration: none;
    line-height: 1.25;
}

.btn:hover {
    transform: translateY(-1px);
}

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

.btn-primary {
    background: var(--primary);
    color: #ffffff;
}
.btn-primary:hover {
    background: var(--primary-light);
}

.btn-magic {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.3);
}
.btn-magic:hover {
    box-shadow: 0 4px 8px rgba(99, 102, 241, 0.45);
}

.btn-secondary {
    background: #ffffff;
    border-color: var(--border-color);
    color: var(--text-main);
}
.btn-secondary:hover {
    background: #f1f5f9;
}

.btn-success {
    background: var(--success);
    color: #ffffff;
}
.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: #fee2e2;
    color: #b91c1c;
    border-color: #fca5a5;
}
.btn-danger:hover {
    background: #fecaca;
}

.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

/* Stats and Compliance Banner */
.stats-banner {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    font-size: 1.75rem;
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon.blue { background: #eff6ff; color: #2563eb; }
.stat-icon.green { background: #ecfdf5; color: #10b981; }
.stat-icon.amber { background: #fffbeb; color: #f59e0b; }
.stat-icon.purple { background: #f5f3ff; color: #7c3aed; }

.stat-info h3 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.stat-info .stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-main);
    margin-top: 0.1rem;
}

/* Compliance Alerts Box */
.compliance-box {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.compliance-box.compliant {
    border-left: 5px solid var(--success);
    background: linear-gradient(to right, #f0fdf4, #ffffff 40%);
}

.compliance-box.warnings {
    border-left: 5px solid var(--warning);
    background: linear-gradient(to right, #fffbeb, #ffffff 40%);
}

.compliance-box.non-compliant {
    border-left: 5px solid var(--danger);
    background: linear-gradient(to right, #fef2f2, #ffffff 40%);
}

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

.compliance-header h2 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.alert-item {
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.alert-item.critical {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-item.warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

/* Rota Grid Table */
.rota-table-container {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
    margin-bottom: 2rem;
}

.rota-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1100px;
}

.rota-table th, .rota-table td {
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    vertical-align: top;
}

.rota-table thead th {
    background: #f1f5f9;
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
}

.rota-table thead th:first-child {
    position: sticky;
    left: 0;
    z-index: 12;
    background: #f1f5f9;
    min-width: 140px;
    width: 140px;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.06);
}

.rota-table thead th.day-col {
    min-width: 135px;
    width: 135px;
}

.rota-table thead th.weekend {
    background: #e2e8f0;
}

.date-header-day {
    font-size: 0.95rem;
    font-weight: 700;
}

.date-header-num {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Row Headers */
.shift-row-header {
    min-width: 140px;
    width: 140px;
    background: #f8fafc;
    font-weight: 600;
    font-size: 0.85rem;
    text-align: center;
    vertical-align: middle !important;
    position: sticky;
    left: 0;
    z-index: 10;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.06);
}

.shift-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.shift-title.early { color: var(--early-color); }
.shift-title.late { color: var(--late-color); }
.shift-title.night { color: var(--night-color); }
.shift-title.day { color: var(--day-color); }

.shift-time {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
}

.shift-hours-pill {
    font-size: 0.7rem;
    font-weight: 700;
    background: #e2e8f0;
    color: var(--primary-dark);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}

.shift-req-badge {
    margin-top: 0.25rem;
    font-size: 0.7rem;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    background: #f1f5f9;
    color: var(--text-muted);
}

/* Shift Cells */
.shift-cell {
    background: #ffffff;
    min-height: 100px;
    position: relative;
    transition: background-color 0.15s;
}

.shift-cell.early-slot { background: #fffdfa; }
.shift-cell.late-slot { background: #f8fcff; }
.shift-cell.night-slot { background: #fbfbfe; }
.shift-cell.day-slot { background: #fffdfa; }

.shift-cell:hover {
    background: #f8fafc;
}

.cell-status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.45rem;
    font-size: 0.7rem;
}

.slot-count-badge {
    font-weight: 600;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
}

.slot-count-badge.met {
    background: var(--success-bg);
    color: var(--success);
}

.slot-count-badge.short {
    background: var(--warning-bg);
    color: var(--warning);
}

.slot-count-badge.critical {
    background: var(--danger-bg);
    color: var(--danger);
}

.btn-add-carer {
    background: none;
    border: 1px dashed #cbd5e1;
    color: var(--text-muted);
    border-radius: 4px;
    padding: 0.1rem 0.4rem;
    font-size: 0.75rem;
    cursor: pointer;
}

.btn-add-carer:hover {
    background: #e2e8f0;
    color: var(--text-main);
}

/* Staff Badges inside cells */
.staff-badge-list {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.staff-badge {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0.45rem;
    border-radius: 5px;
    font-size: 0.76rem;
    font-weight: 500;
    transition: transform 0.1s ease;
}

.staff-badge:hover {
    transform: translateX(2px);
}

.staff-badge.senior {
    background: var(--senior-bg);
    color: var(--senior-text);
    border: 1px solid var(--senior-border);
}

.staff-badge.carer {
    background: var(--carer-bg);
    color: var(--carer-text);
    border: 1px solid var(--carer-border);
}

.staff-badge-name {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.staff-role-pill {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.05rem 0.25rem;
    border-radius: 3px;
}

.staff-badge.senior .staff-role-pill {
    background: #f59e0b;
    color: #ffffff;
}

.staff-badge.carer .staff-role-pill {
    background: #0284c7;
    color: #ffffff;
}

.btn-remove-shift {
    background: none;
    border: none;
    color: inherit;
    opacity: 0.6;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0 0.2rem;
    line-height: 1;
}

.btn-remove-shift:hover {
    opacity: 1;
    font-weight: bold;
}

/* Staff Management & Hours Section */
.bottom-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (max-width: 900px) {
    .bottom-section {
        grid-template-columns: 1fr;
    }
}

.panel-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}

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

.panel-header h2 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--primary-dark);
}

/* Staff Hours Table */
.staff-hours-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.staff-hours-table th, .staff-hours-table td {
    padding: 0.5rem 0.6rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.staff-hours-table th {
    font-weight: 600;
    color: var(--text-muted);
}

.hours-bar-container {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 0.25rem;
}

.hours-bar {
    height: 100%;
    background: var(--primary-light);
    border-radius: 4px;
}

.hours-bar.on-target { background: var(--success); }
.hours-bar.overtime { background: var(--warning); }
.hours-bar.wtr-warning { background: var(--danger); }

/* Shift Config Cards in Settings Modal */
.shift-config-card {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

.shift-config-card.early { border-left: 4px solid var(--early-color); }
.shift-config-card.late { border-left: 4px solid var(--late-color); }
.shift-config-card.night { border-left: 4px solid var(--night-color); }
.shift-config-card.day { border-left: 4px solid var(--day-color); }

.shift-config-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.shift-config-card-header h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary-dark);
}

/* Modals */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: #ffffff;
    border-radius: var(--radius);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalSlide 0.2s ease-out;
}

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

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

.modal-header h3 {
    font-size: 1.15rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body {
    padding: 1.25rem;
}

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

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: #ffffff;
    color: var(--text-main);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-help {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

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

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
}

.modal-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    background: #f8fafc;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: #1e293b;
    color: #ffffff;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: toastIn 0.2s ease-out;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* -------------------------------------------------------------
   PRINT STYLESHEET (Noticeboard / A4 Landscape)
   ------------------------------------------------------------- */
@media print {
    @page {
        size: A4 landscape;
        margin: 6mm 6mm 6mm 6mm;
    }

    body {
        background: #ffffff !important;
        color: #000000 !important;
        font-size: 8.5pt;
    }

    .app-header,
    .controls-bar,
    .stats-banner,
    .compliance-box,
    .bottom-section,
    .btn,
    .btn-add-carer,
    .btn-remove-shift,
    .modal-overlay,
    .toast-container {
        display: none !important;
    }

    .print-header {
        display: block !important;
        margin-bottom: 8px;
        border-bottom: 2px solid #000000;
        padding-bottom: 4px;
    }

    .print-header-top {
        display: flex;
        justify-content: space-between;
        align-items: flex-end;
    }

    .print-header h1 {
        font-size: 14pt;
        font-weight: bold;
        margin: 0;
    }

    .print-header p {
        font-size: 9pt;
        margin: 0;
    }

    .container {
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .rota-table-container {
        border: none !important;
        box-shadow: none !important;
        overflow: visible !important;
    }

    .rota-table {
        width: 100% !important;
        min-width: 100% !important;
        border: 2px solid #000000 !important;
    }

    .rota-table th, .rota-table td {
        border: 1px solid #333333 !important;
        padding: 3px 5px !important;
    }

    .shift-row-header {
        background: #f0f0f0 !important;
        color: #000000 !important;
        font-weight: bold !important;
    }

    .shift-cell {
        min-height: auto !important;
        height: auto !important;
    }

    .staff-badge {
        border: 1px solid #666666 !important;
        background: #ffffff !important;
        color: #000000 !important;
        padding: 1px 3px !important;
        margin-bottom: 2px !important;
        font-size: 8pt !important;
    }

    .staff-badge.senior {
        background: #f5f5f5 !important;
        font-weight: bold !important;
    }

    .staff-role-pill {
        border: 1px solid #000 !important;
        background: transparent !important;
        color: #000 !important;
        font-size: 6.5pt !important;
    }

    .print-footer {
        display: block !important;
        margin-top: 10px;
        display: flex;
        justify-content: space-between;
        font-size: 8pt;
    }
}

.print-header, .print-footer {
    display: none;
}

/* Period Filter Tabs & Date Bar */
.period-filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.85rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.view-tabs {
    display: flex;
    gap: 0.35rem;
    overflow-x: auto;
    padding-bottom: 2px;
}

.view-tab {
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: #ffffff;
    color: var(--text-main);
    transition: all 0.15s ease;
    white-space: nowrap;
}

.view-tab:hover {
    background: #f1f5f9;
}

.view-tab.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

/* Pre-Generation Employee Review Table */
.pregen-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.pregen-table th, .pregen-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.pregen-table th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--text-muted);
    position: sticky;
    top: 0;
    z-index: 5;
}

.leave-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
    margin: 0.1rem 0;
}

.leave-badge .del-leave-btn {
    cursor: pointer;
    font-weight: bold;
    color: #b91c1c;
    margin-left: 0.25rem;
}

