/* ============================================================
   EDC MONITOR - Design System
   Tema: Panel kontrol transaksi (technical, precise, data-dense)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    /* Warna dasar */
    --bg-app: #F4F5F7;
    --bg-panel: #FFFFFF;
    --bg-panel-alt: #FAFBFC;
    --bg-sidebar: #14171C;
    --border-soft: #E2E5EA;
    --border-strong: #C9CDD4;

    --text-primary: #14171C;
    --text-secondary: #5C6370;
    --text-muted: #9098A3;
    --text-on-dark: #E8EAED;
    --text-on-dark-muted: #8B92A0;

    /* Aksen sumber data -- konsisten di seluruh UI */
    --accent-mpn: #2563EB;
    --accent-mpn-soft: #EAF1FF;
    --accent-mpn-border: #BFD6FF;

    --accent-miniatm: #EA580C;
    --accent-miniatm-soft: #FFF0E6;
    --accent-miniatm-border: #FFCCA8;

    /* Status */
    --status-success: #16A34A;
    --status-success-soft: #EAFBF1;
    --status-danger: #DC2626;
    --status-danger-soft: #FEECEC;
    --status-warning: #D97706;
    --status-warning-soft: #FEF3E2;

    /* Tipografi */
    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Layout */
    --sidebar-width: 248px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-card: 0 1px 2px rgba(20, 23, 28, 0.04), 0 1px 1px rgba(20, 23, 28, 0.03);
    --shadow-pop: 0 8px 24px rgba(20, 23, 28, 0.12);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg-app);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

a { color: inherit; text-decoration: none; }

button { font-family: var(--font-body); }

/* Focus visibility (accessibility) */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
    outline: 2px solid var(--accent-mpn);
    outline-offset: 2px;
}

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

/* ------------------------------------------------------------
   APP SHELL
   ------------------------------------------------------------ */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.2s ease;
}

.sidebar-brand {
    padding: 22px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand .mark {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent-mpn), var(--accent-miniatm));
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 13px;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-brand .name {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 15px;
    color: var(--text-on-dark);
    line-height: 1.2;
}

.sidebar-brand .sub {
    font-size: 11px;
    color: var(--text-on-dark-muted);
    font-family: var(--font-mono);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-section-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-on-dark-muted);
    padding: 8px 12px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-on-dark-muted);
    font-size: 13.5px;
    font-weight: 500;
    margin-bottom: 2px;
    transition: background 0.12s ease, color 0.12s ease;
}

.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }

.nav-item:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text-on-dark);
}

.nav-item.active {
    background: rgba(37, 99, 235, 0.18);
    color: #fff;
}

.nav-item.active svg { color: var(--accent-mpn); }

.sidebar-footer {
    padding: 14px 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
}

.user-chip .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-panel-alt);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}

.user-chip .info { overflow: hidden; flex: 1; }
.user-chip .info .name {
    font-size: 13px; font-weight: 600; color: var(--text-on-dark);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-chip .info .role {
    font-size: 11px; color: var(--text-on-dark-muted); font-family: var(--font-mono); text-transform: uppercase;
}

.logout-btn {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    width: 100%; margin-top: 10px; padding: 8px;
    border-radius: var(--radius-sm); border: 1px solid rgba(255,255,255,0.12);
    background: transparent; color: var(--text-on-dark-muted); font-size: 12.5px; font-weight: 500;
    cursor: pointer; transition: all 0.12s ease;
}
.logout-btn:hover { border-color: var(--status-danger); color: var(--status-danger); }

/* ------------------------------------------------------------
   MAIN CONTENT
   ------------------------------------------------------------ */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 64px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar .page-title {
    font-size: 18px;
}

.topbar .page-eyebrow {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.mobile-menu-btn { display: none; }

.content-area {
    padding: 28px;
    flex: 1;
}

/* ------------------------------------------------------------
   COMPONENTS
   ------------------------------------------------------------ */
.card {
    background: var(--bg-panel);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 { font-size: 14.5px; }

.card-body { padding: 20px; }

/* Source tag -- signature element: konsisten membedakan MPN vs MiniATM */
.src-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px 3px 7px;
    border-radius: 5px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}
.src-tag::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
}
.src-tag.mpn {
    background: var(--accent-mpn-soft);
    color: var(--accent-mpn);
    border: 1px solid var(--accent-mpn-border);
}
.src-tag.mpn::before { background: var(--accent-mpn); }
.src-tag.miniatm {
    background: var(--accent-miniatm-soft);
    color: var(--accent-miniatm);
    border: 1px solid var(--accent-miniatm-border);
}
.src-tag.miniatm::before { background: var(--accent-miniatm); }

/* Stat cards (Summary) */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-card .stat-value {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.stat-card .stat-sub {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 6px;
    font-family: var(--font-mono);
}

.stat-card .stat-icon {
    width: 30px; height: 30px;
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
}
.stat-card .stat-icon svg { width: 16px; height: 16px; }

.stat-card.accent-blue .stat-icon { background: var(--accent-mpn-soft); color: var(--accent-mpn); }
.stat-card.accent-orange .stat-icon { background: var(--accent-miniatm-soft); color: var(--accent-miniatm); }
.stat-card.accent-green .stat-icon { background: var(--status-success-soft); color: var(--status-success); }
.stat-card.accent-neutral .stat-icon { background: var(--bg-panel-alt); color: var(--text-secondary); }

/* Form elements */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input, .form-select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-panel);
    color: var(--text-primary);
    font-size: 13.5px;
    font-family: var(--font-body);
    transition: border-color 0.12s ease;
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--accent-mpn);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-input.mono { font-family: var(--font-mono); }

