/* --- CSS VARIABLES (THEME) --- */
:root {
    --bg-base:    #1a1a27;
    --bg-card:    #27293d;
    --bg-input:   #1a1a27;
    --border:     #2b2b40;
    --border-alt: #34384b;
    --text-main:  #ffffff;
    --text-sub:   #8f9bb3;
    --text-muted: #5c6277;
}

body.light-mode {
    --bg-base:    #f0f2f8;
    --bg-card:    #ffffff;
    --bg-input:   #f4f5f7;
    --border:     #d1d5e0;
    --border-alt: #e2e5ef;
    --text-main:  #1a1a2e;
    --text-sub:   #5a6275;
    --text-muted: #9ca3b0;
}

/* --- PENGATURAN DASAR (MODERN DARK THEME) --- */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    background-color: var(--bg-base);
    color: var(--text-sub);
    transition: background-color 0.3s, color 0.3s;
}

.dashboard-container {
    display: flex;
    min-height: 100vh;
}

/* --- DESAIN SIDEBAR (KIRI) --- */
.sidebar {
    width: 260px;
    min-width: 260px;
    background-color: var(--bg-card);
    padding-top: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 22px 0 rgba(0,0,0,0.1);
    z-index: 10;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    padding: 0 25px;
    margin-bottom: 20px;
}

.brand h2 {
    font-size: 22px;
    margin: 0 0 0 10px;
    color: var(--text-main);
}

.logo-icon {
    font-size: 28px;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
}

/* Judul Kategori Sidebar (Contoh: MAIN, REPORTING) */
.sidebar-section {
    font-size: 11px;
    font-weight: 700;
    color: #5c6277;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 25px 25px 10px 25px;
}

/* Desain Menu & Ikon SVG Bersih */
.menu-item {
    text-decoration: none;
    color: var(--text-sub);
    padding: 12px 25px;
    font-size: 15px;
    margin: 4px 15px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: 0.3s;
}

.menu-icon {
    width: 18px;
    height: 18px;
}

.menu-item:hover {
    background-color: rgba(115, 103, 240, 0.08);
    color: var(--text-main);
}

.menu-item.active {
    background-color: var(--bg-base);
    color: #7367f0;
    font-weight: bold;
    border-left: 4px solid #7367f0;
}

.menu-item--soon {
    opacity: .6;
    cursor: default;
    position: relative;
}
.menu-item--soon:hover {
    opacity: .85;
    background-color: rgba(115,103,240,.06);
    color: var(--text-sub);
}
.soon-badge {
    margin-left: auto;
    font-size: 10px;
    font-weight: 700;
    background: rgba(115,103,240,.15);
    color: #7367f0;
    border-radius: 20px;
    padding: 2px 8px;
    letter-spacing: .3px;
    flex-shrink: 0;
}

.sidebar-login-info {
    font-size: 11px;
    color: var(--text-muted);
    padding: 6px 4px 2px;
    word-break: break-all;
    line-height: 1.4;
}
.sidebar-login-info strong {
    display: block;
    color: var(--text-sub);
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 1px;
}

