/* =========================================================
   KREASINDO AGENCY PORTAL — Sistem Desain
   Identitas: otoritas institusional (navy + brass) bertemu
   kejelasan operasional. Motif stempel resmi sebagai penanda
   khas, karena portal ini berbicara tentang legalitas & izin.
   ========================================================= */

/* ---------------- TOKENS ---------------- */
:root {
    /* Navy — kedalaman, otoritas, kepercayaan institusional */
    --navy-950: #0b1220;
    --navy-900: #101b32;
    --navy-800: #16253f;
    --navy-700: #1f3357;
    --navy-600: #2b4670;
    --navy-500: #3d5a8a;

    /* Brass — status resmi, legalitas, nilai premium (bukan emas dekoratif) */
    --brass-700: #8a6524;
    --brass-600: #a9812e;
    --brass-500: #c79a3d;
    --brass-400: #dab662;
    --brass-100: #f7efdd;

    /* Teal — pertumbuhan & ekspansi, pembeda dari sinyal "sukses" generik */
    --teal-700: #0a5346;
    --teal-600: #0e6b5c;
    --teal-100: #e3f5f0;

    /* Netral tinta, sedikit dingin agar selaras dengan navy */
    --ink-950: #0e1218;
    --ink-900: #151b26;
    --ink-700: #3c4453;
    --ink-500: #6b7385;
    --ink-300: #d5d9e1;
    --ink-150: #e9ebf0;
    --ink-100: #f3f4f7;
    --surface: #f8f8fa;
    --white: #ffffff;

    /* Semantik */
    --success: #0a6847;
    --success-bg: #e7f6ee;
    --success-border: #b7e4cc;
    --danger: #a3271f;
    --danger-bg: #fbeceb;
    --danger-border: #f0c4c0;
    --warning: #92590a;
    --warning-bg: #fbf1e0;
    --warning-border: #edcf9c;
    --info: #1c4f8c;
    --info-bg: #e9f1fb;
    --info-border: #bcd6f2;

    /* Tipografi */
    --font-display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;

    /* Skala & bentuk */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-pill: 100px;
    --shadow-flush: 0 1px 0 rgba(14,18,24,0.05);
    --shadow-raised: 0 8px 24px -8px rgba(11,18,32,0.18);
    --shadow-floating: 0 24px 64px -16px rgba(11,18,32,0.35);
    --ease-standard: cubic-bezier(0.2, 0.7, 0.3, 1);
}

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

/* ---------------- BASE ---------------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font-body);
    color: var(--ink-900);
    background: var(--surface);
    -webkit-font-smoothing: antialiased;
    font-size: 15px;
    line-height: 1.55;
}
a { color: var(--navy-700); text-decoration: none; }
a:hover { color: var(--brass-600); }
ul { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4 { margin: 0 0 8px 0; color: var(--ink-950); font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0 0 12px 0; color: var(--ink-700); }
code, .mono { font-family: 'SF Mono', 'Courier New', monospace; }

:focus-visible {
    outline: 2px solid var(--navy-600);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ---------------- LOGO RESMI ---------------- */
.logo-chip {
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--white);
    border-radius: var(--radius-md);
    padding: 12px 18px;
    box-shadow: var(--shadow-flush);
}
.brand-logo { display: inline-flex; align-items: center; }
.sidebar-brand { flex-wrap: wrap; row-gap: 10px; }
.sidebar-brand .logo-chip img { max-width: 150px; height: auto !important; max-height: 34px; }
.auth-side .logo-chip img { max-width: 220px; height: auto !important; max-height: 52px; }
.auth-brand .brand-logo img { max-width: 240px; height: auto !important; max-height: 48px; }