.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row > .form-group { flex: 1; min-width: 160px; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.12s ease;
    font-family: var(--font-body);
    white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }

.btn-primary { background: var(--text-primary); color: #fff; }
.btn-primary:hover { background: #2A2E36; }

.btn-accent-mpn { background: var(--accent-mpn); color: #fff; }
.btn-accent-mpn:hover { background: #1D4ED8; }

.btn-accent-miniatm { background: var(--accent-miniatm); color: #fff; }
.btn-accent-miniatm:hover { background: #C2410C; }

.btn-secondary {
    background: var(--bg-panel);
    color: var(--text-primary);
    border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--bg-panel-alt); border-color: var(--text-muted); }

.btn-danger { background: var(--status-danger); color: #fff; }
.btn-danger:hover { background: #B91C1C; }

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-panel-alt); color: var(--text-primary); }

.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 600;
}
.badge.role-admin { background: var(--accent-mpn-soft); color: var(--accent-mpn); }
.badge.role-viewer { background: var(--bg-panel-alt); color: var(--text-secondary); }
.badge.status-active { background: var(--status-success-soft); color: var(--status-success); }
.badge.status-inactive { background: var(--status-danger-soft); color: var(--status-danger); }

/* Table */
.table-wrap { overflow-x: auto; }
table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table.data-table th {
    text-align: left;
    padding: 10px 14px;
    background: var(--bg-panel-alt);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid var(--border-soft);
    white-space: nowrap;
    position: sticky;
    top: 0;
}
table.data-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-soft);
    color: var(--text-primary);
    white-space: nowrap;
}
table.data-table tbody tr:hover { background: var(--bg-panel-alt); }
table.data-table .mono { font-family: var(--font-mono); font-size: 12.5px; }
table.data-table .num { text-align: right; font-family: var(--font-mono); }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 56px 24px;
    color: var(--text-muted);
}
.empty-state svg { width: 40px; height: 40px; margin-bottom: 12px; color: var(--border-strong); }
.empty-state .title { font-family: var(--font-display); font-size: 15px; color: var(--text-secondary); margin-bottom: 4px; font-weight: 600; }
.empty-state .desc { font-size: 13px; }

/* Pagination */
.pagination {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 20px; border-top: 1px solid var(--border-soft);
}
.pagination .info { font-size: 12.5px; color: var(--text-secondary); }
.pagination .pages { display: flex; gap: 4px; }
.pagination .page-btn {
    min-width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
    border-radius: 6px; font-size: 12.5px; font-weight: 500; color: var(--text-secondary);
    border: 1px solid var(--border-soft); background: var(--bg-panel); cursor: pointer;
}
.pagination .page-btn.active { background: var(--text-primary); color: #fff; border-color: var(--text-primary); }
.pagination .page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Alert / flash message */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.alert svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }
.alert.alert-success { background: var(--status-success-soft); color: #0F6B33; }
.alert.alert-danger { background: var(--status-danger-soft); color: #A11919; }
.alert.alert-warning { background: var(--status-warning-soft); color: #92560A; }

/* Modal */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(20,23,28,0.45);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; padding: 20px;
}
.modal-box {
    background: var(--bg-panel); border-radius: var(--radius-lg);
    width: 100%; max-width: 460px; box-shadow: var(--shadow-pop);
    max-height: 90vh; overflow-y: auto;
}
.modal-header {
    padding: 18px 22px; border-bottom: 1px solid var(--border-soft);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-body { padding: 22px; }
.modal-footer {
    padding: 16px 22px; border-top: 1px solid var(--border-soft);
    display: flex; gap: 10px; justify-content: flex-end;
}

/* Checkbox / radio toggle for marking source (poin 3) */
.marker-toggle {
    display: inline-flex;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border-strong);
}
.marker-toggle button {
    border: none; background: var(--bg-panel); padding: 5px 10px;
    font-size: 11.5px; font-weight: 600; cursor: pointer; font-family: var(--font-mono);
}
.marker-toggle button.active.mpn { background: var(--accent-mpn); color: #fff; }
.marker-toggle button.active.miniatm { background: var(--accent-miniatm); color: #fff; }

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, var(--bg-panel-alt) 25%, var(--border-soft) 37%, var(--bg-panel-alt) 63%);
    background-size: 400% 100%;
    animation: skeleton-loading 1.4s ease infinite;
    border-radius: 4px;
}
@keyframes skeleton-loading {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

/* Responsive */
@media (max-width: 1024px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .mobile-menu-btn { display: flex; }
    .stat-grid { grid-template-columns: 1fr; }
    .content-area { padding: 16px; }
    .topbar { padding: 0 16px; }
}