/* --- TOPBAR --- */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    gap: 20px;
    flex-wrap: wrap;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.topbar-middle {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

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

.topbar h1 {
    margin: 0;
    color: var(--text-main);
    font-weight: 600;
    white-space: nowrap;
}

.platform-select {
    background-color: var(--bg-card);
    color: var(--text-main);
    padding: 10px 15px;
    border: 1px solid var(--border-alt);
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
}

/* Date filter card */
.date-filter-card {
    display: flex;
    align-items: center;
    background-color: var(--bg-card);
    border: 1px solid var(--border-alt);
    border-radius: 12px;
    padding: 10px 20px;
    gap: 15px;
}

.date-item {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.date-item-text {
    display: flex;
    flex-direction: column;
}

.date-label {
    font-size: 11px;
    color: var(--text-sub);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.date-display {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
    cursor: pointer;
    white-space: nowrap;
}

.date-input-hidden {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
}

.date-divider {
    width: 1px;
    height: 36px;
    background-color: var(--border-alt);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-name {
    color: var(--text-sub);
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.topbar-project {
    font-size: 12px;
    font-weight: 500;
    color: #7367f0;
    background: rgba(115, 103, 240, 0.12);
    padding: 3px 10px;
    border-radius: 20px;
    white-space: nowrap;
}

.topbar-project:empty {
    display: none;
}

.btn-logout {
    background-color: transparent;
    color: #ff4d4f;
    border: 1px solid #ff4d4f;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: 0.3s;
    font-size: 13px;
}

.btn-logout:hover {
    background-color: #ff4d4f;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(255, 77, 79, 0.3);
}

/* --- DESAIN KONTEN UTAMA --- */
.main-content {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
}

/* --- DESAIN FILTER AREA & FORM AREA --- */
.filter-area, .form-area {
    background-color: var(--bg-card);
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 22px 0 rgba(0,0,0,0.1);
    margin-bottom: 25px;
}

.filter-area {
    display: flex;
    gap: 15px;
    align-items: center;
}

.filter-area select, .filter-area input,
.form-group input, .form-group select {
    background-color: var(--bg-input);
    color: var(--text-main);
    padding: 12px 15px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    flex: 1;
    width: 100%;
    box-sizing: border-box;
    transition: 0.3s;
}

::-webkit-calendar-picker-indicator {
    filter: invert(1);
    opacity: 0.7;
    cursor: pointer;
}

.filter-area select:focus, .filter-area input:focus,
.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: #7367f0;
    box-shadow: 0 0 8px rgba(115, 103, 240, 0.4);
}

.input-readonly {
    background-color: #232333 !important;
    color: #8f9bb3;
    font-weight: bold;
    cursor: not-allowed;
}

.btn-filter, .btn-simpan {
    background-color: #7367f0; 
    color: white;
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: 0.3s;
    box-shadow: 0px 4px 15px rgba(115, 103, 240, 0.4);
}

.btn-filter:hover, .btn-simpan:hover { 
    background-color: #5e50ee; 
    box-shadow: 0px 6px 20px rgba(115, 103, 240, 0.6);
}

.btn-simpan {
    width: 100%;
    font-size: 16px;
    padding: 15px 25px;
    margin-top: 20px;
}

/* --- GRID & KPI CARDS (KARTU ANGKA) --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1.5fr; 
    gap: 20px;
}

.kpi-card {
    background-color: var(--bg-card);
    padding: 18px 20px;
    text-align: left;
    border-radius: 12px;
    box-shadow: 0 2px 22px 0 rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.kpi-card h3 {
    margin: 0 0 6px 0;
    font-size: 11px;
    color: var(--text-sub);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi-card h2 {
    margin: 0;
    font-size: 26px;
    color: var(--text-main);
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.metric-select {
    background-color: var(--bg-card);
    color: var(--text-main);
    padding: 8px 12px;
    border: 1px solid var(--border-alt);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

/* ── TOP CONTENT SORTABLE HEADERS ── */
#tcHeaderRow th[data-key] {
    transition: color .2s;
    white-space: nowrap;
}
#tcHeaderRow th[data-key]:hover { color: #7367f0; }
.tc-sort-icon { font-size: 11px; color: var(--text-muted); transition: color .2s; }

/* ── KPI HOVER POPUP ── */
.kpi-popup {
    display: none;
    position: fixed;
    background: rgba(17,17,30,.92);
    color: #fff;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    pointer-events: none;
    z-index: 9999;
    box-shadow: 0 4px 16px rgba(0,0,0,.4);
    white-space: nowrap;
    letter-spacing: .3px;
}
body.light-mode .kpi-popup {
    background: rgba(30,30,50,.9);
}

.topbar-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7367f0, #28c76f);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    letter-spacing: 0;
}

.top-content-row {
    cursor: pointer;
    transition: background-color 0.2s;
}

.top-content-row:hover {
    background-color: rgba(115, 103, 240, 0.1) !important;
}

.top-content-row.aktif {
    background-color: rgba(115, 103, 240, 0.15) !important;
    border-left: 3px solid #7367f0;
}

/* --- DESAIN TABEL --- */
.table-card {
    background-color: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 22px 0 rgba(0,0,0,0.1);
}

.best-perf-table, table {
    width: 100%;
    border-collapse: collapse;
}

.best-perf-table th, table th {
    background-color: var(--bg-card) !important;
    padding: 18px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-alt) !important;
    color: var(--text-sub) !important;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
}

.best-perf-table td, table td {
    padding: 15px;
    border-bottom: 1px solid var(--border-alt) !important;
    font-size: 14px;
    color: var(--text-main);
}

.best-perf-table tbody tr:hover, table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

/* --- FORM GRID DI REPORT --- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: bold;
    color: #8f9bb3;
    margin-bottom: 8px;
}

.video-grid {
    border-top: 1px dashed #34384b;
    padding-top: 20px;
    margin-top: 10px;
}

/* --- POP-UP TOOLTIP INTERAKSI --- */
.tooltip-container {
    position: relative;
    cursor: help;
    display: inline-block;
}

.info-icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    background-color: #7367f0;
    color: white;
    border-radius: 50%;
    text-align: center;
    font-size: 11px;
    line-height: 16px;
    font-weight: bold;
    margin-left: 5px;
}