/* ---------------- MOTIF: SEGEL RESMI (aksen dekoratif) ---------------- */
.seal-mark { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.seal-mark svg { display: block; }
.seal-watermark {
    position: absolute; opacity: 0.15; pointer-events: none;
}

/* ---------------- POLA LATAR TERINSPIRASI PARANG (sangat halus) ---------------- */
.pattern-parang {
    background-image: repeating-linear-gradient(
        45deg,
        rgba(199,154,61,0.07) 0px, rgba(199,154,61,0.07) 1.5px,
        transparent 1.5px, transparent 26px
    );
}

/* ---------------- AUTH PAGES ---------------- */
.auth-body { background: var(--navy-950); min-height: 100vh; }
.auth-wrapper {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr 1fr;
}
.auth-side {
    background: linear-gradient(165deg, var(--navy-950) 0%, var(--navy-800) 78%, var(--navy-700) 100%);
    color: var(--white);
    padding: 64px 56px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}
.auth-side::before {
    content: '';
    position: absolute; inset: 0;
    background-image: repeating-linear-gradient(
        45deg,
        rgba(199,154,61,0.09) 0px, rgba(199,154,61,0.09) 1.5px,
        transparent 1.5px, transparent 30px
    );
    pointer-events: none;
}
.auth-side-top { position: relative; z-index: 1; animation: sealRise 0.7s var(--ease-standard) both; }
.auth-side-bottom { position: relative; z-index: 1; }
@keyframes sealRise {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}
.auth-eyebrow { font-size: 13px; color: var(--brass-400); font-weight: 600; margin-bottom: 22px; }
.auth-side h2 {
    color: var(--white);
    font-size: clamp(28px, 3.4vw, 40px);
    line-height: 1.15;
    max-width: 15ch;
    margin-bottom: 18px;
}
.auth-side p { color: rgba(255,255,255,0.68); font-size: 15px; max-width: 42ch; margin-bottom: 0; }
.feature-list { margin-top: 36px; display: flex; flex-direction: column; gap: 0; }
.feature-list li {
    padding: 16px 0;
    border-top: 1px solid rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.88);
    font-size: 14.5px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.feature-list li:last-child { border-bottom: 1px solid rgba(255,255,255,0.12); }
.auth-side-footer { position: relative; z-index: 1; font-size: 12.5px; color: rgba(255,255,255,0.4); margin-top: 40px; }

.auth-body-panel {
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
}
.auth-card { width: 100%; max-width: 400px; }
.auth-card-wide { max-width: 560px; }
.auth-brand { margin-bottom: 32px; }
.auth-brand .seal-mark { margin-bottom: 18px; }
.auth-brand h1 { font-size: 24px; margin-bottom: 4px; }
.auth-brand p { color: var(--ink-500); font-size: 14px; margin: 0; }
.auth-form .form-group { margin-bottom: 18px; }
.auth-footer { text-align: center; margin-top: 24px; font-size: 14px; color: var(--ink-500); }

@media (max-width: 900px) {
    .auth-wrapper { grid-template-columns: 1fr; }
    .auth-side { display: none; }
}

/* ---------------- FORM ELEMENTS ---------------- */
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-700); margin-bottom: 7px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=tel], input[type=file],
select, textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--ink-300);
    border-radius: var(--radius-sm);
    font-size: 14.5px;
    font-family: inherit;
    background: var(--white);
    color: var(--ink-900);
    transition: border-color 0.15s var(--ease-standard), box-shadow 0.15s var(--ease-standard);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--navy-600);
    box-shadow: 0 0 0 4px rgba(43,70,112,0.10);
}
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
input[type=checkbox] { width: auto; }

.segmented-control { display: flex; border: 1.5px solid var(--ink-300); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 22px; }
.segment { flex: 1; text-align: center; padding: 13px; font-size: 14px; font-weight: 600; cursor: pointer; color: var(--ink-500); border-right: 1.5px solid var(--ink-300); transition: 0.15s var(--ease-standard); }
.segment:last-child { border-right: none; }
.segment input { display: none; }
.segment.active { background: var(--navy-900); color: var(--white); }

/* ---------------- BUTTONS ---------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 11px 20px;
    border: 1.5px solid transparent; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 600; cursor: pointer;
    text-decoration: none; transition: 0.15s var(--ease-standard);
    font-family: inherit;
}
.btn-primary { background: var(--navy-900); color: var(--white); border-color: var(--navy-900); }
.btn-primary:hover { background: var(--navy-700); border-color: var(--navy-700); color: var(--white); }
.btn-gold { background: var(--brass-500); color: var(--navy-950); border-color: var(--brass-500); font-weight: 700; }
.btn-gold:hover { background: var(--brass-400); border-color: var(--brass-400); }
.btn-outline { background: var(--white); border-color: var(--ink-300); color: var(--ink-700); }
.btn-outline:hover { border-color: var(--navy-600); color: var(--navy-700); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.btn-danger:hover { background: #f6dad8; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------------- ALERTS ---------------- */
.alert { padding: 13px 16px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 18px; border: 1.5px solid transparent; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.alert-danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); }
.alert-info { background: var(--info-bg); color: var(--info); border-color: var(--info-border); }

