/* ========================================
   GLOBAL TOAST NOTIFICATION
======================================== */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
    width: calc(100% - 40px);
    pointer-events: none;
}

.toast-item {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 18px;
    border-radius: var(--radius, 8px);
    background: #ffffff;
    box-shadow: 0 8px 32px rgba(2, 8, 23, .16), 0 2px 8px rgba(2, 8, 23, .08);
    pointer-events: auto;
    overflow: hidden;
    transform: translateX(120%);
    opacity: 0;
    transition: transform .4s cubic-bezier(.2,.8,.2,1), opacity .35s ease;
}

.toast-item.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-item.removing {
    transform: translateX(120%);
    opacity: 0;
    transition: transform .35s ease, opacity .3s ease;
}

/* Icon */
.toast-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 50%;
    font-size: .85rem;
    margin-top: 1px;
}

.toast-item.toast-success .toast-icon {
    background: #dcfce7;
    color: #16a34a;
}
.toast-item.toast-error .toast-icon {
    background: #fee2e2;
    color: #dc2626;
}
.toast-item.toast-warning .toast-icon {
    background: #fff4d4;
    color: #d97706;
}
.toast-item.toast-info .toast-icon {
    background: #dbeafe;
    color: #2563eb;
}

/* Accent border left */
.toast-item::before {
    content: "";
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 4px;
    border-radius: 99px;
}

