/* ==========================================================================
   MELSA CRM — Dashboard Design System
   Sidebar: deep teal-ink. Content: light canvas. Accent signature: "signal bars"
   (mengambil motif kekuatan sinyal jaringan — sesuai dunia survey coverage Melsa)
   ========================================================================== */

:root {
    /* --- Ink / Sidebar --- */
    --ink-950: #0F3D3E;
    --ink-900: #175455;
    --ink-800: #206A69;
    --ink-line: rgba(255, 255, 255, 0.10);
    --ink-text-dim: #8FD4CC;
    --ink-text-dimmer: #5AA39A;

    /* --- Brand teal --- */
    --teal-500: #0E9488;
    --teal-600: #0B786E;
    --teal-400: #2DD4BF;
    --teal-glow: #99F6E4;
    --mint-100: #ECFEFF;

    /* --- Canvas / surfaces --- */
    --canvas: #F2F9F8;
    --card-bg: #FFFFFF;
    --border-color: rgba(15, 61, 62, 0.09);
    --border-strong: rgba(15, 61, 62, 0.16);

    /* --- Text --- */
    --ink-text: #0F2C2B;
    --text-main: #0F2C2B;
    --text-muted: #5D7C79;
    --text-faint: #92AFAC;

    /* --- Status --- */
    --amber-bg: #FEF3C7; --amber-text: #92400E;
    --green-bg: #DCFCE7; --green-text: #166534;
    --red-bg: #FEE2E2;   --red-text: #991B1B;

    /* --- Layout --- */
    --sidebar-w: 264px;
    --topbar-h: 72px;
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow-card: 0 1px 2px rgba(13, 40, 38, 0.04), 0 8px 24px -12px rgba(13, 40, 38, 0.08);
    --shadow-card-hover: 0 16px 32px -12px rgba(13, 40, 38, 0.16);
}

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

html, body {
    background-color: var(--canvas);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .font-display { font-family: 'Space Grotesk', sans-serif; letter-spacing: -0.01em; }
.font-mono { font-family: 'JetBrains Mono', monospace; }

a { color: inherit; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(15,43,42,0.18); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(15,43,42,0.3); }

/* ==========================================================================
   Signal-bars signature mark
   ========================================================================== */
.signal-mark { display: inline-flex; align-items: flex-end; gap: 3px; height: 18px; }
.signal-mark span {
    width: 4px; border-radius: 2px;
    background: linear-gradient(180deg, var(--teal-glow), var(--teal-400));
}
.signal-mark span:nth-child(1) { height: 6px; }
.signal-mark span:nth-child(2) { height: 10px; }
.signal-mark span:nth-child(3) { height: 14px; }
.signal-mark span:nth-child(4) { height: 18px; }

/* ==========================================================================
   App shell: sidebar + topbar + main
   ========================================================================== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w); flex-shrink: 0;
    background: linear-gradient(185deg, var(--ink-950) 0%, var(--ink-900) 100%);
    color: #DCEEEC;
    display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
    transition: transform 0.25s ease;
}

.sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 24px 22px 20px; text-decoration: none;
    border-bottom: 1px solid var(--ink-line);
}
.sidebar-brand img { width: 38px; height: 38px; border-radius: 10px; object-fit: cover; flex-shrink: 0; }
.sidebar-brand .brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.sidebar-brand .brand-name { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 16.5px; color: #FFFFFF; }
.sidebar-brand .brand-sub { font-size: 11px; color: var(--ink-text-dim); font-weight: 500; letter-spacing: 0.03em; margin-top: 1px; }

.sidebar-nav { flex: 1; padding: 20px 14px; overflow-y: auto; }
.nav-group { margin-bottom: 22px; }
.nav-group-label {
    font-size: 10.5px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase;
    color: var(--ink-text-dimmer); padding: 0 12px 8px;
}
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; margin-bottom: 2px; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 500; color: #B9D6D2; text-decoration: none;
    transition: background 0.15s, color 0.15s; position: relative;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
.nav-item:hover:not(.is-disabled) { background: var(--ink-800); color: #FFFFFF; }
.nav-item.is-active { background: var(--ink-800); color: #FFFFFF; }
.nav-item.is-active::before {
    content: ""; position: absolute; left: -14px; top: 50%; transform: translateY(-50%);
    width: 3px; height: 18px; border-radius: 2px;
    background: linear-gradient(180deg, var(--teal-glow), var(--teal-400));
}
.nav-item.is-active svg { opacity: 1; color: var(--teal-glow); }
.nav-item.is-disabled { color: var(--ink-text-dimmer); cursor: default; }
.nav-badge {
    margin-left: auto; font-size: 9.5px; font-weight: 700; letter-spacing: 0.03em;
    padding: 3px 7px; border-radius: 999px; background: var(--ink-800); color: var(--ink-text-dim);
    text-transform: uppercase; white-space: nowrap;
}

.sidebar-footer {
    padding: 18px 22px 22px; border-top: 1px solid var(--ink-line);
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.sidebar-footer .footer-label { font-size: 12px; color: var(--ink-text-dim); font-weight: 500; line-height: 1.4; min-width: 0; }
.sidebar-footer .footer-label strong { display: block; color: #E4F5F3; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-logout {
    flex-shrink: 0; width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--ink-line);
    background: transparent; color: var(--ink-text-dim); display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: background 0.15s, color 0.15s;
}
.btn-logout:hover { background: var(--ink-800); color: #FCA5A5; }
.btn-logout svg { width: 15px; height: 15px; }

.sidebar-close-btn { display: none; }

/* ==========================================================================
   Main column: topbar + content
   ========================================================================== */
.main-col { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }

.topbar {
    height: var(--topbar-h); flex-shrink: 0;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 32px; background: rgba(243, 247, 246, 0.85);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    position: sticky; top: 0; z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar-title { font-size: 18px; font-weight: 700; color: var(--text-main); }
.topbar-eyebrow { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.hamburger {
    display: none; width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--border-color);
    background: var(--card-bg); align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
}
.topbar-team {
    display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 6px;
    border-radius: 999px; border: 1px solid var(--border-color); background: var(--card-bg);
}
.topbar-team .avatar {
    width: 30px; height: 30px; border-radius: 999px; background: var(--mint-100); color: var(--teal-600);
    display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; font-family: 'Space Grotesk', sans-serif;
}
.topbar-team .team-name { font-size: 13px; font-weight: 600; color: var(--text-main); }
.topbar-team .team-role { font-size: 11px; color: var(--text-muted); }

.content { padding: 32px; max-width: 1400px; width: 100%; }

.sidebar-scrim { display: none; }

/* ==========================================================================
   Shared components
   ========================================================================== */
.btn-primary {
    background: var(--teal-500); color: white; padding: 12px 22px; border: none; border-radius: var(--radius-sm);
    font-weight: 600; font-size: 14px; cursor: pointer; transition: background 0.15s, transform 0.1s;
    font-family: 'Inter', sans-serif;
}
.btn-primary:hover { background: var(--teal-600); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--card-bg); color: var(--text-main); padding: 11px 16px; border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); font-weight: 500; font-size: 13.5px; cursor: pointer; transition: border-color 0.15s, color 0.15s;
    font-family: 'Inter', sans-serif;
}
.btn-secondary svg { width: 15px; height: 15px; flex-shrink: 0; }
.btn-secondary:hover { border-color: var(--teal-400); color: var(--teal-600); }
.btn-secondary:disabled { opacity: 0.6; cursor: default; pointer-events: none; }