/* ---------------- BADGES ---------------- */
.badge { display: inline-block; padding: 3px 11px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 600; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-neutral { background: var(--ink-100); color: var(--ink-700); }

/* ---------------- APP SHELL ---------------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 264px; background: var(--navy-950); color: var(--white);
    display: flex; flex-direction: column; flex-shrink: 0;
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 100;
    transition: transform 0.25s var(--ease-standard);
}
.sidebar-brand {
    display: flex; align-items: center; gap: 13px; padding: 24px 22px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    position: relative; overflow: hidden;
}
.sidebar-brand::before {
    content: '';
    position: absolute; inset: 0;
    background-image: repeating-linear-gradient(45deg, rgba(199,154,61,0.06) 0px, rgba(199,154,61,0.06) 1.5px, transparent 1.5px, transparent 22px);
    pointer-events: none;
}
.brand-title { font-family: var(--font-display); font-weight: 600; font-size: 15.5px; color: var(--white); position: relative; z-index: 1; }
.brand-subtitle { font-size: 12px; color: rgba(255,255,255,0.48); position: relative; z-index: 1; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 18px 12px; }
.nav-section-title { font-size: 11.5px; color: rgba(255,255,255,0.4); padding: 20px 12px 8px 12px; font-weight: 600; }
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 12px; border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.72); font-size: 14px; font-weight: 500;
    margin-bottom: 2px; transition: 0.12s var(--ease-standard);
    border-left: 2px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,0.055); color: var(--white); }
.nav-item.active { background: rgba(199,154,61,0.14); color: var(--brass-400); font-weight: 600; border-left-color: var(--brass-500); }
.nav-icon { width: 20px; text-align: center; }
.sidebar-footer { padding: 16px 12px; border-top: 1px solid rgba(255,255,255,0.08); }
.nav-logout { color: rgba(255,255,255,0.55); }
.sidebar-overlay { display: none; }

.app-main { flex: 1; margin-left: 264px; display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
    display: flex; align-items: center; gap: 16px;
    background: var(--white); border-bottom: 1px solid var(--ink-150);
    padding: 18px 32px; position: sticky; top: 0; z-index: 50;
}
.sidebar-toggle { display: none; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--ink-700); }
.topbar-title { font-family: var(--font-display); font-size: 19px; font-weight: 600; flex: 1; color: var(--ink-950); }
.topbar-user { display: flex; align-items: center; gap: 11px; }
.user-badge { font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: var(--radius-pill); background: var(--navy-900); color: var(--white); }
.user-badge.role-admin, .user-badge.role-staff { background: var(--brass-500); color: var(--navy-950); }
.user-name { font-size: 14px; font-weight: 600; color: var(--ink-900); }

.content-area { flex: 1; padding: 32px; max-width: 1320px; width: 100%; margin: 0 auto; }
.app-footer { text-align: center; padding: 20px; font-size: 12.5px; color: var(--ink-500); border-top: 1px solid var(--ink-150); }

/* ---------------- CARDS & GRID ---------------- */
.card { background: var(--white); border: 1px solid var(--ink-150); border-radius: var(--radius-md); padding: 24px; box-shadow: var(--shadow-flush); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.card-header h3 { margin: 0; font-size: 16.5px; font-weight: 600; }
.grid { display: grid; gap: 20px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1024px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } .form-row { grid-template-columns: 1fr; } }

/* Kartu statistik: aksen garis kiri, bukan bayangan generik */
.stat-card {
    display: flex; flex-direction: column; gap: 5px;
    border-left: 3px solid var(--brass-500);
    box-shadow: none;
}
.stat-value { font-family: var(--font-display); font-size: 32px; font-weight: 600; color: var(--navy-900); line-height: 1; }
.stat-label { font-size: 13px; color: var(--ink-500); font-weight: 500; margin-top: 2px; }
.stat-icon { font-size: 21px; margin-bottom: 6px; opacity: 0.85; }

/* ---------------- VISUAL PROGRESS TRACKER ---------------- */
.progress-bar-outer { background: var(--ink-100); border-radius: var(--radius-pill); height: 8px; overflow: hidden; }
.progress-bar-inner { background: linear-gradient(90deg, var(--brass-600), var(--brass-400)); height: 100%; border-radius: var(--radius-pill); transition: width 0.5s var(--ease-standard); }
.stage-timeline { position: relative; padding-left: 4px; }
.stage-item { display: flex; gap: 16px; position: relative; padding-bottom: 30px; }
.stage-item:last-child { padding-bottom: 0; }
.stage-item::before {
    content: ''; position: absolute; left: 15px; top: 34px; bottom: 0; width: 1.5px; background: var(--ink-300);
}
.stage-item:last-child::before { display: none; }
.stage-dot {
    width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; z-index: 1;
    background: var(--white); color: var(--ink-500); border: 2px solid var(--ink-300);
    font-family: var(--font-display);
}
.stage-item.completed .stage-dot { background: var(--teal-600); border-color: var(--teal-600); color: var(--white); }
.stage-item.in_progress .stage-dot { background: var(--brass-500); border-color: var(--brass-500); color: var(--navy-950); }
.stage-item.blocked .stage-dot { background: var(--danger); border-color: var(--danger); color: var(--white); }
.stage-content { flex: 1; padding-top: 4px; }
.stage-name { font-weight: 600; font-size: 14.5px; margin-bottom: 4px; color: var(--ink-950); }
.stage-meta { font-size: 12.5px; color: var(--ink-500); }
.stage-notes { font-size: 13px; color: var(--ink-700); margin-top: 8px; background: var(--ink-100); padding: 10px 13px; border-radius: var(--radius-sm); border-left: 2px solid var(--brass-500); }

/* ---------------- ANALITIK: BAR CHART CSS MURNI ---------------- */
.chart-bars { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 8px; }
.chart-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.chart-bar { width: 100%; max-width: 26px; background: linear-gradient(180deg, var(--brass-400), var(--brass-600)); border-radius: 4px 4px 1px 1px; transition: height 0.4s var(--ease-standard); }
.chart-bar-value { font-size: 10.5px; font-weight: 700; color: var(--ink-700); margin-bottom: 4px; }
.chart-bar-label { font-size: 10px; color: var(--ink-500); margin-top: 7px; }

/* ---------------- TABLES ---------------- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data-table th { text-align: left; padding: 12px 14px; color: var(--ink-500); font-weight: 600; font-size: 12.5px; border-bottom: 1.5px solid var(--ink-150); }
table.data-table td { padding: 14px; border-bottom: 1px solid var(--ink-100); color: var(--ink-900); }
table.data-table tr:hover td { background: var(--ink-100); }

/* ---------------- DOCUMENT VAULT ---------------- */
.doc-list-item { display: flex; align-items: center; gap: 14px; padding: 15px; border: 1px solid var(--ink-150); border-radius: var(--radius-sm); margin-bottom: 10px; transition: border-color 0.15s; }
.doc-list-item:hover { border-color: var(--ink-300); }
.doc-icon { font-size: 26px; }
.doc-info { flex: 1; min-width: 0; }
.doc-name { font-weight: 600; font-size: 14px; color: var(--ink-950); }
.doc-meta { font-size: 12px; color: var(--ink-500); margin-top: 3px; }
.doc-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ---------------- MARKET INTELLIGENCE ---------------- */
.insight-card { border: 1px solid var(--ink-150); border-radius: var(--radius-md); padding: 22px; margin-bottom: 16px; background: var(--white); }
.insight-meta { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; font-size: 12px; color: var(--ink-500); }
.insight-title { font-family: var(--font-display); font-size: 18px; font-weight: 600; margin-bottom: 10px; color: var(--ink-950); }
.insight-source { font-size: 13px; margin-top: 12px; color: var(--ink-500); }
.category-pill { padding: 3px 11px; border-radius: var(--radius-pill); font-size: 11px; font-weight: 600; background: var(--navy-900); color: var(--white); text-transform: capitalize; }

/* ---------------- TICKETING ---------------- */
.ticket-row { display: flex; align-items: center; gap: 14px; padding: 16px; border: 1px solid var(--ink-150); border-radius: var(--radius-sm); margin-bottom: 10px; transition: border-color 0.15s; }
.ticket-row:hover { border-color: var(--ink-300); }
.ticket-code { font-family: 'SF Mono', 'Courier New', monospace; font-size: 12px; color: var(--ink-500); font-weight: 600; }
.ticket-subject { font-weight: 600; font-size: 14.5px; }
.chat-thread { display: flex; flex-direction: column; gap: 14px; margin: 20px 0; }
.chat-bubble { max-width: 75%; padding: 13px 17px; border-radius: var(--radius-md); font-size: 14px; }
.chat-bubble.mine { align-self: flex-end; background: var(--navy-900); color: var(--white); border-bottom-right-radius: 4px; }
.chat-bubble.theirs { align-self: flex-start; background: var(--ink-100); color: var(--ink-900); border-bottom-left-radius: 4px; }
.chat-bubble.internal { align-self: center; background: var(--warning-bg); color: var(--warning); font-size: 12.5px; border-radius: var(--radius-sm); }
.chat-meta { font-size: 11px; opacity: 0.7; margin-top: 7px; }

.empty-state { text-align: center; padding: 56px 20px; color: var(--ink-500); }
.empty-state-icon { font-size: 38px; margin-bottom: 14px; opacity: 0.7; }

/* ---------------- RESPONSIVE / MOBILE ---------------- */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-floating); }
    .sidebar.open { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .sidebar-toggle { display: block; }
    .sidebar-overlay.show { display: block; position: fixed; inset: 0; background: rgba(11,18,32,0.5); z-index: 99; backdrop-filter: blur(1px); }
    .content-area { padding: 20px; }
    .topbar { padding: 16px 20px; }
}
@media (max-width: 480px) {
    .user-name { display: none; }
    .content-area { padding: 16px; }
}
