/* CORE LAYOUT */
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }

.page-layout-with-sidebar { 
    display: flex; 
    width: 100%; 
    height: 100vh; 
    overflow: hidden; 
    background-color: #f8fafc; 
}

.grid-workspace { 
    flex-grow: 1; 
    padding: 48px 60px 80px 60px; 
    overflow-y: auto; 
}

/* WORKSPACE HEADER & CONTROLS */
.workspace-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: flex-end; 
    flex-wrap: wrap; 
    gap: 24px; 
}
.workspace-header h1 { 
    font-size: 32px; 
    font-weight: 800; 
    color: #0f172a; 
    margin-bottom: 8px; 
    letter-spacing: -0.02em; 
}
.workspace-header p { color: #64748b; font-size: 15px; margin: 0; }
.workspace-controls { display: flex; align-items: center; gap: 12px; }

/* ACTIVE FILTER GLOW */
@keyframes pulse-glow-blue {
    0% { box-shadow: 0 0 0 0 rgba(14, 165, 233, 0.4); border-color: #0ea5e9; background-color: #f0f9ff; color: #0284c7; }
    70% { box-shadow: 0 0 0 8px rgba(14, 165, 233, 0); border-color: #7dd3fc; background-color: #fff; color: #0ea5e9; }
    100% { box-shadow: 0 0 0 0 rgba(14, 165, 233, 0); border-color: #0ea5e9; background-color: #f0f9ff; color: #0284c7; }
}
.active-filter {
    animation: pulse-glow-blue 2s infinite !important;
}
.active-filter svg { stroke: #0ea5e9; }

/* TARGET FILTER OVERHAUL */
.selected-targets-area {
    display: flex; flex-wrap: wrap; gap: 6px; padding: 12px; background: white; border: 1px dashed #cbd5e1; border-radius: 8px; margin-bottom: 16px; max-height: 120px; overflow-y: auto;
}
.target-chip {
    background: #f0f9ff; color: #0284c7; padding: 4px 10px; border-radius: 16px; font-size: 11px; font-weight: 800; display: inline-flex; align-items: center; gap: 6px; border: 1px solid #bae6fd;
}
.target-chip-remove {
    cursor: pointer; opacity: 0.6; transition: opacity 0.2s; display: flex; align-items: center;
}
.target-chip-remove:hover { opacity: 1; color: #e11d48; }
.disabled-setting { opacity: 0.5; pointer-events: none; filter: grayscale(100%); }
.disabled-setting-msg { font-size: 12px; font-weight: 700; color: #e11d48; margin-top: 8px; display: none; }
.disabled-setting .disabled-setting-msg { display: block; }

/* SMOOTH COLLAPSE UTILITIES */
.collapsible-wrapper {
    display: grid;
    grid-template-rows: 1fr;
    transition: grid-template-rows 0.4s cubic-bezier(0.4, 0, 0.2, 1), margin-bottom 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 24px;
    opacity: 1;
}
.collapsible-wrapper.collapsed {
    grid-template-rows: 0fr;
    margin-bottom: 0;
    opacity: 0;
    pointer-events: none;
}
.collapsible-inner {
    min-height: 0; 
    overflow: hidden;
}

/* WARNING BANNER */
.filter-warning-banner {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 14px 20px;
    border-radius: 12px;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.1);
    animation: fadeIn 0.3s ease-out;
}
.second-best-banner {
    background-color: #fffbeb;
    border-color: #fcd34d;
    color: #d97706;
    box-shadow: 0 4px 6px -1px rgba(245, 158, 11, 0.1);
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* BUTTONS & FORMS */
.save-btn { 
    background: #007a5a; color: white; border: none; padding: 12px 24px; border-radius: 8px; font-weight: 700; font-size: 14px; cursor: pointer; transition: all 0.2s; display: inline-flex; align-items: center;
}
.save-btn:hover { background: #00684a; transform: translateY(-1px); }
.btn-outline { 
    background: white; border: 1px solid #cbd5e1; color: #334155; padding: 12px 20px; border-radius: 8px; font-weight: 700; font-size: 14px; cursor: pointer; transition: all 0.2s; display: inline-flex; align-items: center; 
}
.btn-outline:hover { background: #f8fafc; border-color: #94a3b8; }

/* CUSTOM MULTI-SELECT DROPDOWN */
.multi-select-container { position: relative; }
.multi-select-button {
    width: 100%; 
    padding: 6px 10px; 
    border-radius: 8px; 
    border: 1px solid #cbd5e1; 
    background: white; 
    text-align: left; 
    cursor: pointer; 
    font-size: 13px; 
    font-weight: 600; 
    color: #475569; 
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    min-height: 43px; 
    transition: border-color 0.2s;
}
.multi-select-button:hover { border-color: #94a3b8; }

.multi-select-label-container {
    display: flex; 
    gap: 4px; 
    flex-wrap: nowrap; 
    align-items: center; 
    max-height: 50px; 
    overflow: hidden; 
    padding-right: 6px;
}
.multi-select-tag {
    background: #f1f5f9; 
    border: 1px solid #cbd5e1; 
    padding: 3px 8px; 
    border-radius: 6px; 
    font-size: 11px; 
    font-weight: 800; 
    color: #334155; 
    white-space: nowrap; 
    display: inline-flex; 
    align-items: center;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
}

.multi-select-dropdown {
    position: absolute; 
    top: 100%; 
    left: 0; 
    width: 100%; 
    background: white; 
    border: 1px solid #cbd5e1; 
    border-radius: 8px; 
    margin-top: 4px; 
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1); 
    z-index: 2500; 
    display: none; 
    max-height: 200px; 
    overflow-y: auto; 
    flex-direction: column; 
    padding: 4px;
}
.multi-select-dropdown.show { display: flex; }
.multi-select-option {
    padding: 8px 10px; 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    cursor: pointer; 
    border-radius: 6px; 
    font-size: 13px; 
    font-weight: 600; 
    color: #334155; 
    transition: background 0.2s;
}
.multi-select-option:hover { background: #f1f5f9; }
.multi-select-option input { cursor: pointer; accent-color: #007a5a; width: 16px; height: 16px; margin: 0; }

/* THE GRID SYSTEM */
.grid-card { 
    background: white; 
    border: 1px solid #e2e8f0; 
    border-radius: 16px; 
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.05); 
    overflow: hidden; 
    user-select: none; 
}
.grid-scroll { width: 100%; overflow-x: auto; }
.avail-grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.avail-grid th { 
    position: sticky; 
    top: 0; 
    background: #f8fafc; 
    z-index: 10; 
    padding: 16px; 
    font-size: 12px; 
    font-weight: 800; 
    color: #64748b; 
    text-transform: uppercase; 
    border-bottom: 1px solid #e2e8f0; 
}
.avail-grid td { border: 1px solid #f1f5f9; height: 95px; padding: 0; position: relative; vertical-align: top; }
.time-col { 
    width: 95px; 
    font-size: 12px; 
    font-weight: 700; 
    color: #94a3b8; 
    text-align: center; 
    background: #f8fafc; 
    border-right: 1px solid #e2e8f0; 
    vertical-align: middle; 
}

/* CELLS & HEATMAP LOGIC */
.cell { 
    width: 100%; 
    height: 100%; 
    display: flex; 
    flex-direction: column; 
    gap: 4px; 
    padding: 4px;
    background-color: transparent; 
    overflow-y: auto; 
    border-radius: 6px; 
    position: relative;
    transition: background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s;
    contain: content; 
    scrollbar-width: none;
}
.cell::-webkit-scrollbar { display: none; }

/* Default Colors (Green) */
.heatmap-active .cell.level-0 { background-color: #f8fafc; } 
.heatmap-active .cell.level-1 { background-color: rgba(0, 122, 90, 0.15); } 
.heatmap-active .cell.level-2 { background-color: rgba(0, 122, 90, 0.35); } 
.heatmap-active .cell.level-3 { background-color: rgba(0, 122, 90, 0.6); } 
.heatmap-active .cell.level-4 { background-color: rgba(0, 122, 90, 0.9); }
.heatmap-active .cell.optimal-match { box-shadow: inset 0 0 0 3px #10b981; }

/* SECOND BEST OVERRIDES (Orange) */
.grid-second-best .cell.optimal-match { box-shadow: inset 0 0 0 3px #f59e0b; }
.grid-second-best .cell.optimal-match .avail-count-badge { color: white; }
.grid-second-best .cell.optimal-match .optimal-center-mark { color: white; }

/* ISOLATED PRIORITIZED USER OVERRIDES (Graded Blue) */
.user-isolated.heatmap-active .cell.level-1 { background-color: rgba(2, 132, 199, 0.15) !important; }
.user-isolated.heatmap-active .cell.level-2 { background-color: rgba(2, 132, 199, 0.35) !important; }
.user-isolated.heatmap-active .cell.level-3 { background-color: rgba(2, 132, 199, 0.6) !important; }
.user-isolated.heatmap-active .cell.level-4 { background-color: rgba(2, 132, 199, 0.9) !important; }

/* SATELLITE ISOLATED OVERRIDES (Graded Yellow) */
.satellite-isolated.heatmap-active .cell.level-1 { background-color: rgba(234, 179, 8, 0.15) !important; }
.satellite-isolated.heatmap-active .cell.level-2 { background-color: rgba(234, 179, 8, 0.35) !important; }
.satellite-isolated.heatmap-active .cell.level-3 { background-color: rgba(234, 179, 8, 0.6) !important; }
.satellite-isolated.heatmap-active .cell.level-4 { background-color: rgba(234, 179, 8, 0.9) !important; }
.satellite-isolated.heatmap-active .cell.optimal-match { box-shadow: inset 0 0 0 3px #eab308 !important; }
.satellite-isolated.heatmap-active .cell.optimal-match .avail-count-badge { color: #854d0e !important; }
.satellite-isolated.heatmap-active .cell.optimal-match .optimal-center-mark { color: #854d0e !important; }
.satellite-isolated.heatmap-active .cell.level-3 .optimal-center-mark,
.satellite-isolated.heatmap-active .cell.level-4 .optimal-center-mark { color: #fff !important; }

/* PRIORITIZED CONTEXT MATCHES (Yellow for Partial, Blue for Full) */
.user-isolated.heatmap-active .cell.partial-match { box-shadow: inset 0 0 0 3px #eab308 !important; }
.user-isolated.heatmap-active .cell.partial-match.level-1 { background-color: rgba(234, 179, 8, 0.15) !important; }
.user-isolated.heatmap-active .cell.partial-match.level-2 { background-color: rgba(234, 179, 8, 0.35) !important; }
.user-isolated.heatmap-active .cell.partial-match.level-3 { background-color: rgba(234, 179, 8, 0.6) !important; }
.user-isolated.heatmap-active .cell.partial-match.level-4 { background-color: rgba(234, 179, 8, 0.9) !important; }

.user-isolated.heatmap-active .cell.full-match { box-shadow: inset 0 0 0 3px #0ea5e9 !important; }

/* THE CENTER CHECKMARK */
.optimal-center-mark {
    display: none; 
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 4;
}
.heatmap-active .cell.optimal-match .optimal-center-mark {
    display: flex; flex-direction: column; align-items: center;
}
.heatmap-active .cell.optimal-match .optimal-center-mark span {
    font-size: 14px; font-weight: 800; margin-top: 2px; letter-spacing: 0.5px; text-transform: uppercase;
}

.heatmap-active .cell.level-0 .optimal-center-mark,
.heatmap-active .cell.level-1 .optimal-center-mark,
.heatmap-active .cell.level-2 .optimal-center-mark { color: rgba(15, 23, 42, 0.7); }
.heatmap-active .cell.level-3 .optimal-center-mark,
.heatmap-active .cell.level-4 .optimal-center-mark { color: white; }

/* THE COUNT BADGES (n/x Fractions) */
.avail-count-badge {
    position: absolute;
    top: 6px; right: 6px;
    font-size: 11px; font-weight: 800; color: #94a3b8;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none; z-index: 2;
}

/* Default Heatmap: Centers the fraction nice and big */
.heatmap-active .avail-count-badge {
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px; font-weight: 800;
    z-index: 4;
}

/* Corner Override: Pushes it back to the corner ONLY if a checkmark is using the center */
.heatmap-active .cell.optimal-match .avail-count-badge {
    top: 6px; 
    left: auto; 
    right: 6px;
    transform: none;
    font-size: 11px; 
    font-weight: 800;
}

/* Dynamic text colors for standard gradients */
.heatmap-active .cell.level-0 .avail-count-badge,
.heatmap-active .cell.level-1 .avail-count-badge,
.heatmap-active .cell.level-2 .avail-count-badge { color: rgba(15, 23, 42, 0.7); }
.heatmap-active .cell.level-3 .avail-count-badge,
.heatmap-active .cell.level-4 .avail-count-badge { color: white; }

/* SCHEDULED EVENTS */
.scheduled-event {
    position: relative; 
    border-radius: 6px; 
    padding: 6px 8px;
    display: flex; 
    flex-direction: column; 
    justify-content: flex-start;
    color: white; 
    overflow: hidden; 
    text-align: left;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15); 
    flex-shrink: 0;
    cursor: pointer; 
    transition: all 0.2s ease;
    z-index: 3;
}
.scheduled-event:hover { transform: scale(0.98); filter: brightness(1.05); }
.heatmap-active .scheduled-event { opacity: 0.15; pointer-events: none; filter: grayscale(100%); }

.event-content-wrapper { display: flex; flex-direction: column; padding-right: 16px; pointer-events: none; }
.event-time { font-size: 9px; font-weight: 800; opacity: 0.9; margin-bottom: 4px; display: flex; align-items: center; letter-spacing: 0.5px; }
.event-title { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event-target { font-size: 9px; font-weight: 600; opacity: 0.8; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* INTERACTION LAYERS */
.cell-bg {
    flex-grow: 1; 
    min-height: 20px; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    border-radius: 4px; 
    cursor: pointer; 
    transition: background 0.1s; 
    z-index: 1;
}
.cell-bg:hover { background: rgba(0, 0, 0, 0.04); }
.add-hint { font-size: 20px; color: #cbd5e1; font-weight: 300; opacity: 0; transition: opacity 0.2s; pointer-events: none; }
.cell-bg:hover .add-hint { opacity: 1; }

.heatmap-active .cell-bg { display: none; }
.heatmap-click-shield { position: absolute; inset: 0; z-index: 10; cursor: pointer; display: none; }
.heatmap-active .heatmap-click-shield { display: block; }

/* MODALS & GLASSMORPHISM */
.modal-overlay { 
    position: fixed; 
    inset: 0; 
    background: rgba(15, 23, 42, 0.6); 
    display: none; 
    align-items: center; 
    justify-content: center; 
    z-index: 3000; 
    backdrop-filter: blur(4px); 
    padding: 20px;
}
.modal-card { 
    background: white; 
    width: 100%; 
    border-radius: 16px; 
    padding: 32px; 
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); 
    max-height: 90vh;
    overflow-y: auto;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.close-modal { background: none; border: none; color: #64748b; cursor: pointer; padding: 0; transition: color 0.2s; }
.close-modal:hover { color: #0f172a; }

.form-group label { display: block; font-weight: 700; font-size: 13px; color: #334155; margin-bottom: 8px; }
.form-group input[type="text"], 
.form-group input[type="time"],
.form-group input[type="number"],
.form-group input[type="url"],
.form-group textarea { 
    width: 100%; 
    padding: 12px; 
    border-radius: 8px; 
    border: 1px solid #cbd5e1; 
    outline: none; 
    font-family: inherit; 
    font-size: 14px; 
    transition: border-color 0.2s;
}
.form-group input:focus, .form-group textarea:focus { border-color: #007a5a; }

/* USER LIST UI */
.user-list-container { 
    max-height: 300px; 
    overflow-y: auto; 
    border: 1px solid #e2e8f0; 
    border-radius: 8px; 
    padding: 8px; 
    background: #f8fafc; 
}
.user-list-item { 
    display: flex; 
    align-items: center; 
    padding: 12px; 
    border-radius: 6px; 
    cursor: pointer; 
    transition: background 0.2s; 
    background: white; 
    border: 1px solid transparent; 
    margin-bottom: 4px; 
}
.user-list-item:hover { background: #f1f5f9; border-color: #e2e8f0; }
.user-avatar { 
    width: 36px; height: 36px; border-radius: 8px; background: #e0e7ff; color: #3730a3; 
    display: flex; justify-content: center; align-items: center; font-weight: 800; font-size: 13px; margin-right: 12px; 
}
.user-info { flex-grow: 1; display: flex; flex-direction: column; }
.user-name { font-weight: 700; font-size: 14px; color: #0f172a; }
.user-email { font-size: 12px; color: #64748b; }
.user-checkbox { width: 18px; height: 18px; cursor: pointer; accent-color: #007a5a; }

/* COLOR SWATCHES */
.color-picker { display: flex; gap: 12px; }
.color-swatch-wrapper { cursor: pointer; position: relative; }
.color-swatch-wrapper input { position: absolute; opacity: 0; }
.color-swatch { display: block; width: 32px; height: 32px; border-radius: 50%; transition: transform 0.2s; border: 2px solid transparent; }
.color-swatch-wrapper input:checked ~ .color-swatch { transform: scale(1.15); box-shadow: 0 0 0 2px white, 0 0 0 4px #0f172a; }

/* REQUEST DETAILS MODAL TABS */
.req-tab-btn {
    background: transparent; border: none; padding: 8px 16px; font-size: 14px; font-weight: 700; color: #64748b; cursor: pointer; border-radius: 6px; transition: all 0.2s;
}
.req-tab-btn:hover { background: #f1f5f9; color: #334155; }
.req-tab-btn.active { background: #f0f9ff; color: #0284c7; }

/* --- DRAFT MODE & SCRATCHPAD --- */
.cell.reserved-draft {
    box-shadow: inset 0 0 0 3px #6366f1 !important;
    background-color: rgba(99, 102, 241, 0.08) !important;
}

/* User Draft Highlight Styles */
.cell.reserved-draft.draft-user-can-attend {
    box-shadow: inset 0 0 0 4px #10b981 !important;
    background-color: rgba(16, 185, 129, 0.15) !important;
}
.cell.reserved-draft.draft-user-warning {
    box-shadow: inset 0 0 0 4px #eab308 !important;
    background-color: rgba(234, 179, 8, 0.15) !important;
}
.cell.reserved-draft.draft-user-cannot-attend {
    box-shadow: inset 0 0 0 4px #ef4444 !important;
    background-color: rgba(239, 68, 68, 0.15) !important;
}

/* Context Met Icon */
.context-met-icon {
    position: absolute;
    bottom: 6px;
    left: 6px;
    color: #0ea5e9;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.context-partial-icon {
    position: absolute;
    bottom: 6px;
    left: 6px;
    color: #eab308;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

/* DRAFT BUTTONS */
.create-event-btn {
    position: absolute; top: 6px; left: 6px;
    width: 22px; height: 22px; background: #6366f1; color: white;
    border: none; border-radius: 6px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; z-index: 20; opacity: 0; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 5px rgba(99, 102, 241, 0.4);
}
.dedicate-users-btn {
    position: absolute; top: 6px; left: 32px;
    width: 22px; height: 22px; background: #0ea5e9; color: white;
    border: none; border-radius: 6px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; z-index: 20; opacity: 0; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 5px rgba(14, 165, 233, 0.4);
}
.cell.reserved-draft:hover .create-event-btn,
.cell.reserved-draft:hover .dedicate-users-btn { opacity: 1; transform: scale(1.05); }

.create-event-btn:hover { background: #4f46e5; transform: scale(1.15) !important; }
.dedicate-users-btn:hover { background: #0284c7; transform: scale(1.15) !important; }

/* UPDATED DEDICATE BADGE */
.dedicate-badge {
    position: absolute; top: 8px; left: 60px; font-size: 9px; font-weight: 800; text-transform: uppercase;
    background: #0ea5e9; color: white; padding: 2px 6px; border-radius: 4px; z-index: 5;
    pointer-events: auto; cursor: pointer; transition: background 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.dedicate-badge:hover { background: #0284c7; }

/* POPOVER AND NEW SEARCH INPUT */
.slot-summary-popover {
    display: none; 
    position: absolute; 
    z-index: 4000; 
    background: white; 
    border-radius: 8px; 
    box-shadow: 0 10px 25px rgba(0,0,0,0.15); 
    padding: 12px; 
    min-width: 200px; 
    border: 1px solid #e2e8f0;
}

.dedicate-search-input {
    width: 100%; 
    padding: 10px; 
    border-radius: 8px; 
    border: 1px solid #cbd5e1; 
    margin-bottom: 16px; 
    outline: none; 
    font-family: inherit;
}

/* ------------------------------------------- */
/* FLOATING DRAFT WIDGET (UNIFIED DASHBOARD)   */
/* ------------------------------------------- */
.floating-draft-report {
    position: fixed; bottom: 32px; right: 32px;
    z-index: 2000; 
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s;
    transform: translateY(150%); opacity: 0; pointer-events: none;
}
.floating-draft-report.active { transform: translateY(0); opacity: 1; pointer-events: auto; }

/* The container holding everything securely */
.fdr-layout-wrapper {
    display: flex; flex-direction: column;
    background: white; border-radius: 12px;
    box-shadow: 0 20px 40px -10px rgba(0,0,0,0.2), 0 0 0 1px #e2e8f0;
    overflow: hidden;
}

/* Global Header that spans across the top */
.fdr-global-header {
    height: 56px; padding: 0 20px; background: #f8fafc;
    display: flex; align-items: center; justify-content: space-between;
    cursor: pointer; border-bottom: 1px solid #e2e8f0; user-select: none; transition: background 0.2s;
}
.fdr-global-header:hover { background: #f1f5f9; }
.fdr-badge { background: #e0e7ff; color: #4f46e5; font-size: 11px; font-weight: 800; padding: 4px 8px; border-radius: 12px; }

/* Minimized translates perfectly to show ONLY the top 56px */
.floating-draft-report.minimized { transform: translateY(calc(100% - 56px)); }

/* The 3-Column Body Container */
.fdr-body-area {
    display: flex; flex-direction: row; height: 400px;
}

/* 1. Left Sidebar (Action Stack with Text) */
.fdr-sidebar {
    width: 150px; 
    flex-shrink: 0; background: #f8fafc; 
    border-right: 1px solid #e2e8f0; display: flex; flex-direction: column; 
    padding: 12px 8px; gap: 6px;
}

/* Category Headers */
.fdr-sidebar-label {
    font-size: 10px; font-weight: 800; color: #94a3b8; 
    text-transform: uppercase; margin: 4px 8px 2px 8px;
    letter-spacing: 0.5px;
}

/* Sidebar Tab Button (Parameters) */
.fdr-sidebar-btn {
    background: transparent; border: 1px solid transparent;
    color: #64748b; font-size: 12px; font-weight: 700; text-align: left;
    padding: 8px 10px; border-radius: 8px; cursor: pointer;
    transition: all 0.2s; display: flex; align-items: center; gap: 8px;
}
.fdr-sidebar-btn:hover { background: #e2e8f0; color: #0f172a; }
.fdr-sidebar-btn.active { 
    background: white; border-color: #cbd5e1; color: #0f172a; 
    box-shadow: 0 1px 3px rgba(0,0,0,0.05); 
}
.fdr-sidebar-btn.active svg { color: #6366f1; }

/* Sidebar Divider */
.fdr-sidebar-divider {
    height: 1px; background: #e2e8f0; margin: 8px 4px;
}

/* Sidebar Action Buttons (Time-Finder & Auto-Allocate) */
.fdr-tool-btn {
    background: white; border: 1px solid #e2e8f0;
    color: #334155; font-size: 12px; font-weight: 700; text-align: left;
    padding: 8px 10px; border-radius: 8px; cursor: pointer;
    transition: all 0.2s; display: flex; align-items: center; gap: 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
.fdr-tool-btn:hover { border-color: #cbd5e1; background: #f8fafc; transform: translateY(-1px); }
.fdr-tool-btn svg { color: #0ea5e9; }

/* Primary Tool Action */
.fdr-tool-btn.primary {
    background: #0ea5e9; color: white; border-color: #0284c7;
    box-shadow: 0 2px 4px rgba(14, 165, 233, 0.2);
}
.fdr-tool-btn.primary:hover {
    background: #0284c7; color: white; border-color: #0369a1;
}
.fdr-tool-btn.primary svg { color: white; }

/* 2. Middle Drawer (Slides open/closed) */
.fdr-settings-drawer {
    width: 0; overflow: hidden; background: #f8fafc;
    border-right: 1px solid transparent;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.4s;
}
.floating-draft-report.drawer-open .fdr-settings-drawer {
    width: 280px; border-right-color: #e2e8f0;
}
/* Fixed-width internal wrapper prevents text wrap height-jumps */
.drawer-inner-content {
    width: 280px; height: 100%; display: flex; flex-direction: column;
}
.drawer-body { padding: 20px; overflow-y: auto; flex-grow: 1; }

/* 3. Right Main Content (The List) */
.fdr-main-content {
    width: 340px; flex-shrink: 0; background: white; display: flex; flex-direction: column;
}
.fdr-body { padding: 20px; overflow-y: auto; flex-grow: 1; }

/* List Items inside the scratchpad */
.fdr-user-item { cursor: pointer; transition: transform 0.1s, box-shadow 0.1s, border-color 0.1s; }
.fdr-user-item:hover { transform: scale(1.02); }
.fdr-user-item.active-highlight {
    border-color: #6366f1 !important; box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.4) !important;
}

/* --- MULTI-POPOVER WINDOW SYSTEM --- */
.slot-summary-popover {
    position: absolute; 
    z-index: 4000; 
    background: white; 
    border-radius: 8px; 
    box-shadow: 0 10px 25px rgba(0,0,0,0.2); 
    min-width: 220px; 
    border: 1px solid #cbd5e1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.popover-header {
    background: #f8fafc;
    padding: 8px 12px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: grab;
    user-select: none;
}

.popover-header:active { cursor: grabbing; }

.popover-title {
    font-size: 11px; 
    font-weight: 800; 
    color: #475569; 
    text-transform: uppercase; 
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 6px;
    pointer-events: none;
}

.popover-close-btn {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.popover-close-btn:hover {
    background: #e2e8f0;
    color: #ef4444;
}

.popover-body {
    padding: 8px;
    max-height: 250px;
    overflow-y: auto;
}

.popover-user-row {
    display: flex; 
    align-items: center; 
    padding: 6px; 
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.popover-user-row:hover { background: #f1f5f9; }

/* The Global Highlight State for Selected Users */
.popover-user-row.active-cross-ref {
    background: #fffbeb;
    border-color: #fde047;
    box-shadow: 0 1px 3px rgba(202, 138, 4, 0.1);
}

/* CROSS-REFERENCE GRID HIGHLIGHTS (Red/Blue/Yellow Visual) */
.cell.cross-ref-highlight {
    box-shadow: inset 0 0 0 4px #0ea5e9 !important;
    background-color: rgba(14, 165, 233, 0.15) !important;
}

.cell.cross-ref-highlight.cross-ref-vip {
    box-shadow: inset 0 0 0 4px #eab308 !important;
    background-color: rgba(234, 179, 8, 0.15) !important;
}

/* --- FLEXIBLE MINI WINDOWS --- */
.mini-window {
    position: absolute;
    width: 280px;
    min-width: 220px;
    min-height: 200px;
    max-height: 500px;
    display: flex;
    flex-direction: column;
    resize: both;
    overflow: hidden;
    z-index: 2010;
    
    /* Apple-Style Glassmorphism */
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    
    /* Updated Purple Border & Transitions */
    border: 2px solid #8b5cf6; 
    border-radius: 12px;
    box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.15), 0 10px 15px -5px rgba(0, 0, 0, 0.05);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* New Animation State */
.mini-window.fade-out {
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
}

.mini-window-header {
    padding: 10px 14px;
    background: rgba(248, 250, 252, 0.6);
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: grab;
    user-select: none;
}

.mini-window-header:active { cursor: grabbing; }

.mini-window-title {
    font-size: 12px;
    font-weight: 800;
    color: #0f172a;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mini-window-body {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 10px;
    overflow: hidden;
}

.mini-window-search {
    width: 100%;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    outline: none;
    font-size: 13px;
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.9);
    transition: border-color 0.2s;
}

.mini-window-search:focus { border-color: #6366f1; }

.mini-window-list {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-right: 4px;
}

.close-mini-window {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    transition: all 0.2s;
}

.close-mini-window:hover {
    background: #fee2e2;
    color: #ef4444;
}

/* --- UNITY STYLE NODE CONNECTIONS --- */
#svg-connection-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none; /* Let clicks pass right through */
    z-index: 2000; /* Sits right beneath the mini-windows */
}

.connection-path {
    fill: none;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0px 2px 6px rgba(0, 0, 0, 0.2));
    stroke-dasharray: 8 6;
    animation: dashFlow 30s linear infinite;
    opacity: 0.85;
}

@keyframes dashFlow {
    to { stroke-dashoffset: -1000; }
}

/* --- USER AVAILABILITY CROSS-REFERENCE --- */
.cell.highlight-user-avail {
    box-shadow: inset 0 0 0 2px #94a3b8 !important; 
    background-color: rgba(241, 245, 249, 0.4); 
    z-index: 10;
}

.floating-user-badge {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background-color: #475569;
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
    pointer-events: none;
    z-index: 20;
    box-shadow: 0 4px 6px rgba(0,0,0,0.15);
    animation: floatIn 0.2s ease-out forwards;
}

.floating-user-badge::after {
    content: '';
    position: absolute;
    top: 100%; 
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #475569 transparent transparent transparent; 
}

/* --- VIP CONTEXT BUTTONS (Replaces old static icons) --- */
.context-met-icon, .context-partial-icon {
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.2s ease;
    z-index: 25;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.context-met-icon:hover, .context-partial-icon:hover {
    transform: scale(1.1);
}

/* Full Match: Vibrant Blue */
.context-met-icon {
    background-color: #e0e7ff; 
    color: #4f46e5; 
    border: 1px solid #c7d2fe;
}
.context-met-icon:hover { background-color: #c7d2fe; }

/* Partial Match: Soft Muted Grey (Toned down from Gold) */
.context-partial-icon {
    background-color: #f8fafc; 
    color: #94a3b8; 
    border: 1px solid #e2e8f0;
}
.context-partial-icon:hover {
    background-color: #f1f5f9;
    color: #64748b;
}

/* Mute the cell outline for partial matches so it isn't gold */
.cell.partial-match {
    box-shadow: inset 0 0 0 2px #e2e8f0 !important; /* Soft grey border */
}

/* --- APPLE STYLE TOGGLE SWITCH --- */
.fdr-toggle-switch {
    width: 36px;
    height: 20px;
    background: #cbd5e1;
    border-radius: 20px;
    position: relative;
    transition: background 0.3s;
}
.fdr-toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.fdr-toggle-switch.active { background: #10b981; }
.fdr-toggle-switch.active::after { transform: translateX(16px); }

@keyframes floatIn {
    from { opacity: 0; transform: translate(-50%, 4px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* --- Z-INDEX FIXES --- */
#floatingDraftReport, #floatingErrorDrawer {
    z-index: 2050 !important; /* Forces it above the 2000 SVG layer but below 2200 Modals */
}

/* --- MINI-WINDOW DUAL PANE UPGRADES --- */
.mini-window-body {
    flex-grow: 1;
    display: flex;
    flex-direction: row; /* Shifted from column to row for split view */
    padding: 0; /* Removed padding to let panes handle it */
    overflow: hidden;
}

.mw-pane {
    display: flex;
    flex-direction: column;
    padding: 10px;
    height: 100%;
    overflow: hidden;
    min-width: 150px;
}

.mw-resizer {
    width: 4px;
    background: #e2e8f0;
    cursor: col-resize;
    transition: background 0.2s;
    z-index: 10;
}
.mw-resizer:hover, .mw-resizer:active {
    background: #8b5cf6;
}

/* Header Controls */
.mw-control-btn {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    transition: all 0.2s;
}
.mw-control-btn:hover { background: #e2e8f0; color: #0f172a; }
.mw-control-btn.active { background: #e0e7ff; color: #4f46e5; }

/* Subgroup Grouping Headers */
.mw-group-header {
    font-size: 10px;
    font-weight: 800;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 8px 4px 4px 4px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 2px;
}

/* Event Cards */
.mw-event-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 8px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: box-shadow 0.2s;
}
.mw-event-card:hover { box-shadow: 0 2px 6px rgba(0,0,0,0.05); }
.mw-event-title { font-size: 12px; font-weight: 800; color: #0f172a; }
.mw-event-time { font-size: 11px; font-weight: 600; color: #64748b; margin-bottom: 4px;}
.mw-event-details {
    font-size: 11px;
    color: #475569;
    background: #f8fafc;
    padding: 6px;
    border-radius: 4px;
    margin-top: 6px;
    line-height: 1.4;
}
.mw-event-details a { color: #0ea5e9; text-decoration: none; font-weight: 600; }
.mw-event-details a:hover { text-decoration: underline; }


.toolbar-heatmap-group {
    position: relative;
    display: flex;
    gap: 6px;
    align-items: stretch;
}
.toolbar-divider {
    width: 1px;
    height: 32px;
    background: #e2e8f0;
    margin: 0 8px;
}
.scheduler-filter-select {
    width: 220px;
    margin-right: 4px;
}
.context-banner-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px 18px;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 18px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
    transition: all 0.25s ease;
    max-width: 100%;
    overflow: hidden;
}
.context-banner-title {
    flex-shrink: 0;
    min-width: 150px;
}
.context-banner-body {
    flex: 1 1 auto;
    min-width: 0;
}
.context-banner-btn {
    padding: 9px 14px;
    font-size: 12.5px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
}

/* Sticky time column & day headers for effortless touch scrolling */
.avail-grid th.time-col,
.avail-grid td.time-col {
    position: sticky;
    left: 0;
    z-index: 6;
    background: #f8fafc;
    box-shadow: 2px 0 6px rgba(15, 23, 42, 0.06);
}
.avail-grid thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #f8fafc;
}
.avail-grid thead th.time-col {
    z-index: 8;
}

/* =========================================================
   MOBILE & TABLET RESPONSIVENESS (<= 900px & <= 640px)
   ========================================================= */
@media (max-width: 900px) {
    .page-layout-with-sidebar {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 108px);
        overflow-x: hidden;
    }
    .grid-workspace,
    .scheduler-workspace {
        padding: 18px 14px calc(92px + env(safe-area-inset-bottom, 0px)) 14px !important;
        width: 100%;
        min-width: 0;
    }
    .workspace-header {
        flex-direction: column;
        align-items: stretch !important;
        gap: 14px;
    }
    .workspace-header h1 {
        font-size: 24px !important;
    }
    .toolbar-divider,
    .kbd-hint {
        display: none !important;
    }
    .workspace-controls,
    .scheduler-toolbar,
    .toolbar-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }
    .toolbar-heatmap-group {
        grid-column: 1 / -1;
        width: 100%;
    }
    .toolbar-heatmap-group .toggle-heatmap-btn {
        flex: 1 1 auto;
        justify-content: center;
        white-space: nowrap;
    }
    #heatmapSettingsBtn {
        width: 48px !important;
        min-width: 48px !important;
        flex: 0 0 48px !important;
        padding: 10px !important;
    }
    .scheduler-filter-select {
        grid-column: 1 / -1;
        width: 100% !important;
        margin-right: 0 !important;
    }
    .workspace-controls .btn-outline,
    .workspace-controls .save-btn,
    .workspace-controls .multi-select-button {
        min-height: 44px;
        justify-content: center;
        width: 100%;
        font-size: 13px;
        padding: 10px 12px;
    }
    .workspace-controls > button.btn-outline {
        grid-column: 1 / -1;
    }
    .workspace-controls .save-btn {
        grid-column: 1 / -1;
    }
    .context-banner-card {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 14px;
    }
    .context-banner-title {
        min-width: 0;
    }
    .context-banner-btn {
        width: 100%;
    }
    .grid-scroll,
    .scheduler-grid-wrapper {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .avail-grid,
    .scheduler-table {
        min-width: 620px;
    }
    .avail-grid th.time-col,
    .avail-grid td.time-col {
        width: 78px;
        min-width: 78px;
        font-size: 11px;
        padding: 8px 6px;
    }
    .mini-window {
        width: calc(100vw - 24px) !important;
        max-width: 420px;
        left: 12px !important;
        bottom: calc(74px + env(safe-area-inset-bottom, 0px)) !important;
    }
    .modal-card {
        width: calc(100vw - 24px) !important;
        max-width: 100% !important;
        padding: 20px !important;
        max-height: 86vh;
        overflow-y: auto;
    }
}

@media (max-width: 640px) {
    .grid-workspace,
    .scheduler-workspace {
        padding: 14px 12px calc(92px + env(safe-area-inset-bottom, 0px)) 12px !important;
    }
    .status-pill-selector {
        width: 100%;
        overflow-x: visible;
    }
    .mini-window-body {
        flex-direction: column;
    }
}

@media (max-width: 360px) {
    .workspace-controls {
        grid-template-columns: 1fr;
    }
}