.tooltip-text {
    visibility: hidden;
    width: 130px;
    background-color: #7367f0; 
    color: #fff;
    text-align: left;
    border-radius: 8px;
    padding: 10px;
    position: absolute;
    z-index: 999;
    top: 50%;
    left: 100%;
    transform: translateY(-50%);
    margin-left: 12px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 12px;
    line-height: 1.6;
    box-shadow: 0px 4px 15px rgba(115, 103, 240, 0.4);
}

.tooltip-text::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 100%; 
    margin-top: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: transparent #7367f0 transparent transparent;
}

.tooltip-container:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* --- HALAMAN SETTINGS --- */
.setting-card {
    background-color: var(--bg-card);
    border-radius: 12px;
    padding: 28px;
    margin-bottom: 20px;
    box-shadow: 0 2px 22px 0 rgba(0,0,0,0.2);
}

.setting-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-alt);
}

.setting-card-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-main);
}

.setting-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

/* Social Media checkboxes */
.sosmed-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.sosmed-item {
    cursor: pointer;
}

.sosmed-item input[type="checkbox"] {
    display: none;
}

.sosmed-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border: 1px solid var(--border-alt);
    border-radius: 10px;
    color: var(--text-sub);
    transition: 0.2s;
    font-size: 14px;
    font-weight: 500;
    user-select: none;
}

.sosmed-card:hover {
    border-color: #7367f0;
    color: var(--text-main);
}

.sosmed-item input:checked + .sosmed-card {
    border-color: #7367f0;
    background-color: rgba(115, 103, 240, 0.15);
    color: #7367f0;
}

/* Content Pillar tags */
.pillar-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 40px;
}

.pillar-tag {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: rgba(115, 103, 240, 0.15);
    border: 1px solid #7367f0;
    color: #7367f0;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.pillar-tag button {
    background: none;
    border: none;
    color: #7367f0;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.pillar-tag button:hover {
    opacity: 1;
}

/* --- INFO POPUP MODAL --- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(3px);
}

.modal-overlay.active {
    display: flex;
}

.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border-alt);
    border-radius: 14px;
    padding: 28px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(-10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-header h3 {
    margin: 0;
    color: var(--text-main);
    font-size: 17px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: #8f9bb3;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #ffffff;
}

.modal-body {
    margin: 0;
    color: #8f9bb3;
    font-size: 14px;
    line-height: 1.7;
    white-space: pre-line;
}

.info-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    background: #7367f0;
    color: white;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    margin-left: 4px;
    vertical-align: middle;
    flex-shrink: 0;
    transition: background 0.2s;
}

.info-btn:hover {
    background: #5e50ee;
}

/* Toast notification */
.toast {
    position: fixed;
    top: 30px;
    right: 30px;
    background-color: #28c76f;
    color: #ffffff;
    padding: 14px 24px;
    border-radius: 10px;
    font-weight: bold;
    font-size: 14px;
    z-index: 9999;
    box-shadow: 0 4px 20px rgba(40, 199, 111, 0.4);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* --- DESAIN HALAMAN LOGIN KHUSUS --- */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background-color: #1a1a27; 
}

