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

* , *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Warna dasar */
    --bg-app:        #F3F6FB;   /* background utama, biru sangat pucat */
    --bg-surface:     #FFFFFF;   /* card, sidebar, topbar */
    --bg-surface-2:   #F8FAFD;   /* hover state, zebra row */
    --bg-sidebar:     #0E1F3D;   /* sidebar gelap kontras dgn konten terang */

    /* Biru kerja (bukan dekorasi) */
    --blue-900:  #0E1F3D;
    --blue-700:  #14438C;
    --blue-600:  #1A56C4;
    --blue-500:  #2E6FE0;
    --blue-100:  #E3ECFB;
    --blue-50:   #EFF4FD;

    /* Status (untuk badge label/kategori) */
    --green-600: #15803D;
    --green-100: #DCFCE7;
    --red-600:   #C0291A;
    --red-100:   #FCE4E1;
    --amber-600: #B45309;
    --amber-100: #FEF3C7;

    /* Teks */
    --text-primary:   #0F1A2E;
    --text-secondary: #4B5A75;
    --text-muted:     #8696B0;
    --text-on-dark:   #E8EEFB;
    --text-on-dark-muted: #8DA0C4;

    /* Border */
    --border:       #E1E8F3;
    --border-strong: #C7D4E8;

    /* Font */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Courier New', monospace;

    /* Layout */
    --sidebar-w: 248px;
    --topbar-h:  64px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-card: 0 1px 2px rgba(15, 26, 46, 0.04), 0 1px 8px rgba(15, 26, 46, 0.04);
    --shadow-pop:  0 8px 24px rgba(15, 26, 46, 0.12);
}

html, body {
    height: 100%;
}

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

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
ul { list-style: none; }

/* angka & data teknis pakai monospace supaya terasa presisi */
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* App Shell */

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

/* Sidebar */

.sidebar {
    background: var(--bg-sidebar);
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px 22px;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(232, 238, 251, 0.1);
}

.sidebar-brand img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.sidebar-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.sidebar-brand-text strong {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-on-dark);
    letter-spacing: -0.01em;
}

.sidebar-brand-text span {
    font-size: 10.5px;
    color: var(--text-on-dark-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.sidebar-section-label {
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-on-dark-muted);
    padding: 16px 10px 6px;
}

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

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

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

.nav-item.active {
    background: var(--blue-600);
    color: #fff;
}

.nav-item.active svg { opacity: 1; }

.nav-item .nav-badge {
    margin-left: auto;
    background: var(--red-600);
    color: #fff;
    font-size: 10.5px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 999px;
    font-family: var(--font-mono);
}

.sidebar-footer {
    border-top: 1px solid rgba(232, 238, 251, 0.1);
    padding-top: 12px;
    margin-top: 12px;
}

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

.sidebar-user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--blue-600);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    flex: 1;
    min-width: 0;
}

.sidebar-user-info strong {
    font-size: 13px;
    color: var(--text-on-dark);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user-info span {
    font-size: 11px;
    color: var(--text-on-dark-muted);
}

.btn-logout {
    width: 100%;
    margin-top: 8px;
    background: rgba(192, 41, 26, 0.12);
    color: #F2A39B;
    border: none;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.15s;
}

.btn-logout:hover {
    background: rgba(192, 41, 26, 0.22);
}

/* Main Content */

.main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

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

.topbar-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.topbar-subtitle {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: 1px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.live-dot {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--green-600);
    background: var(--green-100);
    padding: 5px 10px;
    border-radius: 999px;
}

.live-dot::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green-600);
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.35; }
}

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

/* Cards */

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
}

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

.card-header h3 {
    font-size: 13.5px;
    font-weight: 700;
}

.card-header-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 1px;
}

.card-body {
    padding: 20px;
}

/* Stat Cards */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

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

.stat-card-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
}

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

.stat-card-value.accent-red    { color: var(--red-600); }
.stat-card-value.accent-green  { color: var(--green-600); }
.stat-card-value.accent-blue   { color: var(--blue-600); }

.stat-card-icon {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--blue-50);
    color: var(--blue-600);
}

.stat-card-icon svg { width: 16px; height: 16px; }

/* Charts row */

.chart-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.chart-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

canvas { max-width: 100%; }

/* Tables */