.import-summary-list { max-height: 260px; overflow-y: auto; border: 1px solid var(--border-color); border-radius: var(--radius-sm); margin-top: 12px; }
.import-summary-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; font-size: 12.5px; border-bottom: 1px solid var(--border-color); }
.import-summary-row:last-child { border-bottom: none; }
.import-summary-row .baris-no { font-family: 'JetBrains Mono', monospace; color: var(--text-muted); flex-shrink: 0; }
.import-summary-row .pesan { color: var(--red-text); text-align: right; }

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

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 960px) {
    .sidebar { transform: translateX(-100%); box-shadow: 24px 0 48px rgba(0,0,0,0.25); }
    .sidebar.is-open { transform: translateX(0); }
    .sidebar-close-btn {
        display: flex; align-items: center; justify-content: center; margin-left: auto;
        width: 30px; height: 30px; border-radius: 8px; border: none; background: var(--ink-800); color: #DCEEEC; cursor: pointer;
    }
    .main-col { margin-left: 0; }
    .hamburger { display: flex; }
    .content { padding: 20px; }
    .topbar { padding: 0 18px; }
    .topbar-team .team-name, .topbar-team .team-role { display: none; }
    .sidebar-scrim {
        display: none; position: fixed; inset: 0; background: rgba(11, 36, 35, 0.45); z-index: 90;
    }
    .sidebar-scrim.is-visible { display: block; }
}

/* ==========================================================================
   Footer copyright (disuntikkan otomatis lewat sidebar.js ke semua halaman)
   ========================================================================== */
.app-footer {
    padding: 18px 32px; text-align: center; font-size: 12px; color: var(--text-faint);
    border-top: 1px solid var(--border-color); margin-top: auto; line-height: 1.6;
}
.app-footer-credit { font-size: 11px; opacity: 0.75; }
@media (max-width: 960px) { .app-footer { padding: 16px 20px; } }