.login-card {
    background-color: #27293d;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 360px; 
    text-align: center;
    border: 1px solid #34384b;
}

.login-input {
    width: 100%;
    padding: 14px;
    margin-bottom: 20px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-alt);
    color: var(--text-main);
    border-radius: 8px;
    box-sizing: border-box;
    font-size: 14px;
    transition: 0.3s;
}

.login-input:focus {
    outline: none;
    border-color: #7367f0;
    box-shadow: 0 0 8px rgba(115, 103, 240, 0.4);
}

.error-msg {
    color: #ff4d4f;
    font-size: 13px;
    margin-bottom: 15px;
    font-weight: bold;
    display: none; 
}
/* --- SIDEBAR BOTTOM CONTROLS --- */
.sidebar-menu {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.sidebar-bottom {
    padding: 16px 20px 20px;
    border-top: 1px solid var(--border-alt);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.lang-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-base);
    border-radius: 8px;
    padding: 4px;
}

.lang-btn {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-sub);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 0;
    border-radius: 6px;
    transition: 0.2s;
    letter-spacing: 0.5px;
}

.lang-btn.active {
    background: #7367f0;
    color: #ffffff;
}

.lang-btn:hover:not(.active) {
    color: var(--text-main);
}

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--bg-base);
    border: 1px solid var(--border-alt);
    color: var(--text-sub);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: 0.2s;
}

.theme-toggle:hover {
    border-color: #7367f0;
    color: #7367f0;
}

/* --- SUBMENU SIDEBAR --- */
.submenu {
    display: flex;
    flex-direction: column;
    padding-left: 15px;
}

.submenu a {
    text-decoration: none;
    color: #8f9bb3;
    padding: 9px 25px;
    font-size: 14px;
    margin: 2px 15px;
    border-radius: 8px;
    transition: 0.3s;
}

.submenu a:hover {
    background-color: rgba(115, 103, 240, 0.08);
    color: var(--text-main);
}

/* Layout baru ala PowerPixel */
.dashboard-layout {
    display: grid;
    grid-template-columns: 480px 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.bottom-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.chart-area, .chart-card {
    background: var(--bg-card);
    padding: 20px;
    border-radius: 12px;
    /* Allow Chart.js tooltip to overflow */
    overflow: visible;
}

.filter-header {
    display: flex;
    gap: 10px;
    background: #27293d;
    padding: 10px;
    border-radius: 8px;
}

/* ============================================
   RESPONSIVE - HAMBURGER & OVERLAY
   ============================================ */

.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    color: var(--text-main);
    flex-direction: column;
    gap: 5px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.hamburger:hover { background: rgba(115,103,240,0.1); }

.hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-main);
    border-radius: 2px;
    transition: 0.3s;
}

body.sidebar-open .hamburger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
body.sidebar-open .hamburger span:nth-child(2) { opacity: 0; }
body.sidebar-open .hamburger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9;
    backdrop-filter: blur(2px);
}
body.sidebar-open .sidebar-overlay { display: block; }

/* KPI number — clamp agar tidak melar */
.kpi-card h2 {
    font-size: clamp(16px, 2.2vw, 28px);
    word-break: break-all;
}
.kpi-card h3 {
    font-size: clamp(9px, 0.8vw, 13px);
}

/* ============================================
   SMALL DESKTOP — 1280px ke bawah
   ============================================ */
