/* ============================================================
   e-KEPEGAWAIAN UNIMA — UX/UI ENHANCEMENT LAYER
   Additive stylesheet: dark mode, a11y, progress bar, cookie
   banner, FAQ, confirm modal, 404 page, print styles, etc.
   Loaded AFTER style.css — does not modify existing rules.
   ============================================================ */

/* ---------- 1. Skip-to-content link ---------- */
.skip-to-content {
    position: fixed;
    top: -60px;
    left: 12px;
    z-index: 3000;
    background: var(--brand-blue, #1a56a5);
    color: #fff;
    padding: 10px 18px;
    border-radius: 0 0 8px 8px;
    font-weight: 600;
    font-size: .9rem;
    text-decoration: none;
    transition: top .2s ease;
    box-shadow: var(--shadow-md, 0 4px 14px rgba(0,0,0,.15));
}
.skip-to-content:focus {
    top: 0;
    color: #fff;
    outline: 3px solid var(--brand-accent, #e8a020);
    outline-offset: 2px;
}

/* ---------- 2. Global focus-visible states (a11y) ---------- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid var(--brand-accent, #e8a020);
    outline-offset: 2px;
    border-radius: 4px;
}
.nav-link:focus-visible,
.dropdown-item:focus-visible,
.btn-portal:focus-visible {
    outline-offset: -2px;
}

/* Hover/focus polish for buttons that only had hover before */
.btn, .btn-portal, .nav-search-btn, .nav-hamburger, button {
    transition: transform var(--dur-fast, .15s) var(--ease, ease),
                filter var(--dur-fast, .15s) var(--ease, ease),
                box-shadow var(--dur-fast, .15s) var(--ease, ease),
                background-color var(--dur-fast, .15s) var(--ease, ease),
                color var(--dur-fast, .15s) var(--ease, ease);
}
.btn:hover, .btn:focus-visible,
.btn-portal:hover, .btn-portal:focus-visible {
    filter: brightness(1.06);
    transform: translateY(-1px);
}
.btn:active, .btn-portal:active { transform: translateY(0); filter: brightness(.97); }
.nav-search-btn:hover, .nav-search-btn:focus-visible,
.nav-hamburger:hover, .nav-hamburger:focus-visible { filter: brightness(1.1); }
button:disabled, .btn:disabled { filter: none !important; transform: none !important; cursor: not-allowed; opacity: .6; }

/* ---------- 3. Scroll progress bar ---------- */
.scroll-progress {
    position: fixed;
    top: 0; left: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(90deg, var(--brand-blue, #1a56a5), var(--brand-accent, #e8a020));
    z-index: 2500;
    transition: width .08s linear;
}

/* ---------- 4. Theme toggle button ---------- */
.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--gray-200, #e2e8f0);
    background: var(--gray-50, #f8fafc);
    color: var(--brand-navy, #0d1b3e);
    cursor: pointer;
    font-size: 1rem;
}
.theme-toggle-btn:hover { background: var(--gray-100, #f1f5f9); }
.theme-toggle-btn .bi-moon-stars-fill { display: none; }
[data-theme="dark"] .theme-toggle-btn .bi-sun-fill { display: none; }
[data-theme="dark"] .theme-toggle-btn .bi-moon-stars-fill { display: inline-block; }

/* ---------- 5. Loading skeleton / spinner utilities ---------- */
.skeleton {
    background: linear-gradient(90deg, var(--gray-100, #f1f5f9) 25%, var(--gray-200, #e2e8f0) 37%, var(--gray-100, #f1f5f9) 63%);
    background-size: 400% 100%;
    animation: skeleton-loading 1.4s ease infinite;
    border-radius: var(--radius-sm, 6px);
}
@keyframes skeleton-loading { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.enhance-spinner {
    width: 22px; height: 22px;
    border: 3px solid var(--gray-200, #e2e8f0);
    border-top-color: var(--brand-blue, #1a56a5);
    border-radius: 50%;
    animation: enhance-spin .7s linear infinite;
    display: inline-block;
}
@keyframes enhance-spin { to { transform: rotate(360deg); } }

.page-fade-in { animation: pageFadeIn .3s ease both; }
@keyframes pageFadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 6. Back-to-top polish (element already exists in HTML) ---------- */
.back-to-top:focus-visible { outline: 3px solid var(--brand-accent, #e8a020); outline-offset: 3px; }

/* ---------- 7. Cookie consent banner ---------- */
.cookie-banner {
    position: fixed;
    left: 16px; right: 16px; bottom: 16px;
    max-width: 560px;
    margin: 0 auto;
    background: var(--brand-navy, #0d1b3e);
    color: #fff;
    border-radius: var(--radius-lg, 16px);
    box-shadow: var(--shadow-xl, 0 20px 60px rgba(0,0,0,.25));
    padding: 18px 20px;
    z-index: 2600;
    display: none;
    gap: 12px;
    flex-direction: column;
    transform: translateY(20px);
    opacity: 0;
    transition: transform .3s ease, opacity .3s ease;
}
.cookie-banner.open { display: flex; transform: translateY(0); opacity: 1; }
.cookie-banner p { margin: 0; font-size: .85rem; line-height: 1.5; color: rgba(255,255,255,.85); }
.cookie-banner-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.cookie-banner-actions .btn { font-size: .82rem; padding: 7px 16px; }
@media (max-width: 480px) { .cookie-banner { left: 10px; right: 10px; bottom: 10px; padding: 16px; } }

/* ---------- 8. Expandable FAQ ---------- */
.faq-list { display: flex; flex-direction: column; gap: 10px; }
.faq-item {
    border: 1px solid var(--gray-200, #e2e8f0);
    border-radius: var(--radius-md, 10px);
    overflow: hidden;
    background: #fff;
}
.faq-question {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: none;
    border: none;
    text-align: left;
    padding: 14px 16px;
    font-weight: 600;
    font-size: .92rem;
    color: var(--brand-navy, #0d1b3e);
    cursor: pointer;
}
.faq-question .faq-chevron { transition: transform .2s ease; flex-shrink: 0; }
.faq-item.open .faq-question .faq-chevron { transform: rotate(180deg); }
.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height .25s ease;
    font-size: .87rem;
    color: var(--gray-600, #475569);
    line-height: 1.6;
}
.faq-answer-inner { padding: 0 16px 16px; }
.faq-item.open .faq-answer { max-height: 600px; }

/* ---------- 9. Confirmation modal (destructive actions) ---------- */
.confirm-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(13, 27, 62, .55);
    z-index: 3100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.confirm-modal-overlay.open { display: flex; }
.confirm-modal-box {
    background: #fff;
    border-radius: var(--radius-lg, 16px);
    max-width: 420px;
    width: 100%;
    padding: 24px;
    box-shadow: var(--shadow-xl, 0 20px 60px rgba(0,0,0,.25));
    animation: confirmPop .18s ease;
}
@keyframes confirmPop { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.confirm-modal-icon {
    width: 46px; height: 46px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: #fef2f2; color: var(--color-danger, #dc2626);
    font-size: 1.3rem; margin-bottom: 14px;
}
.confirm-modal-box h5 { font-weight: 700; margin-bottom: 8px; color: var(--brand-navy, #0d1b3e); }
.confirm-modal-box p { color: var(--gray-600, #475569); font-size: .88rem; margin-bottom: 20px; }
.confirm-modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- 10. 404 page ---------- */
.page-404 {
    min-height: 60vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 20px;
}
.page-404 .code-404 {
    font-size: clamp(4rem, 12vw, 7rem);
    font-weight: 800;
    line-height: 1;
    background: linear-gradient(135deg, var(--brand-blue, #1a56a5), var(--brand-accent, #e8a020));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.page-404 h2 { color: var(--brand-navy, #0d1b3e); margin: 12px 0 8px; }
.page-404 p { color: var(--gray-500, #64748b); max-width: 420px; margin-bottom: 24px; }

/* ---------- 11. Copy-to-clipboard for code snippets ---------- */
.enhance-code-wrap { position: relative; }
.enhance-copy-btn {
    position: absolute;
    top: 8px; right: 8px;
    background: rgba(255,255,255,.12);
    color: #fff;
    border: 1px solid rgba(255,255,255,.25);
    border-radius: 6px;
    font-size: .72rem;
    padding: 4px 9px;
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}
.enhance-copy-btn:hover { background: rgba(255,255,255,.22); }
.enhance-copy-btn.copied { background: var(--color-success, #16a34a); border-color: var(--color-success, #16a34a); }

/* ---------- 12. Last-updated badge ---------- */
.last-updated-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: .75rem;
    color: var(--gray-500, #64748b);
    background: var(--gray-100, #f1f5f9);
    padding: 3px 9px;
    border-radius: 999px;
}

/* ============================================================
   DARK MODE
   ============================================================ */
[data-theme="dark"] {
    --gray-50:  #0f172a;
    --gray-100: #16213a;
    --gray-200: #23304d;
    --gray-300: #35415e;
    --gray-400: #5b6a8a;
    --gray-500: #8896b3;
    --gray-600: #aab6ce;
    --gray-700: #c7d1e3;
    --gray-800: #e5eaf3;
    --gray-900: #f5f7fb;
}
[data-theme="dark"] body { background: #0a1226; color: var(--gray-700); }

/* Every container that hardcodes background:#fff in style.css gets a dark
   surface here, matched with an explicit light text color so nothing
   inherits a color meant for a white background. */
[data-theme="dark"] .main-navbar,
[data-theme="dark"] .breadcrumb-bar,
[data-theme="dark"] .nav-dropdown-menu,
[data-theme="dark"] .nav-menu.mobile-open,
[data-theme="dark"] .search-suggestions,
[data-theme="dark"] .site-footer,
[data-theme="dark"] .modal-overlay .modal-box,
[data-theme="dark"] .modal-header,
[data-theme="dark"] .confirm-modal-box,
[data-theme="dark"] .cookie-banner,
[data-theme="dark"] .card,
[data-theme="dark"] .dash-section,
[data-theme="dark"] .chart-card,
[data-theme="dark"] .article-card,
[data-theme="dark"] .article-image-overlay,
[data-theme="dark"] .artikel-list-item,
[data-theme="dark"] .layanan-card:hover,
[data-theme="dark"] .survey-thanks,
[data-theme="dark"] .survey-popup-box,
[data-theme="dark"] .table-card,
[data-theme="dark"] .faq-item,
[data-theme="dark"] .upload-card,
[data-theme="dark"] .upload-card:hover,
[data-theme="dark"] .doc-link-item,
[data-theme="dark"] .doc-link-item:hover,
[data-theme="dark"] .success-card,
[data-theme="dark"] .ref-box,
[data-theme="dark"] .chat-widget-panel,
[data-theme="dark"] .chat-widget-tab.active,
[data-theme="dark"] .chat-widget-inputbar,
[data-theme="dark"] .chat-bubble.from-bot,
[data-theme="dark"] .chat-widget-ticket-badge,
[data-theme="dark"] .toast-item {
    background: #101c38 !important;
    color: var(--gray-700) !important;
    border-color: var(--gray-200) !important;
}
/* Headings / labels that use the fixed --brand-navy color (not a themed
   variable) go invisible on the dark surfaces above — force them light. */
[data-theme="dark"] .nav-link,
[data-theme="dark"] .dropdown-item strong,
[data-theme="dark"] .faq-question,
[data-theme="dark"] .card-title-usul,
[data-theme="dark"] .success-card h3,
[data-theme="dark"] .doc-links-title,
[data-theme="dark"] .step-item.active .step-label,
[data-theme="dark"] .doc-link-item:hover,
[data-theme="dark"] .upload-btn,
[data-theme="dark"] .field-value,
[data-theme="dark"] .upload-name,
[data-theme="dark"] h1, [data-theme="dark"] h2, [data-theme="dark"] h3,
[data-theme="dark"] h4, [data-theme="dark"] h5 { color: var(--gray-900) !important; }
[data-theme="dark"] .upload-btn { border-color: var(--gray-400) !important; }
[data-theme="dark"] .upload-btn:hover { background: var(--brand-blue, #1a56a5) !important; color: #fff !important; }
[data-theme="dark"] .doc-link-item:hover { border-color: var(--brand-blue, #1a56a5) !important; }
[data-theme="dark"] .dropdown-item:hover { background: var(--gray-100); }
/* Secondary/muted text that used fixed hex greys (#94a3b8, #1e293b, etc.) */
[data-theme="dark"] .artikel-list-empty,
[data-theme="dark"] .chat-bubble-admin-name { color: var(--gray-500) !important; }
[data-theme="dark"] .info-banner { background: #16213a !important; color: var(--gray-700) !important; border-left-color: var(--brand-blue, #1a56a5); }
[data-theme="dark"] .chat-suggestion-chip { background: var(--gray-100) !important; color: var(--gray-700) !important; border-color: var(--gray-300) !important; }
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select {
    background: #16213a !important;
    color: var(--gray-700) !important;
    border-color: var(--gray-300) !important;
}
[data-theme="dark"] .form-control::placeholder { color: var(--gray-500); }
[data-theme="dark"] .theme-toggle-btn { background: #16213a; border-color: var(--gray-300); color: var(--gray-800); }
[data-theme="dark"] .nav-search-bar { background: #101c38 !important; }
[data-theme="dark"] .sug-item:hover { background: var(--gray-100); }
[data-theme="dark"] a { color: var(--brand-blue-light, #4a90e2); }
[data-theme="dark"] .artikel-list-date,
[data-theme="dark"] .last-updated-badge { background: var(--gray-100); color: var(--gray-500); }
[data-theme="dark"] .skeleton {
    background: linear-gradient(90deg, #16213a 25%, #23304d 37%, #16213a 63%);
    background-size: 400% 100%;
}

/* ---------- 13. Print stylesheet ---------- */
@media print {
    .topbar, .main-navbar, .breadcrumb-bar, .site-footer,
    .back-to-top, .scroll-progress, .cookie-banner,
    .chat-widget-toggle, .chat-widget-panel, .skip-to-content,
    .theme-toggle-btn, .toast-item, .survey-popup-overlay,
    .nav-search-bar, .confirm-modal-overlay, .enhance-copy-btn,
    button, .btn, .btn-portal, video, audio {
        display: none !important;
    }
    body { background: #fff !important; color: #000 !important; }
    main#app-container { margin: 0 !important; padding: 0 !important; }
    a { color: #000 !important; text-decoration: underline; }
    a[href^="http"]::after { content: " (" attr(href) ")"; font-size: .75em; color: #555; }
    * { box-shadow: none !important; text-shadow: none !important; }
}

/* ---------- 14. Responsive table → card view (mobile) ---------- */
/* Applied via enhance.js to tables inside .table-overflow / .table-responsive
   wrappers within #app-container. Cells get [data-label] from their <th>. */
@media (max-width: 767px) {
    .table-cards-mobile thead { display: none; }
    .table-cards-mobile, .table-cards-mobile tbody, .table-cards-mobile tr, .table-cards-mobile td {
        display: block;
        width: 100%;
    }
    .table-cards-mobile tr {
        margin-bottom: 12px;
        border: 1px solid var(--gray-200, #e2e8f0);
        border-radius: var(--radius-md, 10px);
        padding: 10px 12px;
        background: #fff;
    }
    [data-theme="dark"] .table-cards-mobile tr { background: #101c38; border-color: var(--gray-200); }
    .table-cards-mobile td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
        text-align: right;
        padding: 6px 0;
        border: none !important;
        font-size: .84rem;
    }
    .table-cards-mobile td:not(:last-child) { border-bottom: 1px dashed var(--gray-200, #e2e8f0) !important; }
    .table-cards-mobile td[data-label]::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--gray-500, #64748b);
        text-align: left;
        margin-right: auto;
        padding-right: 10px;
        flex-shrink: 0;
    }
    .table-cards-mobile td:empty::before { content: none; }
}

/* ---------- 15. Status badge visual consistency ---------- */
.badge, span.badge {
    font-weight: 600;
    letter-spacing: .01em;
    padding: 5px 10px;
    border-radius: 999px;
}
[data-theme="dark"] .badge.bg-light { background: var(--gray-100) !important; color: var(--gray-700) !important; }
[data-theme="dark"] .badge.text-dark { color: var(--gray-900) !important; }

/* ---------- 16. Input masking / validation UX ---------- */
input[id^="input-nip"] { font-variant-numeric: tabular-nums; letter-spacing: .03em; }
input[id^="input-nip"].mask-invalid { border-color: var(--color-danger, #dc2626) !important; }
input[id^="input-nip"].mask-valid { border-color: var(--color-success, #16a34a) !important; }
.nip-hint {
    font-size: .74rem;
    margin-top: 4px;
    color: var(--gray-500, #64748b);
    display: flex;
    align-items: center;
    gap: 4px;
}
.nip-hint.hint-ok { color: var(--color-success, #16a34a); }

/* Consistent date-picker affordance */
input[type="date"] { cursor: pointer; }
input[type="date"]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .7; }
input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: 1; }

/* Live preview box for forms */
.form-live-preview {
    border: 1px dashed var(--gray-300, #cbd5e1);
    border-radius: var(--radius-md, 10px);
    padding: 14px 16px;
    background: var(--gray-50, #f8fafc);
    font-size: .84rem;
    margin-top: 14px;
}
[data-theme="dark"] .form-live-preview { background: #101c38; border-color: var(--gray-300); }
.form-live-preview h6 { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--gray-500, #64748b); margin-bottom: 8px; }
.form-live-preview .preview-row { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }
.form-live-preview .preview-row span:first-child { color: var(--gray-500, #64748b); }
.form-live-preview .preview-row span:last-child { font-weight: 600; text-align: right; }

/* ---------- Responsive helper: ensure hamburger/menu targets are large enough ---------- */
@media (max-width: 991px) {
    .nav-hamburger { min-width: 44px; min-height: 44px; }
    .nav-search-btn { min-width: 44px; min-height: 44px; }
}
