/* ══════════════════════════════════════════════════════════════════════════
   Section Export Modal & Print Styles
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Export button group in page headers ─────────────────────────────────── */
.sec-export-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.sec-export-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.9rem;
    font-size: 0.8125rem;
    font-weight: 600;
    border-radius: 0.5rem;
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
    white-space: nowrap;
    text-decoration: none;
    line-height: 1;
}

.sec-export-btn--print {
    background: #f8fafc;
    color: #374151;
    border-color: #d1d5db;
}
.sec-export-btn--print:hover {
    background: #f1f5f9;
    border-color: #9ca3af;
    transform: translateY(-1px);
}

.sec-export-btn--pdf {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}
.sec-export-btn--pdf:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.4);
}

.sec-export-btn--docx {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}
.sec-export-btn--docx:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
}

/* ── Modal overlay ────────────────────────────────────────────────────────── */
.sec-export-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(3px);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: sec-fade-in 0.15s ease;
}

@keyframes sec-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.sec-export-modal {
    background: var(--kpi-surface, #fff);
    border-radius: 1rem;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    width: 100%;
    max-width: 520px;
    display: flex;
    flex-direction: column;
    animation: sec-slide-up 0.2s ease;
    overflow: hidden;
}

@keyframes sec-slide-up {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.sec-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem 1rem;
    border-bottom: 1.5px solid var(--kpi-border, #e5e7eb);
}

.sec-modal-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--kpi-text, #111827);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.sec-modal-title i {
    color: #6366f1;
}

.sec-modal-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--kpi-muted, #6b7280);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.375rem;
    line-height: 1;
    transition: background 0.1s, color 0.1s;
}
.sec-modal-close:hover {
    background: #f3f4f6;
    color: #111827;
}