@media (max-width: 1280px) {
    .dashboard-layout {
        grid-template-columns: 420px 1fr;
    }
    .metrics-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    .kpi-card {
        padding: 14px 16px;
    }
}

/* ============================================
   TABLET LANDSCAPE + iPad Pro — 1024px ke bawah
   ============================================ */
@media (max-width: 1024px) {

    .sidebar {
        width: 210px;
        min-width: 210px;
    }

    .brand h2 { font-size: 18px; }
    .menu-item { font-size: 13px; padding: 10px 16px; margin: 3px 10px; }
    .sidebar-section { margin: 18px 16px 8px; font-size: 10px; }

    .main-content { padding: 24px; }

    .topbar { flex-wrap: wrap; gap: 10px; }
    .topbar-right { flex-wrap: wrap; gap: 8px; }
    .topbar h1 { font-size: 22px; }

    .date-filter-card { padding: 8px 12px; gap: 10px; }
    .date-display { font-size: 13px; }

    .dashboard-layout {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .metrics-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
    }
    .bottom-layout {
        grid-template-columns: 2fr 1fr;
        gap: 16px;
    }
}

/* ============================================
   TABLET PORTRAIT / iPad mini — 768px ke bawah
   ============================================ */
@media (max-width: 768px) {

    /* Sidebar tetap visible tapi lebih ramping */
    .sidebar {
        width: 200px;
        min-width: 200px;
    }

    .main-content { padding: 16px 20px; }

    .topbar { flex-wrap: wrap; gap: 8px; }
    .topbar-left h1 { font-size: 20px; }
    .topbar-right { flex-wrap: wrap; gap: 8px; }

    .date-filter-card {
        flex-direction: column;
        gap: 8px;
        padding: 10px 14px;
    }
    .date-divider { width: 100%; height: 1px; }
    .btn-filter { padding: 10px 16px; }

    .dashboard-layout { grid-template-columns: 1fr; gap: 14px; }
    .metrics-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .kpi-card { padding: 14px; }

    .bottom-layout { grid-template-columns: 1fr; gap: 14px; }

    /* Chart tetap tapi lebih kecil */
    .chart-area { padding: 14px; }

    .form-grid { grid-template-columns: 1fr 1fr; }
    .setting-grid { grid-template-columns: 1fr; }

    .modal-box { margin: 16px; padding: 20px; }

    .best-perf-table th, .best-perf-table td,
    table th, table td { padding: 10px 8px; font-size: 12px; }
}

/* ============================================
   LARGE PHONE — 600px ke bawah (Samsung Fold unfolded, dll)
   ============================================ */
