:root {
    --navy: #0a2558;
    --navy-2: #12357a;
    --blue: #1d6bf3;
    --blue-dark: #1556c6;
    --green: #16a34a;
    --red: #dc2626;
    --ink: #14213d;
    --muted: #6b7a99;
    --bg: #f2f5fa;
    --card: #ffffff;
    --line: #e3e9f3;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(10, 37, 88, .06), 0 6px 18px rgba(10, 37, 88, .06);
    --sidebar-w: 260px;
}

body {
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
}

.text-muted { color: var(--muted) !important; }

/* ---------- Tombol ---------- */
.btn-primary {
    --bs-btn-bg: var(--blue);
    --bs-btn-border-color: var(--blue);
    --bs-btn-hover-bg: var(--blue-dark);
    --bs-btn-hover-border-color: var(--blue-dark);
    --bs-btn-active-bg: var(--blue-dark);
    --bs-btn-active-border-color: var(--blue-dark);
    --bs-btn-disabled-bg: var(--blue);
    --bs-btn-disabled-border-color: var(--blue);
    font-weight: 600;
    border-radius: 10px;
}
.btn-start { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; border-radius: 10px; }
.btn-start:hover { background: #12853c; border-color: #12853c; color: #fff; }
.btn-stop { background: var(--red); border-color: var(--red); color: #fff; font-weight: 600; border-radius: 10px; }
.btn-stop:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }

.form-control, .form-select, .input-group-text { border-color: var(--line); }
.form-control:focus, .form-select:focus { border-color: var(--blue); box-shadow: 0 0 0 .2rem rgba(29, 107, 243, .15); }
.input-group-text { background: #f8fafd; color: var(--muted); }

/* ---------- Kerangka aplikasi ---------- */
.app-shell { display: flex; min-height: 100vh; }
.app-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.app-content { padding: 1.5rem; flex: 1 1 auto; }

.card-ui {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.page-head { margin-bottom: 1.25rem; }
.page-title { font-size: 1.4rem; font-weight: 700; margin: 0; }
.page-subtitle { color: var(--muted); margin: .25rem 0 0; }

/* ---------- Sidebar (offcanvas di layar kecil) ---------- */
.app-sidebar {
    --bs-offcanvas-width: var(--sidebar-w);
    --bs-offcanvas-bg: var(--navy);
    --bs-offcanvas-color: #fff;
    --bs-offcanvas-border-width: 0;
    background: var(--navy);
    color: #fff;
}

@media (min-width: 992px) {
    .app-sidebar.offcanvas {
        position: sticky !important;
        top: 0;
        bottom: auto;
        height: 100vh;
        flex: 0 0 var(--sidebar-w);
        width: var(--sidebar-w);
        visibility: visible !important;
        transform: none !important;
        transition: none;
    }
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sidebar-brand-icon { height: 38px; width: auto; flex-shrink: 0; }
.sidebar-brand-text { height: 22px; width: auto; max-width: 100%; min-width: 0; }

.sidebar-nav { padding: 1rem .75rem; overflow-y: auto; }
.sidebar-nav .nav-link {
    display: flex; align-items: center; gap: .75rem;
    color: rgba(255, 255, 255, .78);
    padding: .65rem .9rem;
    border-radius: 10px;
    font-size: .92rem;
    margin-bottom: .2rem;
}
.sidebar-nav .nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--blue); color: #fff; font-weight: 600; }
.sidebar-nav .nav-link.disabled { opacity: .45; cursor: not-allowed; pointer-events: auto; }
.sidebar-nav .nav-link.disabled:hover { background: transparent; color: rgba(255, 255, 255, .78); }
.sidebar-nav .nav-link i { font-size: 1.05rem; width: 1.25rem; text-align: center; }

.sidebar-user {
    display: flex; align-items: center; gap: .75rem;
    padding: .9rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, .08);
}
.sidebar-user-info { min-width: 0; }
.sidebar-user .name { font-weight: 600; font-size: .9rem; }
.sidebar-user .role { font-size: .78rem; color: rgba(255, 255, 255, .65); }

.btn-logout {
    background: transparent; color: rgba(255, 255, 255, .85);
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 10px; padding: .55rem .9rem; font-size: .9rem;
}
.btn-logout:hover { background: rgba(255, 255, 255, .08); color: #fff; }

.avatar {
    width: 38px; height: 38px; flex: 0 0 38px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: #dbe7ff; color: var(--navy);
    font-weight: 700; font-size: .85rem;
}
.avatar-sm { width: 34px; height: 34px; flex-basis: 34px; font-size: .8rem; }

/* ---------- Topbar ---------- */
.app-topbar {
    display: flex; align-items: center; gap: 1rem;
    background: #fff;
    border-bottom: 1px solid var(--line);
    padding: .75rem 1.5rem;
    position: sticky; top: 0; z-index: 100;
}
.topbar-date { color: var(--muted); font-size: .88rem; }
.topbar-user { display: flex; align-items: center; gap: .6rem; }
.topbar-user-name { max-width: 200px; }

/* ---------- Login ---------- */
.login-body { background: #fff; }
.login-wrap { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
.login-brand {
    background: linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 100%);
    color: #fff;
    display: flex; flex-direction: column; justify-content: space-between;
    padding: 3rem;
    position: relative; overflow: hidden;
}
/* Motif batik tipis di atas latar biru */
.login-brand::before {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: url('../img/motif-batik.png') center / cover no-repeat;
    opacity: .10;
}
.login-brand > * { position: relative; z-index: 1; }
.login-brand-inner { margin: auto 0; text-align: center; }
.login-logo { display: inline-block; margin-bottom: 1.5rem; }
.login-logo img { display: block; width: 260px; max-width: 100%; height: auto; }
.login-brand h1 { font-size: 1.7rem; font-weight: 700; margin-bottom: .35rem; }
.login-brand p { margin: 0; color: rgba(255, 255, 255, .8); }
.login-tagline { text-align: center; font-size: .85rem; }
.login-form-side { display: flex; align-items: center; justify-content: center; padding: 2rem; background: #fff; }
.login-form-box { width: 100%; max-width: 380px; }
.login-form-box h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: .25rem; }
.login-copy { text-align: center; color: var(--muted); font-size: .8rem; margin: 2rem 0 0; }

.forbidden-icon { font-size: 2.6rem; color: var(--red); }

@media (max-width: 767.98px) {
    .login-wrap { grid-template-columns: 1fr; }
    .login-brand { padding: 2rem 1.5rem; min-height: 38vh; }
    .app-content { padding: 1rem; }
    .app-topbar { padding: .6rem 1rem; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* =====================================================================
   PHASE 2 - Dashboard, timer, tabel, modal
   ===================================================================== */
.stat-card { display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1.25rem; }
.stat-icon {
    width: 48px; height: 48px; flex: 0 0 48px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.3rem;
}
.stat-icon-blue { background: #e4eeff; color: var(--blue); }
.stat-icon-green { background: #dcf5e6; color: var(--green); }
.stat-label { color: var(--muted); font-size: .85rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.25; }

.card-ui-head { padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.card-ui-foot {
    display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between;
    padding: .9rem 1.25rem; border-top: 1px solid var(--line);
}

.table-ui { --bs-table-bg: transparent; }
.table-ui thead th {
    background: #f8fafd; color: var(--muted); font-size: .8rem; font-weight: 600;
    border-bottom: 1px solid var(--line); padding: .75rem 1.25rem; white-space: nowrap;
}
.table-ui tbody td { padding: .8rem 1.25rem; border-color: var(--line); font-size: .92rem; }
.table-ui tbody tr:last-child td { border-bottom: 0; }

.badge-soft {
    display: inline-block; padding: .2rem .65rem; border-radius: 999px;
    background: #e4eeff; color: var(--blue-dark); font-size: .8rem; font-weight: 600;
}

.empty-state { padding: 3rem 1rem; text-align: center; color: var(--muted); }
.empty-state i { display: block; font-size: 2.2rem; margin-bottom: .5rem; opacity: .6; }

.pagination .page-link { color: var(--blue); border-color: var(--line); }
.pagination .active > .page-link { background: var(--blue); border-color: var(--blue); color: #fff; }

/* Timer */
.timer-card { max-width: 640px; }
.timer-panel {
    border: 1px solid var(--line); border-radius: var(--radius);
    background: #f8fafd; text-align: center; padding: 1.5rem 1rem;
    transition: border-color .2s, background .2s;
}
.timer-panel.is-running { border-color: #b7e4c7; background: #f1fbf5; }
.timer-display {
    font-size: 3.2rem; font-weight: 700; letter-spacing: .04em; line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.timer-status { color: var(--muted); font-weight: 600; margin-top: .25rem; }
.timer-panel.is-running .timer-status { color: var(--green); }

.info-box {
    display: flex; gap: .75rem; align-items: flex-start;
    background: #eef4ff; border: 1px solid #d6e4ff; border-radius: 12px;
    padding: .85rem 1rem; font-size: .9rem;
}
.info-box i { margin-top: .15rem; }

/* Modal detail */
.modal-ui { border: 0; border-radius: var(--radius); box-shadow: var(--shadow); }
.modal-ui .modal-header, .modal-ui .modal-footer { border-color: var(--line); }
.detail-list dt { color: var(--muted); font-weight: 500; font-size: .82rem; margin-top: .75rem; }
.detail-list dt:first-child { margin-top: 0; }
.detail-list dd { margin: 0; font-weight: 600; }
.detail-box { border: 1px solid var(--line); border-radius: 12px; padding: .9rem 1rem; background: #f8fafd; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 1.1rem; position: relative; }
.timeline::before { content: ""; position: absolute; left: 4px; top: 8px; bottom: 8px; width: 2px; background: #c9d8f5; }
.timeline li { position: relative; display: flex; gap: .75rem; padding: .3rem 0; }
.timeline li::before {
    content: ""; position: absolute; left: -1.1rem; top: .65rem;
    width: 10px; height: 10px; border-radius: 50%; background: var(--blue);
}
.timeline-time { font-weight: 700; min-width: 3rem; font-variant-numeric: tabular-nums; }

/* =====================================================================
   REVISI PHASE 2 - grafik kategori & tabel ringkasan di Input Layanan
   ===================================================================== */
.timer-card { max-width: none; }

.chart-box { position: relative; height: 240px; }

.category-legend { list-style: none; margin: 0; padding: 0; }
.category-legend li {
    display: flex; align-items: center; gap: .75rem;
    padding: .7rem 0; border-bottom: 1px solid var(--line);
}
.category-legend li:last-child { border-bottom: 0; }
.legend-dot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 12px; }
.legend-name { flex: 1 1 auto; font-weight: 600; min-width: 0; }
.legend-meta { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.3; font-size: .9rem; }
.legend-meta .text-muted { font-size: .8rem; }

.table-compact thead th, .table-compact tbody td { padding: .7rem .85rem; }

/* Tombol Detail pada legenda kategori & modal rincian */
.btn-category-detail { flex: 0 0 auto; }

/* =====================================================================
   PHASE 3 - Admin: badge, ikon konfirmasi, modal
   ===================================================================== */
.badge-status, .badge-role, .badge-action {
    display: inline-block; padding: .2rem .65rem; border-radius: 999px;
    font-size: .78rem; font-weight: 600; white-space: nowrap;
}
.badge-status-active { background: #dcf5e6; color: #11743a; }
.badge-status-inactive { background: #fde6e6; color: #b42323; }
.badge-role-admin { background: #ece6fb; color: #5b34b8; }
.badge-role-pj { background: #ece6fb; color: #5b34b8; }
.badge-role-cs { background: #e4eeff; color: var(--blue-dark); }
.badge-role-teller { background: #fff1d9; color: #a35c00; }
.badge-action-create { background: #dcf5e6; color: #11743a; }
.badge-action-update { background: #e4eeff; color: var(--blue-dark); }
.badge-action-delete { background: #fde6e6; color: #b42323; }

.confirm-icon {
    width: 56px; height: 56px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.6rem;
}
.confirm-icon-danger { background: #fde6e6; color: var(--red); }
.confirm-icon-warning { background: #fff1d9; color: #d97706; }

.duration-preview {
    border: 1px solid var(--line); border-radius: 8px; background: #f8fafd;
    padding: .45rem .75rem; font-weight: 600;
}