.toast-item.toast-success::before { background: #16a34a; }
.toast-item.toast-error::before { background: #dc2626; }
.toast-item.toast-warning::before { background: #d97706; }
.toast-item.toast-info::before { background: #2563eb; }

/* Body */
.toast-body {
    flex: 1;
    min-width: 0;
    padding-right: 8px;
}

.toast-title {
    display: block;
    font-size: .88rem;
    font-weight: 850;
    color: var(--ink, #0d1b2a);
    line-height: 1.3;
    text-transform: capitalize;
}

.toast-message {
    display: block;
    margin-top: 3px;
    font-size: .82rem;
    font-weight: 650;
    color: var(--muted-strong, #475569);
    line-height: 1.55;
    word-break: break-word;
}

/* Close button */
.toast-close {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    min-width: 28px;
    border: none;
    border-radius: 6px;
    background: none;
    color: var(--muted, #64748b);
    font-size: 1.1rem;
    cursor: pointer;
    transition: color .2s, background .2s;
    margin-top: 1px;
    padding: 0;
    line-height: 1;
}

.toast-close:hover {
    color: var(--ink, #0d1b2a);
    background: rgba(15, 23, 42, .06);
}

/* Progress bar */
.toast-progress {
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    border-radius: 0 0 var(--radius, 8px) var(--radius, 8px);
    animation: toastProgress 5s linear forwards;
}

.toast-item.toast-success .toast-progress { background: #16a34a; }
.toast-item.toast-error .toast-progress { background: #dc2626; }
.toast-item.toast-warning .toast-progress { background: #d97706; }
.toast-item.toast-info .toast-progress { background: #2563eb; }

@keyframes toastProgress {
    from { width: 100%; }
    to { width: 0%; }
}

/* Pause progress on hover / touch */
.toast-item.paused .toast-progress {
    animation-play-state: paused;
}

/* -- Swipe state -- */
.toast-item.swiping {
    transition: none !important;
}

/* -- Responsive -- */
@media (max-width: 575.98px) {
    .toast-container {
        top: 12px;
        right: 12px;
        width: calc(100% - 24px);
        max-width: none;
    }
    .toast-item {
        padding: 14px 16px;
        gap: 10px;
    }
    .toast-icon {
        width: 24px;
        height: 24px;
        min-width: 24px;
        font-size: .75rem;
    }
    .toast-title {
        font-size: .84rem;
    }
    .toast-message {
        font-size: .78rem;
    }
    .toast-close {
        width: 26px;
        height: 26px;
        min-width: 26px;
        font-size: 1rem;
    }
}

/* -- Reduced motion -- */
@media (prefers-reduced-motion: reduce) {
    .toast-item {
        transition: opacity .15s ease !important;
        transform: none !important;
    }
    .toast-item.removing {
        opacity: 0;
    }
    .toast-progress {
        animation: none;
        width: 0;
    }
}

/* ------------------------------------------
   LOGOUT CONFIRMATION MODAL
   ------------------------------------------ */

.logout-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(2, 8, 23, .55);
    backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .28s ease;
}
.logout-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.logout-modal {
    position: relative;
    width: 100%;
    max-width: 400px;
    background: #ffffff;
    border-radius: var(--radius, 8px);
    padding: 36px 32px 28px;
    box-shadow: 0 28px 80px rgba(2, 8, 23, .28);
    transform: scale(.88) translateY(16px);
    transition: transform .32s cubic-bezier(.2,.8,.2,1);
    overflow: hidden;
}
.logout-overlay.show .logout-modal {
    transform: scale(1) translateY(0);
}

/* Accent top bar */
.logout-modal::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 4px;
    background: linear-gradient(90deg, var(--teal, #0f766e), var(--blue, #2563eb), var(--amber, #f5b83d));
}

/* Icon */
.logout-modal-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    margin: 0 auto 18px;
    border-radius: 50%;
    background: #fee2e2;
    color: #dc2626;
    font-size: 1.8rem;
}

/* Title */
.logout-modal-title {
    margin: 0 0 10px;
    font-size: 1.25rem;
    font-weight: 900;
    color: var(--ink, #0d1b2a);
    text-align: center;
    line-height: 1.3;
}

/* Text */
.logout-modal-text {
    margin: 0 0 28px;
    font-size: .9rem;
    font-weight: 650;
    color: var(--muted-strong, #475569);
    text-align: center;
    line-height: 1.65;
}

/* Buttons row */
.logout-modal-actions {
    display: flex;
    gap: 12px;
}
.logout-modal-actions button {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 11px 18px;
    border: none;
    border-radius: var(--radius, 8px);
    font-size: .92rem;
    font-weight: 850;
    cursor: pointer;
    transition: transform .2s var(--ease, cubic-bezier(.2,.8,.2,1)),
                box-shadow .25s var(--ease, cubic-bezier(.2,.8,.2,1)),
                background .2s ease;
    line-height: 1.2;
}
.logout-modal-actions button:active {
    transform: scale(.96);
}

/* Batal button */
.logout-btn-cancel {
    background: rgba(15, 23, 42, .06);
    color: var(--ink, #0d1b2a);
}
.logout-btn-cancel:hover {
    background: rgba(15, 23, 42, .1);
}

/* Logout button */
.logout-btn-confirm {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(220, 38, 38, .25);
}
.logout-btn-confirm:hover {
    box-shadow: 0 8px 24px rgba(220, 38, 38, .32);
    transform: translateY(-1px);
}
.logout-btn-confirm:active {
    transform: translateY(0) scale(.96);
    box-shadow: 0 2px 8px rgba(220, 38, 38, .18);
}

/* -- Mobile -- */
@media (max-width: 575.98px) {
    .logout-overlay {
        padding: 16px;
        align-items: flex-end;
    }
    .logout-overlay.show .logout-modal {
        transform: scale(1) translateY(0);
        border-radius: var(--radius, 8px) var(--radius, 8px) 0 0;
    }
    .logout-modal {
        max-width: none;
        padding: 28px 22px 22px;
        transform: scale(1) translateY(60px);
        border-radius: var(--radius, 8px) var(--radius, 8px) 0 0;
    }
    .logout-modal-icon {
        width: 54px;
        height: 54px;
        font-size: 1.5rem;
        margin-bottom: 14px;
    }
    .logout-modal-title {
        font-size: 1.1rem;
    }
    .logout-modal-text {
        font-size: .85rem;
        margin-bottom: 22px;
    }
    .logout-modal-actions button {
        min-height: 44px;
        font-size: .88rem;
    }
}

/* -- Touch disable hover -- */
@media (hover: none) {
    .logout-btn-confirm:hover {
        transform: none;
        box-shadow: 0 4px 14px rgba(220, 38, 38, .25);
    }
    .logout-btn-cancel:hover {
        background: rgba(15, 23, 42, .06);
    }
}

/* -- Reduced motion -- */
@media (prefers-reduced-motion: reduce) {
    .logout-overlay {
        transition: none;
    }
    .logout-modal {
        transition: none;
    }
}

/* ------------------------------------------
   FONT SIZE CONTROLS — A- / A / A+
   ------------------------------------------ */

.font-size-controls {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: auto;
    flex-shrink: 0;
}

.font-size-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    min-width: 32px;
    border: 1.5px solid rgba(15, 23, 42, .1);
    border-radius: 6px;
    background: rgba(255, 255, 255, .7);
    color: var(--muted, #64748b);
    font-family: var(--font-main, system-ui);
    font-weight: 800;
    cursor: pointer;
    transition: color .2s, background .2s, border-color .2s, transform .2s;
    line-height: 1;
    padding: 0;
}
.font-size-btn:hover {
    background: rgba(255, 255, 255, .95);
    color: var(--ink, #0d1b2a);
    border-color: rgba(15, 23, 42, .18);
}
.font-size-btn:active {
    transform: scale(.92);
}

.font-size-btn.s1 { font-size: .7rem; }
.font-size-btn.s2 { font-size: .82rem; }
.font-size-btn.s3 { font-size: .95rem; }

.font-size-btn.active {
    background: linear-gradient(135deg, var(--teal, #0f766e), var(--blue, #2563eb));
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(37, 99, 235, .2);
}

/* Inject into dashboard topbar */
.topbar .font-size-controls {
    margin-right: 14px;
}

/* Inject into admin topbar */
.admin-topbar .font-size-controls {
    margin-right: 14px;
}

/* -- Responsive -- */
@media (max-width: 575.98px) {
    .font-size-btn {
        width: 30px;
        height: 30px;
        min-width: 30px;
    }
    .topbar .font-size-controls,
    .admin-topbar .font-size-controls {
        margin-right: 8px;
    }
}

/* ------------------------------------------
   TOP LOADING PROGRESS BAR
   ------------------------------------------ */

.pg-bar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 9999999;
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--teal, #0f766e), var(--blue, #2563eb), var(--amber, #f5b83d));
    box-shadow: 0 0 8px rgba(37, 99, 235, .35);
    transition: width .4s cubic-bezier(.2,.8,.2,1), opacity .35s ease;
    pointer-events: none;
}

/* Initial trickle — CSS-only until JS takes over */
.pg-bar.trickle {
    animation: pgTrickle 1.8s ease-out forwards;
}

@keyframes pgTrickle {
    0%   { width: 0%; }
    30%  { width: 18%; }
    60%  { width: 32%; }
    85%  { width: 40%; }
    100% { width: 45%; }
}

/* Jump to near-complete (triggered by JS on DOMContentLoaded) */
.pg-bar.near {
    width: 85% !important;
    transition-duration: .3s;
}

/* Complete — full width then fade */
.pg-bar.done {
    width: 100% !important;
    transition-duration: .25s;
}
.pg-bar.fade {
    opacity: 0;
    transition: opacity .35s ease;
}

/* Pulse glow when bar is active */
.pg-bar.pulse::after {
    content: "";
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 60px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.35));
    animation: pgGlow 1.2s ease infinite;
}

@keyframes pgGlow {
    0%   { opacity: 0; transform: translateX(-20px); }
    50%  { opacity: 1; }
    100% { opacity: 0; transform: translateX(20px); }
}

/* -- Reduced motion -- */
@media (prefers-reduced-motion: reduce) {
    .pg-bar {
        transition: opacity .15s ease !important;
        animation: none !important;
    }
    .pg-bar.trickle {
        animation: none;
        width: 45%;
    }
    .pg-bar.pulse::after {
        display: none;
    }
}

/* ------------------------------------------
   EMPTY STATE
   ------------------------------------------ */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    min-height: 220px;
}

/* Illustration area — CSS-only decorative circle with icon */
.empty-state-illustration {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--blue-soft, #dbeafe), var(--teal-soft, #ccfbf1));
    color: var(--blue, #2563eb);
    font-size: 2rem;
    box-shadow: 0 8px 24px rgba(37, 99, 235, .12);
}

/* Decorative ring behind icon */
.empty-state-illustration::before {
    content: "";
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px dashed rgba(37, 99, 235, .15);
    animation: emptyRing 12s linear infinite;
}
@keyframes emptyRing {
    to { transform: rotate(360deg); }
}

/* Small decorative dots */
.empty-state-illustration::after {
    content: "";
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--amber, #f5b83d);
    top: -2px;
    right: -2px;
    opacity: .6;
}

.empty-state-title {
    margin: 0 0 8px;
    font-size: 1.1rem;
    font-weight: 900;
    color: var(--ink, #0d1b2a);
    line-height: 1.3;
}

.empty-state-desc {
    margin: 0 0 22px;
    font-size: .88rem;
    font-weight: 650;
    color: var(--muted, #64748b);
    line-height: 1.6;
    max-width: 360px;
}

.empty-state-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 10px 22px;
    border: none;
    border-radius: var(--radius, 8px);
    background: linear-gradient(135deg, var(--teal, #0f766e), var(--blue, #2563eb));
    color: #fff;
    font-size: .85rem;
    font-weight: 850;
    text-decoration: none;
    cursor: pointer;
    transition: transform .2s var(--ease, cubic-bezier(.2,.8,.2,1)),
                box-shadow .25s var(--ease, cubic-bezier(.2,.8,.2,1));
    box-shadow: 0 4px 14px rgba(37, 99, 235, .2);
}
.empty-state-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(37, 99, 235, .28);
    color: #fff;
}
.empty-state-btn:active {
    transform: translateY(0) scale(.97);
}

/* -- Inside tables (td) -- */
td .empty-state,
td.empty-state-cell .empty-state {
    padding: 40px 16px;
    min-height: 160px;
}
td .empty-state-illustration {
    width: 64px;
    height: 64px;
    font-size: 1.5rem;
    margin-bottom: 16px;
}
td .empty-state-title {
    font-size: .95rem;
}
td .empty-state-desc {
    font-size: .82rem;
    max-width: 300px;
}
td .empty-state-btn {
    min-height: 36px;
    padding: 8px 18px;
    font-size: .8rem;
}

/* -- Mobile -- */
@media (max-width: 575.98px) {
    .empty-state {
        padding: 36px 18px;
        min-height: 180px;
    }
    .empty-state-illustration {
        width: 64px;
        height: 64px;
        font-size: 1.5rem;
    }
    .empty-state-title {
        font-size: 1rem;
    }
    .empty-state-desc {
        font-size: .82rem;
    }
    td .empty-state {
        padding: 28px 12px;
        min-height: 140px;
    }
}

/* -- Reduced motion -- */
@media (prefers-reduced-motion: reduce) {
    .empty-state-illustration::before {
        animation: none;
        border-style: solid;
    }
}

/* -- Color variants -- */
.empty-state-illustration.is-module {
    background: linear-gradient(135deg, #dbeafe, #e9d5ff);
    color: #7c3aed;
}
.empty-state-illustration.is-user {
    background: linear-gradient(135deg, #dbeafe, #ccfbf1);
    color: #0f766e;
}
.empty-state-illustration.is-consultation {
    background: linear-gradient(135deg, #fce7f3, #dbeafe);
    color: #db2777;
}
.empty-state-illustration.is-quiz {
    background: linear-gradient(135deg, #fef3c7, #dbeafe);
    color: #d97706;
}
.empty-state-illustration.is-simulation {
    background: linear-gradient(135deg, #ccfbf1, #dbeafe);
    color: #0f766e;
}
.empty-state-illustration.is-timeline {
    background: linear-gradient(135deg, #f3e8ff, #dbeafe);
    color: #7c3aed;
}
.empty-state-illustration.is-history {
    background: linear-gradient(135deg, #fce7f3, #ccfbf1);
    color: #be185d;
}

/* ------------------------------------------
   TOOLTIP — hover desktop + tap-hold mobile
   ------------------------------------------ */

.tt {
    position: fixed;
    z-index: 999999;
    padding: 8px 14px;
    border-radius: 6px;
    background: #0d1b2a;
    color: #fff;
    font-size: .78rem;
    font-weight: 700;
    font-family: var(--font-main, system-ui);
    line-height: 1.4;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity .2s ease, transform .2s var(--ease, cubic-bezier(.2,.8,.2,1));
    max-width: 280px;
    white-space: normal;
    word-break: break-word;
    box-shadow: 0 4px 16px rgba(2, 8, 23, .22);
}
.tt.show {
    opacity: 1;
    transform: translateY(0);
}

/* Arrow */
.tt::after {
    content: "";
    position: absolute;
    left: 50%;
    width: 8px;
    height: 8px;
    background: #0d1b2a;
    transform: translateX(-50%) rotate(45deg);
}
.tt.tt-bottom::after {
    top: -4px;
}
.tt.tt-top::after {
    bottom: -4px;
}

/* Mobile — reduced motion */
@media (prefers-reduced-motion: reduce) {
    .tt {
        transition: opacity .1s ease;
        transform: none;
    }
}


/* -- Table -- */