@media (max-width: 600px) {

    /* Sidebar slide-in — full height, menu scrolls, bottom pinned */
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        /* iOS Safari: gunakan svh agar tidak terhalang address bar */
        height: 100vh;
        height: -webkit-fill-available;
        height: 100svh;
        width: 260px;
        z-index: 100;
        transition: left 0.3s ease;
        box-shadow: none;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
    body.sidebar-open .sidebar {
        left: 0;
        box-shadow: 4px 0 30px rgba(0,0,0,0.4);
    }

    /* Menu scrolls */
    .sidebar-menu {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        min-height: 0; /* penting agar flex shrink bekerja */
    }

    /* Bottom selalu kelihatan dan bisa disentuh */
    .sidebar-bottom {
        flex-shrink: 0;
        padding-bottom: max(16px, env(safe-area-inset-bottom, 16px));
        /* pastikan z-index di atas overlay */
        position: relative;
        z-index: 1;
    }
    /* Perbesar touch area tombol theme toggle */
    .sidebar-bottom .theme-toggle {
        min-height: 44px;
    }
    .sidebar-bottom .lang-btn {
        min-height: 36px;
    }

    .dashboard-container { flex-direction: column; }

    /* Body scroll — diperlukan agar sticky topbar bekerja */
    .main-content {
        padding: 14px;
        width: 100%;
        box-sizing: border-box;
        overflow-y: visible;
    }

    /* Hamburger tampil */
    .hamburger { display: flex; flex-shrink: 0; }

    /* TOPBAR sticky penuh (hamburger + platform row) */
    .topbar {
        position: sticky;
        top: 0;
        z-index: 8;
        background: var(--bg-base);
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 0 0 8px 0;
        margin-bottom: 14px;
        /* Shadow tipis agar terlihat saat di-scroll */
        box-shadow: 0 2px 8px -4px rgba(0,0,0,.3);
    }

    /* Row 1: hamburger + judul */
    .topbar-left {
        position: static; /* sticky sudah di .topbar */
        width: 100%;
        gap: 10px;
        padding: 10px 0 6px 0;
    }

    /* Row 2: platform + datepicker sejajar dalam satu baris */
    .topbar-middle {
        width: 100%;
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 8px;
        padding: 4px 0 6px 0;
        flex-wrap: nowrap;
    }

    .platform-select {
        flex: 1;
        min-width: 0;
        font-size: 13px;
        padding: 8px 10px;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .datepicker-wrapper { flex-shrink: 0; }

    /* Sembunyikan user/logout dari topbar di mobile — dipindah ke bawah konten */
    .topbar-right { display: none !important; }

    /* User/logout footer di paling bawah scroll */
    .mobile-user-footer {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        margin-top: 28px;
        padding: 14px 0 24px;
        border-top: 1px solid var(--border-alt);
    }
    .mobile-user-footer .user-menu { gap: 10px; flex-wrap: wrap; }

    .user-menu { gap: 10px; flex-wrap: wrap; }

    .date-filter-card { flex-direction: column; }
    .date-divider { width: 100%; height: 1px; }
    .btn-filter { width: 100%; }

    .metrics-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .kpi-card { padding: 12px; }

    /* Sembunyikan chart di layar kecil */
    .chart-area { display: none; }
    .bottom-layout { grid-template-columns: 1fr; gap: 12px; }

    .form-grid { grid-template-columns: 1fr; }
    .setting-grid { grid-template-columns: 1fr; }

    .sosmed-grid { gap: 6px; }
    .sosmed-card { padding: 8px 12px; font-size: 12px; }

    .login-card { margin: 16px; padding: 24px 18px; }

    /* Report title truncate on mobile — dinamis */
    #reportTitle {
        font-size: 16px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: min(160px, 40vw);
    }

    /* Table headers — pastikan bisa di-tap di mobile */
    table th {
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(115,103,240,0.15);
        cursor: pointer;
    }

    /* Date input — hilangkan native bar iOS */
    input[type="date"] {
        -webkit-appearance: none;
        appearance: none;
    }

    /* User management table bisa scroll horizontal */
    .um-table-wrap {
        -webkit-overflow-scrolling: touch;
        overflow-x: auto;
    }
}

/* ============================================
   SMALL PHONE / Samsung Fold closed — 400px ke bawah
   ============================================ */
@media (max-width: 400px) {

    .metrics-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
    .kpi-card { padding: 10px 12px; }
    .kpi-card h2 { font-size: 16px; }
    .kpi-card h3 { font-size: 9px; }

    .topbar-left h1 { font-size: 18px; }
    .date-display { font-size: 12px; }

    .modal-box { margin: 10px; padding: 16px; }

    .best-perf-table th, .best-perf-table td,
    table th, table td { padding: 8px 6px; font-size: 11px; }
}

/* ============================================
   PROJECT CARDS (Settings)
   ============================================ */

.project-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.project-card {
    background: var(--bg-card);
    border-radius: 14px;
    padding: 22px;
    border: 2px solid var(--border-alt);
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
    position: relative;
}

.project-card:hover {
    border-color: #7367f0;
    box-shadow: 0 4px 20px rgba(115, 103, 240, 0.15);
    transform: translateY(-2px);
}

.project-card.aktif {
    border-color: #7367f0;
    box-shadow: 0 4px 24px rgba(115, 103, 240, 0.25);
}