.sec-modal-body {
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ── Shared confirm-modal content (used by ConfirmDeleteModal) ───────────── */
.dam-lead {
    margin: 0;
    font-size: 0.9rem;
    color: var(--kpi-text, #111827);
    line-height: 1.55;
}

.dam-warning {
    margin: 0;
    font-size: 0.8rem;
    color: var(--kpi-muted, #6b7280);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.dam-warning i {
    color: #f59e0b;
}

.dam-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.6rem;
    padding: 1rem 1.5rem 1.25rem;
    border-top: 1.5px solid var(--kpi-border, #e5e7eb);
}

.dam-spinner {
    display: inline-block;
    width: 0.85rem;
    height: 0.85rem;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: dam-spin 0.6s linear infinite;
    vertical-align: middle;
}

@keyframes dam-spin {
    to { transform: rotate(360deg); }
}

.sec-modal-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.sec-modal-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--kpi-muted, #6b7280);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.sec-modal-date-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.sec-modal-date-row .kpi-input,
.sec-modal-input {
    flex: 1;
    min-width: 120px;
    padding: 0.45rem 0.75rem;
    border: 1.5px solid var(--kpi-border, #e5e7eb);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    background: var(--kpi-surface, #fff);
    color: var(--kpi-text, #111827);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.sec-modal-date-row .kpi-input:focus,
.sec-modal-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

.sec-modal-sep {
    color: var(--kpi-muted, #9ca3af);
    font-size: 0.875rem;
}

/* Employee multi-select list */
.sec-modal-emp-list {
    border: 1.5px solid var(--kpi-border, #e5e7eb);
    border-radius: 0.5rem;
    max-height: 180px;
    overflow-y: auto;
}

.sec-modal-emp-search {
    width: 100%;
    padding: 0.45rem 0.75rem;
    border: none;
    border-bottom: 1.5px solid var(--kpi-border, #e5e7eb);
    border-radius: 0.5rem 0.5rem 0 0;
    font-size: 0.875rem;
    background: var(--kpi-surface, #fff);
    color: var(--kpi-text, #111827);
}
.sec-modal-emp-search:focus { outline: none; box-shadow: none; border-color: #6366f1; }

.sec-modal-emp-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background 0.1s;
    border-bottom: 1px solid #f3f4f6;
}
.sec-modal-emp-item:last-child { border-bottom: none; }
.sec-modal-emp-item:hover { background: #f9fafb; }
.sec-modal-emp-item input[type=checkbox] { accent-color: #6366f1; cursor: pointer; }

.sec-modal-emp-all {
    font-size: 0.75rem;
    color: #6366f1;
    cursor: pointer;
    text-align: right;
    padding: 0 0.25rem;
}
.sec-modal-emp-all:hover { text-decoration: underline; }

/* Footer buttons */
.sec-modal-footer {
    padding: 1rem 1.5rem 1.25rem;
    display: flex;
    gap: 0.625rem;
    justify-content: flex-end;
    border-top: 1.5px solid var(--kpi-border, #e5e7eb);
    flex-wrap: wrap;
}

.sec-modal-action {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 0.5rem;
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
    white-space: nowrap;
}

.sec-modal-action--cancel {
    background: #f3f4f6;
    color: #374151;
    border-color: #d1d5db;
}
.sec-modal-action--cancel:hover { background: #e5e7eb; transform: translateY(-1px); }

.sec-modal-action--print {
    background: #f8fafc;
    color: #374151;
    border-color: #9ca3af;
}
.sec-modal-action--print:hover { background: #f1f5f9; transform: translateY(-1px); }

.sec-modal-action--pdf {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(239,68,68,0.3);
}
.sec-modal-action--pdf:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(239,68,68,0.4); }

.sec-modal-action--docx {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}
.sec-modal-action--docx:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(37,99,235,0.4); }

.sec-modal-action:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

/* Loading spinner inside modal action */
.sec-modal-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.5);
    border-top-color: #fff;
    border-radius: 50%;
    animation: sec-spin 0.6s linear infinite;
    display: inline-block;
}
@keyframes sec-spin { to { transform: rotate(360deg); } }

/* Dark mode */
[data-theme="dark"] .sec-export-btn--print,
[data-bs-theme="dark"] .sec-export-btn--print {
    background: #1f2937;
    color: #e5e7eb;
    border-color: #374151;
}
[data-theme="dark"] .sec-modal-emp-item:hover,
[data-bs-theme="dark"] .sec-modal-emp-item:hover {
    background: #1f2937;
}

/* ── Mode toggle ───────────────────────────────────────────────────────────── */
.sec-mode-toggle {
    display: flex;
    border: 1.5px solid #e5e7eb;
    border-radius: 0.6rem;
    overflow: hidden;
    margin-top: 0.35rem;
}

.sec-mode-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.45rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    background: #f8fafc;
    color: #6b7280;
    border: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.sec-mode-btn:first-child {
    border-right: 1.5px solid #e5e7eb;
}

.sec-mode-btn--active {
    background: #6366f1;
    color: #fff;
    font-weight: 600;
}

.sec-mode-btn:not(.sec-mode-btn--active):hover {
    background: #ede9fe;
    color: #6366f1;
}

.sec-mode-hint {
    font-size: 0.775rem;
    color: #6b7280;
    margin: 0.4rem 0 0;
    font-style: italic;
}

/* Dark mode for mode toggle */
[data-theme="dark"] .sec-mode-toggle,
[data-bs-theme="dark"] .sec-mode-toggle {
    border-color: var(--border);
}

[data-theme="dark"] .sec-mode-btn,
[data-bs-theme="dark"] .sec-mode-btn {
    background: var(--surface-alt);
    color: var(--text-secondary);
}

[data-theme="dark"] .sec-mode-btn:first-child,
[data-bs-theme="dark"] .sec-mode-btn:first-child {
    border-right-color: var(--border);
}

[data-theme="dark"] .sec-mode-btn--active { background: #6366f1; color: #fff; }
[data-theme="dark"] .sec-mode-btn:not(.sec-mode-btn--active):hover { background: rgba(99,102,241,0.15); color: #a5b4fc; }
[data-theme="dark"] .sec-mode-hint { color: var(--text-secondary); }

[data-theme="dark"] .sec-export-modal {
    background: var(--surface);
    color: var(--text);
}

[data-theme="dark"] .sec-modal-header { border-bottom-color: var(--border); }
[data-theme="dark"] .sec-modal-footer { border-top-color: var(--border); }
[data-theme="dark"] .sec-modal-title { color: var(--text); }

[data-theme="dark"] .sec-modal-emp-list {
    border-color: var(--border);
    background: var(--surface);
    color: var(--text);
}

[data-theme="dark"] .sec-modal-emp-search {
    background: var(--input-bg);
    color: var(--text);
    border-bottom-color: var(--border);
}

[data-theme="dark"] .sec-modal-emp-item { border-bottom-color: var(--border); color: var(--text); }
[data-theme="dark"] .sec-modal-emp-item:hover { background: var(--surface-hover); }
[data-theme="dark"] .sec-modal-emp-all { color: #a5b4fc; }

[data-theme="dark"] .sec-modal-label { color: var(--text-secondary); }
[data-theme="dark"] .sec-modal-sep   { color: var(--text-secondary); }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .sec-mode-toggle { border-color: var(--border); }
    :root:not([data-theme="light"]) .sec-mode-btn { background: var(--surface-alt); color: var(--text-secondary); }
    :root:not([data-theme="light"]) .sec-mode-btn:first-child { border-right-color: var(--border); }
    :root:not([data-theme="light"]) .sec-mode-hint { color: var(--text-secondary); }
    :root:not([data-theme="light"]) .sec-export-modal { background: var(--surface); color: var(--text); }
    :root:not([data-theme="light"]) .sec-modal-header { border-bottom-color: var(--border); }
    :root:not([data-theme="light"]) .sec-modal-footer { border-top-color: var(--border); }
    :root:not([data-theme="light"]) .sec-modal-title { color: var(--text); }
    :root:not([data-theme="light"]) .sec-modal-emp-list { border-color: var(--border); background: var(--surface); color: var(--text); }
    :root:not([data-theme="light"]) .sec-modal-emp-search { background: var(--input-bg); color: var(--text); border-bottom-color: var(--border); }
    :root:not([data-theme="light"]) .sec-modal-emp-item { border-bottom-color: var(--border); color: var(--text); }
    :root:not([data-theme="light"]) .sec-modal-emp-item:hover { background: var(--surface-hover); }
    :root:not([data-theme="light"]) .sec-modal-label { color: var(--text-secondary); }
}

/* ── Dashboard map print styles ───────────────────────────────────────────── */
@media print {
    /*
     * Use visibility:hidden (inheritable) rather than display:none so that a
     * deeply-nested .dashboard-print-target can override it with
     * visibility:visible on itself and its children.  display:none removes the
     * entire subtree from layout and cannot be overridden by a descendant.
     */
    html[data-printing-map="1"] body * {
        visibility: hidden !important;
    }

    /*
     * Collapse BOTH html and body to zero height with overflow:hidden.
     * - body alone is not enough: the html element retains the full document
     *   height and the browser uses it to paginate.
     * - position:absolute children can still push html's scroll-height even
     *   when body is zero, because absolute boxes are contained by the nearest
     *   positioned ancestor — which defaults to the initial containing block
     *   (html).  Clamping html + overflow:hidden prevents that.
     */
    html[data-printing-map="1"],
    html[data-printing-map="1"] body {
        height: 0 !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }

    /* Restore the card and every element inside it */
    html[data-printing-map="1"] .dashboard-print-target,
    html[data-printing-map="1"] .dashboard-print-target * {
        visibility: visible !important;
    }

    /* Place the card once at the top of the (now single) print page */
    html[data-printing-map="1"] .dashboard-print-target {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        box-shadow: none !important;
        border: 1px solid #dee2e6 !important;
        page-break-inside: avoid;
        background: #fff !important;
    }

    /* Reveal the filter summary header, hide the interactive filter bar */
    html[data-printing-map="1"] .dashboard-print-header {
        display: block !important;
        visibility: visible !important;
    }
    html[data-printing-map="1"] .dashboard-map-filter-bar,
    html[data-printing-map="1"] .dashboard-map-print-controls {
        display: none !important;
    }

    /* Expand the map to fill the available print width */
    html[data-printing-map="1"] #employee-map {
        height: 500px !important;
        width: 100% !important;
        border-radius: 0 !important;
    }

    /* Force tile images to render in colour in print */
    html[data-printing-map="1"] .leaflet-container img,
    html[data-printing-map="1"] .leaflet-container canvas {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        visibility: visible !important;
    }
}


    /* Reveal the filter summary header, hide the interactive filter bar */
    html[data-printing-map="1"] .dashboard-print-header {
        display: block !important;
        visibility: visible !important;
    }
    html[data-printing-map="1"] .dashboard-map-filter-bar,
    html[data-printing-map="1"] .dashboard-map-print-controls {
        display: none !important;
    }

    /* Expand the map to fill the available print width */
    html[data-printing-map="1"] #employee-map {
        height: 500px !important;
        width: 100% !important;
        border-radius: 0 !important;
    }

    /* Force tile images to render in colour in print */
    html[data-printing-map="1"] .leaflet-container img,
    html[data-printing-map="1"] .leaflet-container canvas {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        visibility: visible !important;
    }
}