.table-wrap {
    overflow-x: auto;
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table thead th {
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table thead th.sortable {
    cursor: pointer;
    user-select: none;
    transition: color 0.15s;
}

.data-table thead th.sortable:hover {
    color: var(--blue-600);
}

.data-table tbody td {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--text-secondary);
}

.data-table tbody tr:hover {
    background: var(--bg-surface-2);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.cell-primary {
    color: var(--text-primary);
    font-weight: 500;
}

.cell-mono {
    font-family: var(--font-mono);
    font-size: 12.5px;
    color: var(--text-secondary);
}

.cell-text-preview {
    max-width: 360px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Badges */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 999px;
    white-space: nowrap;
}

.badge-affiliate { background: var(--red-100);   color: var(--red-600); }
.badge-organic   { background: var(--green-100); color: var(--green-600); }
.badge-pending   { background: var(--amber-100); color: var(--amber-600); }
.badge-reviewed  { background: var(--green-100); color: var(--green-600); }
.badge-category  { background: var(--blue-100);  color: var(--blue-700); }
.badge-neutral   { background: var(--bg-surface-2); color: var(--text-secondary); border: 1px solid var(--border); }

/* Filters bar */

.filters-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.filter-select, .filter-input {
    background: var(--bg-app);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 12px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text-primary);
    min-width: 140px;
}

.filter-select:focus, .filter-input:focus {
    outline: none;
    border-color: var(--blue-500);
    background: #fff;
}

/* Buttons */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    border: 1px solid transparent;
    transition: all 0.15s;
}

.btn svg { width: 14px; height: 14px; }

.btn-primary {
    background: var(--blue-600);
    color: #fff;
}
.btn-primary:hover { background: var(--blue-700); }

.btn-outline {
    background: var(--bg-surface);
    border-color: var(--border-strong);
    color: var(--text-secondary);
}
.btn-outline:hover { border-color: var(--blue-500); color: var(--blue-600); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-surface-2); }

.btn-sm { padding: 5px 10px; font-size: 12px; }

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Pagination */

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
}

.pagination-info {
    font-size: 12.5px;
    color: var(--text-muted);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.page-indicator {
    font-size: 12.5px;
    font-family: var(--font-mono);
    color: var(--text-secondary);
    padding: 0 8px;
}

/* Modal */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(14, 31, 61, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
}

.modal-box {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-pop);
    max-width: 560px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 { font-size: 15px; font-weight: 700; }

.modal-body { padding: 22px; }

.modal-field { margin-bottom: 16px; }
.modal-field:last-child { margin-bottom: 0; }

.modal-field label {
    display: block;
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.modal-field-value {
    font-size: 13.5px;
    color: var(--text-primary);
    line-height: 1.6;
    background: var(--bg-app);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    word-break: break-word;
}

/* Empty state */

.empty-state {
    text-align: center;
    padding: 56px 20px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 40px;
    height: 40px;
    margin-bottom: 12px;
    opacity: 0.4;
}

.empty-state-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.empty-state-desc {
    font-size: 12.5px;
}

/* Toast */

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--text-primary);
    color: #fff;
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-pop);
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: toast-in 0.25s ease;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.toast.toast-error { background: var(--red-600); }
.toast.toast-success { background: var(--green-600); }

/* Loading skeleton */

.skeleton {
    background: linear-gradient(90deg, var(--bg-surface-2) 25%, var(--border) 50%, var(--bg-surface-2) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.4s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton-loading {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Auth page (login) */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 20% 20%, rgba(46, 111, 224, 0.08), transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(20, 67, 140, 0.06), transparent 40%),
        var(--bg-app);
    padding: 20px;
}

.auth-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-pop);
    width: 100%;
    max-width: 380px;
    padding: 36px 32px;
}

.auth-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}

.auth-logo img {
    width: 52px;
    height: 52px;
    object-fit: contain;
}

.auth-logo-text {
    text-align: center;
}

.auth-logo-text strong {
    display: block;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.auth-logo-text span {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.auth-field { margin-bottom: 16px; }

.auth-field label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.auth-field input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s;
}

.auth-field input:focus {
    outline: none;
    border-color: var(--blue-500);
    box-shadow: 0 0 0 3px var(--blue-50);
}

.password-input-wrap {
    position: relative;
}

.password-input-wrap input {
    padding-right: 42px; /* kasih ruang supaya teks tidak ketutupan ikon mata */
}

.password-toggle {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s;
}

.password-toggle:hover {
    color: var(--blue-600);
    background: var(--blue-50);
}

.password-toggle svg {
    width: 18px;
    height: 18px;
}

.auth-error {
    background: var(--red-100);
    color: var(--red-600);
    font-size: 12.5px;
    font-weight: 500;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    display: none;
}

.auth-error.visible { display: block; }

.auth-submit {
    width: 100%;
    background: var(--blue-600);
    color: #fff;
    border: none;
    padding: 11px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    margin-top: 6px;
    transition: background 0.15s;
}

.auth-submit:hover { background: var(--blue-700); }
.auth-submit:disabled { opacity: 0.6; cursor: not-allowed; }

.auth-footer {
    text-align: center;
    margin-top: 22px;
    font-size: 12px;
    color: var(--text-muted);
}

/* Responsive */

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

@media (max-width: 768px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { display: none; } /* sederhana untuk versi awal — mobile nav bisa ditambah nanti */
    .stat-grid { grid-template-columns: 1fr; }
}