.project-card-active-badge {
    position: absolute;
    top: 14px;
    right: 14px;
    background: #7367f0;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.project-card-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 4px 0;
    padding-right: 70px;
}

.project-card-client {
    font-size: 13px;
    color: var(--text-sub);
    margin: 0 0 14px 0;
}

.project-card-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.project-card-meta-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.project-card-meta-row svg {
    flex-shrink: 0;
}

.project-card-sosmed {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.sosmed-pill {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    background: rgba(115, 103, 240, 0.1);
    color: #7367f0;
    border: 1px solid rgba(115, 103, 240, 0.2);
}

.project-card-footer {
    display: flex;
    gap: 8px;
    padding-top: 14px;
    border-top: 1px solid var(--border-alt);
}

.btn-set-active {
    flex: 1;
    background: #7367f0;
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-set-active:hover { background: #5e50ee; }

.btn-set-active.is-active {
    background: rgba(115,103,240,0.15);
    color: #7367f0;
    cursor: default;
}

.btn-edit-proj {
    background: transparent;
    color: var(--text-sub);
    border: 1px solid var(--border-alt);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}

.btn-edit-proj:hover {
    border-color: #7367f0;
    color: #7367f0;
}

/* ============================================
   MODAL LARGE (Project Form)
   ============================================ */

.modal-large {
    max-width: 700px;
    width: calc(100% - 32px);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.modal-large .modal-header {
    padding: 22px 28px 18px;
    border-bottom: 1px solid var(--border-alt);
    flex-shrink: 0;
}

.modal-scroll {
    overflow-y: auto;
    padding: 24px 28px;
    flex: 1;
}

.modal-footer {
    padding: 16px 28px;
    border-top: 1px solid var(--border-alt);
    display: flex;
    align-items: center;
    flex-shrink: 0;
    background: var(--bg-card);
}

.modal-section-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-alt);
}

@media (max-width: 600px) {
    .project-card-grid {
        grid-template-columns: 1fr;
    }

    .modal-large {
        max-height: 95vh;
    }

    .modal-large .modal-header,
    .modal-scroll,
    .modal-footer {
        padding-left: 18px;
        padding-right: 18px;
    }

    .modal-footer {
        flex-wrap: wrap;
        gap: 8px;
    }

    .modal-footer > div {
        width: 100%;
        justify-content: stretch;
    }

    .modal-footer > div button {
        flex: 1;
    }
}

/* ============================================
   LIGHT MODE FIXES — comprehensive overrides
   ============================================ */

body.light-mode .platform-select,
body.light-mode .metric-select {
    background-color: var(--bg-card);
    color: var(--text-main);
    border-color: var(--border-alt);
}

body.light-mode .date-filter-card {
    background-color: var(--bg-card);
    border-color: var(--border-alt);
}

body.light-mode .date-display {
    color: var(--text-main);
}

body.light-mode .date-label {
    color: var(--text-sub);
}

body.light-mode .kpi-card {
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

/* Top Content tabel di light mode */
body.light-mode .best-perf-table td,
body.light-mode table td {
    color: var(--text-main) !important;
}

body.light-mode .best-perf-table th,
body.light-mode table th {
    color: var(--text-sub) !important;
    background-color: var(--bg-card) !important;
    border-bottom-color: var(--border-alt) !important;
}

body.light-mode .best-perf-table,
body.light-mode table {
    background-color: var(--bg-card);
}

body.light-mode .top-content-row:hover {
    background-color: rgba(115,103,240,0.06) !important;
}

body.light-mode .top-content-row.aktif {
    background-color: rgba(115,103,240,0.1) !important;
}

/* Sidebar di light mode */
body.light-mode .sidebar-section {
    color: #9ca3b0;
}

body.light-mode .sidebar-bottom {
    border-top-color: var(--border-alt);
}

body.light-mode .lang-toggle {
    background: var(--bg-base);
}

body.light-mode .theme-toggle {
    background: var(--bg-base);
    border-color: var(--border-alt);
    color: var(--text-sub);
}

/* Form inputs di light mode */
body.light-mode .filter-area select,
body.light-mode .filter-area input,
body.light-mode .form-group input,
body.light-mode .form-group select {
    background-color: var(--bg-input);
    color: var(--text-main);
    border-color: var(--border-alt);
}

body.light-mode .input-readonly {
    background-color: #eaecf2 !important;
    color: var(--text-sub);
}

/* Form area di light mode */
body.light-mode .form-area,
body.light-mode .filter-area {
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

/* Calendar picker di light mode */
body.light-mode ::-webkit-calendar-picker-indicator {
    filter: none;
    opacity: 0.5;
}

/* Modal di light mode */
body.light-mode .modal-box {
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

body.light-mode .modal-body {
    color: var(--text-sub);
}

body.light-mode .modal-close {
    color: var(--text-muted);
}

/* Project cards di light mode */
body.light-mode .project-card {
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

body.light-mode .project-card:hover {
    box-shadow: 0 4px 20px rgba(115,103,240,0.12);
}

body.light-mode .project-card-footer {
    border-top-color: var(--border-alt);
}

body.light-mode .btn-edit-proj {
    border-color: var(--border-alt);
    color: var(--text-sub);
}

/* Sosmed cards di light mode */
body.light-mode .sosmed-card {
    border-color: var(--border-alt);
    color: var(--text-sub);
}

/* Pillar tags di light mode */
body.light-mode .pillar-tag {
    background-color: rgba(115,103,240,0.1);
}

/* Chart area di light mode */
body.light-mode .chart-area,
body.light-mode .chart-card {
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

/* Setting cards di light mode */
body.light-mode .setting-card {
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

body.light-mode .setting-card-header {
    border-bottom-color: var(--border-alt);
}

/* No project banner */
body.light-mode #noProjectBanner {
    border-color: var(--border-alt);
}

/* Toast di light mode */
body.light-mode .toast {
    box-shadow: 0 4px 20px rgba(40,199,111,0.2);
}

/* Info button di light mode */
body.light-mode .info-btn {
    opacity: 0.9;
}

/* Table card di light mode */
body.light-mode .table-card {
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

/* link button in table */
.link-btn {
    background: #7367f0;
    color: white;
    padding: 5px 10px;
    text-decoration: none;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}
.link-btn:hover { background: #5e50ee; }

/* ── SIDEBAR CLOCK ──────────────────────────────────────────────────── */
.sidebar-clock {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 6px 0 6px 0;
    border-bottom: 1px solid var(--border-alt);
    margin-bottom: 8px;
}

/* ── KPI TREND ──────────────────────────────────────────────────────── */
.kpi-trend {
    font-size: 12px;
    font-weight: 600;
    margin-top: 4px;
    min-height: 18px;
    display: flex;
    align-items: center;
    gap: 3px;
}
.kpi-trend.up   { color: #28c76f; }
.kpi-trend.down { color: #ea5455; }
.kpi-trend.flat { color: var(--text-muted); }

/* ── DATE PICKER DROPDOWN ───────────────────────────────────────────── */
.datepicker-wrapper {
    position: relative;
}
.datepicker-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-alt);
    color: var(--text-main);
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.2s;
}
.datepicker-btn:hover { border-color: #7367f0; }
.datepicker-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-alt);
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
    z-index: 9999;
    min-width: 200px;
    overflow: hidden;
}
.datepicker-dropdown.open { display: block; }
.datepicker-presets { padding: 8px 0; }
.preset-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 6px 16px 8px;
}
.preset-item {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 9px 16px;
    font-size: 13px;
    color: var(--text-sub);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.preset-item:hover { background: rgba(115,103,240,0.1); color: #7367f0; }
.preset-item.active { color: #7367f0; font-weight: 700; background: rgba(115,103,240,0.08); }
.datepicker-custom {
    border-top: 1px solid var(--border-alt);
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.custom-date-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
}
.custom-date-input {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-base);
    border: 1px solid var(--border-alt);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 13px;
    box-sizing: border-box;
}
