/* ========================================= */
/* 1. CONFIG: MONOCHROME THEME               */
/* ========================================= */
:root {
    /* --- DARK MODE (DEFAULT) --- */
    --bg-body: #121212;        
    --bg-sidebar: #1e1e1e;     
    --bg-card: #1e1e1e;        
    --bg-input: #121212;
    --bg-hover: rgba(255, 255, 255, 0.1); /* Hover lebih terang dikit */
    
    --text-primary: #ffffff;   /* Putih Murni */
    --text-secondary: #a0a0a0; /* Abu Terang */
    
    --border-color: #333333;   
    --border-subtle: #2a2a2a;
    
    /* REPLACEMENT WARNA (DULU KUNING/BIRU JADI MONOKROM) */
    --color-accent-1: #ffffff;  /* Pengganti Kuning (Sekarang Putih) */
    --color-accent-2: #888888;  /* Pengganti Biru (Sekarang Abu) */
    
    --color-danger: #ef4444;    /* Merah tetap untuk error/alert */
    --color-stock: #666666; 
    
    --shadow-card: 0 4px 12px rgba(0,0,0,0.5);

    /* LAYOUT VARS */
    --gap-std: 24px;         
    --card-radius: 12px;     
    --header-height: 64px;
    --sidebar-width: 260px;
}

[data-theme="light"] {
    /* --- LIGHT MODE --- */
    --bg-body: #f5f5f5;      
    --bg-sidebar: #ffffff;     
    --bg-card: #ffffff;
    --bg-input: #f0f0f0;
    --bg-hover: #e5e5e5;
    
    --text-primary: #121212;   /* Hitam Pekat */
    --text-secondary: #666666; /* Abu Tua */
    
    --border-color: #e0e0e0;   
    --border-subtle: #f5f5f5;
    
    /* MONOKROM LIGHT MODE */
    --color-accent-1: #121212; /* Hitam sebagai aksen utama */
    --color-accent-2: #666666; /* Abu tua sebagai aksen kedua */
    
    --color-stock: #cccccc; 
    
    --shadow-card: 0 2px 10px rgba(0,0,0,0.05);
}

/* ========================================= */
/* 2. BASE STYLES                            */
/* ========================================= */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

body { 
    background-color: var(--bg-body); 
    color: var(--text-primary); 
    font-family: 'Plus Jakarta Sans', sans-serif; 
    height: 100dvh; 
    width: 100vw;
    overflow: hidden; 
    display: flex; 
    transition: background 0.2s; 
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }

/* ========================================= */
/* 3. SIDEBAR (MONOCHROME STYLE)             */
/* ========================================= */
.sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex; flex-direction: column;
    padding: 24px 16px; 
    z-index: 3000; 
    transform: translateX(-100%); 
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar.show { transform: translateX(0); }

.brand { padding-bottom: 20px; margin-bottom: 16px; border-bottom: 1px solid var(--border-color); }
.brand-title { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.brand-subtitle { font-size: 11px; color: var(--text-secondary); margin-top: 4px; }

/* ICON TEMA (Tanpa Warna Warni) */
.theme-btn-header {
    background: transparent; 
    border: none; 
    color: var(--text-secondary); 
    cursor: pointer;
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    padding: 0;
}
.theme-btn-header:hover { color: var(--text-primary); } /* Jadi Putih/Hitam saat hover */
.theme-btn-header i { font-size: 16px; }

.menu-label { font-size: 11px; font-weight: 700; color: var(--text-secondary); margin: 16px 10px 8px; text-transform: uppercase; letter-spacing: 0.5px; }

.nav-item {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 4px; 
    border-radius: 8px; font-size: 14px; color: var(--text-secondary); cursor: pointer;
}
.nav-item:hover, .nav-item.active { background-color: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { font-weight: 600; }
.nav-item i { width: 20px; text-align: center; font-size: 15px; }

/* MENU AKTIF: PUTIH (Dark) / HITAM (Light) - TIDAK KUNING/BIRU */
.nav-item.active i { color: var(--color-accent-1); }

/* Tombol Login Admin */
#btn-login-trigger {
    margin-top: auto; 
    margin-bottom: 20px;
    background-color: var(--bg-hover);
    color: var(--text-primary);
    font-weight: 600;
}
#admin-label-hidden { display: none !important; }

/* ========================================= */
/* 4. MAIN CONTENT & HEADER                  */
/* ========================================= */
.main-content { 
    flex-grow: 1; 
    overflow-y: auto; 
    height: 100dvh; 
    width: 100%; 
    position: relative;
    scroll-behavior: smooth;
}

.header {
    position: sticky; top: 0; 
    z-index: 100;
    background: var(--bg-sidebar); 
    border-bottom: 1px solid var(--border-color);
    padding: 0 32px; height: var(--header-height);
    display: flex; align-items: center; justify-content: space-between;
}
.header-left { display: flex; align-items: center; gap: 20px; flex: 1; min-width: 0; }
.mobile-toggle { 
    display: flex; width: 36px; height: 36px; align-items: center; justify-content: center;
    background: var(--bg-body); border: 1px solid var(--border-color); border-radius: 8px; 
    color: var(--text-primary); cursor: pointer; flex-shrink: 0;
}
.page-info h2 { font-size: 18px; font-weight: 700; margin: 0; }
.page-info p { font-size: 12px; color: var(--text-secondary); margin: 0; }

.container { padding: var(--gap-std); max-width: 1600px; margin: 0 auto; padding-bottom: 40px; }

/* ========================================= */
/* 5. GRID SYSTEM                            */
/* ========================================= */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--gap-std); margin-bottom: var(--gap-std); align-items: stretch; }
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap-std); margin-bottom: var(--gap-std); }
.ranking-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap-std); }

/* ========================================= */
/* 6. CARDS                                  */
/* ========================================= */
.kpi-card, .chart-section {
    background: var(--bg-card); 
    border: 1px solid var(--border-color);
    border-radius: var(--card-radius);
    padding: 24px;
    box-shadow: var(--shadow-card);
    display: flex; flex-direction: column; 
    height: 100%; min-width: 0;
}
.kpi-card { justify-content: space-between; min-height: 160px; }
.kpi-header { display: flex; justify-content: space-between; margin-bottom: 12px; align-items: center; }
.kpi-title { font-size: 12px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }

/* ICON KPI: Hitam Putih Saja */
.kpi-icon { 
    width: 32px; height: 32px; border-radius: 50%; 
    display: flex; align-items: center; justify-content: center; 
    background: var(--bg-body); 
    color: var(--text-primary); /* Mengikuti warna teks utama */
}

.kpi-main-val { font-size: 28px; font-weight: 800; color: var(--text-primary); margin-bottom: 4px; }
.kpi-sub-val { font-size: 12px; color: var(--text-secondary); display: flex; justify-content: space-between; margin-bottom: 12px; }
.progress-track { height: 6px; background: var(--bg-body); border-radius: 10px; overflow: hidden; margin-bottom: 12px; border: 1px solid var(--border-color); }
.progress-bar { height: 100%; border-radius: 10px; background-color: var(--text-primary); /* Bar progress mengikuti warna teks (Putih/Hitam) */ }

.kpi-footer { padding-top: 12px; border-top: 1px solid var(--border-subtle); font-size: 11px; color: var(--text-secondary); display: flex; gap: 6px; align-items: center; margin-top: auto; }
.sparkline-container { width: 100%; height: 60px; margin-top: auto; position: relative; }
.sparkline-val { position: absolute; bottom: 0; right: 0; font-size: 18px; font-weight: 700; color: var(--text-primary); }

.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 16px; }
.section-title { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.chart-wrapper { position: relative; height: 300px; width: 100%; flex-grow: 1; }
.chart-actions { flex-grow: 1; display: flex; justify-content: flex-end; }

/* Toggle Buttons (Monokrom) */
.btn-group { display: flex; background: var(--bg-body); padding: 3px; border-radius: 8px; border: 1px solid var(--border-color); }
.btn-toggle { padding: 6px 14px; font-size: 12px; font-weight: 600; color: var(--text-secondary); border: none; background: transparent; cursor: pointer; border-radius: 6px; }
.btn-toggle.active { background: var(--bg-card); color: var(--text-primary); box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
/* Hapus warna khusus Urea/NPK, ganti jadi standar aktif */
.btn-toggle.active.t-urea, .btn-toggle.active.t-npk { color: var(--text-primary); }

/* Ranking List */
.rank-item { display: flex; align-items: center; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border-subtle); }
.rank-item:last-child { border-bottom: none; }

/* Badge Ranking (Abu-abu, bukan kuning) */
.rank-badge { 
    width: 32px; height: 32px; border-radius: 8px; 
    display: flex; align-items: center; justify-content: center; 
    font-weight: 700; font-size: 13px; 
    border: 1px solid var(--border-color); 
    color: var(--text-primary); 
    background: var(--bg-body);
    flex-shrink: 0; 
}
.badge-1 { 
    background: rgba(255, 255, 255, 0.1); 
    color: var(--text-primary); 
    border-color: var(--border-color); 
}
[data-theme="light"] .badge-1 { background: #e0e0e0; color: #000; }

.rank-name { font-size: 14px; font-weight: 600; color: var(--text-primary); flex: 1; overflow: hidden; text-overflow: ellipsis; }
.rank-meta { font-size: 11px; color: var(--text-secondary); display: block; }
.rank-val { font-size: 14px; font-weight: 700; color: var(--text-primary); }
/* Text Good/Bad jadi netral atau tetap merah jika kritis */
.text-good { color: var(--text-primary); } 
.text-bad { color: var(--color-danger); }

/* ========================================= */
/* 7. DROPDOWN & INPUTS                      */
/* ========================================= */
.select-wrapper { position: relative; width: 200px; max-width: 100%; }
.year-wrapper { width: 100px !important; }
.select-trigger { display: flex; justify-content: space-between; align-items: center; background: var(--bg-body); border: 1px solid var(--border-color); padding: 0 14px; border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--text-primary); cursor: pointer; height: 38px; }
.select-trigger span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-right: 8px; flex: 1; }
.select-options { position: absolute; top: 110%; right: 0; left: 0; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 8px; box-shadow: 0 10px 30px rgba(0,0,0,0.2); max-height: 250px; overflow-y: auto; z-index: 100; opacity: 0; visibility: hidden; transform: translateY(-10px); transition: 0.2s; }
.select-options.open { opacity: 1; visibility: visible; transform: translateY(0); }
.option { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border-subtle); font-size: 13px; color: var(--text-secondary); }
.option:hover { background: var(--bg-hover); color: var(--text-primary); }
.option.selected { color: var(--text-primary); font-weight: 700; background: var(--bg-hover); }

/* ========================================= */
/* 8. MODAL & OVERLAY                        */
/* ========================================= */
.overlay, .backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 2000; opacity: 0; visibility: hidden; transition: 0.2s; backdrop-filter: blur(4px); }
.overlay.active, .backdrop.open { opacity: 1; visibility: visible; }

.modal { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.95); background: var(--bg-card); border: 1px solid var(--border-color); box-shadow: 0 20px 60px rgba(0,0,0,0.5); z-index: 4000; border-radius: 16px; opacity: 0; visibility: hidden; transition: 0.2s; display: flex; flex-direction: column; }
.modal.open { opacity: 1; visibility: visible; transform: translate(-50%, -50%) scale(1); }

#loginModal { width: 90%; max-width: 320px; }
.modal-header { padding: 16px 24px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
#loginModal .modal-header { justify-content: center; border-bottom: none; }
.modal-title { font-size: 14px; font-weight: 700; color: var(--text-primary); text-transform: uppercase; letter-spacing: 1px; }
.modal-body { padding: 20px; overflow-y: auto; }
#loginModal .modal-body { padding: 10px 30px; }
.form-control { width: 100%; background: var(--bg-input); border: 1px solid var(--border-color); color: var(--text-primary); padding: 10px; border-radius: 6px; font-size: 14px; }
.form-control:focus { outline: none; border-color: var(--text-primary); }
#adminPass { text-align: center; letter-spacing: 3px; font-size: 16px; height: 44px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 10px; }
#loginModal .modal-footer { justify-content: center; border-top: none; padding-top: 5px; padding-bottom: 25px; }

/* TOMBOL LOGIN MONOKROM */
.btn { padding: 10px 20px; border-radius: 8px; font-weight: 700; font-size: 12px; cursor: pointer; border: none; transition: 0.2s; }
.btn-primary { 
    background: var(--text-primary); /* Putih di dark, Hitam di light */
    color: var(--bg-card); /* Teks kebalikan dari background */
    min-width: 100px; 
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-2px); }
.btn-close { background: none; border: none; font-size: 18px; color: var(--text-secondary); cursor: pointer; }

#loader { position: fixed; inset: 0; background: var(--bg-body); z-index: 9999; display: flex; flex-direction: column; justify-content: center; align-items: center; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--border-color); border-top-color: var(--text-primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.footer-copyright { text-align: center; color: var(--text-muted); font-size: 11px; margin-top: 40px; }

/* ========================================= */
/* 9. RESPONSIVE                             */
/* ========================================= */
@media (max-width: 1200px) { .container { max-width: 100%; } }
@media (max-width: 1024px) { .kpi-grid { grid-template-columns: 1fr 1fr; } .charts-row, .ranking-grid { grid-template-columns: 1fr; } .chart-wrapper { height: 260px; } }
@media (max-width: 768px) {
    .header { padding: 0 20px; }
    .container { padding: 16px; padding-bottom: 80px; }
    .kpi-grid, .charts-row { gap: 16px; margin-bottom: 16px; }
    .kpi-card { padding: 16px; }
    .kpi-main-val { font-size: 24px; }
    .section-header { flex-direction: column; align-items: flex-start; gap: 12px; }
    .chart-actions { width: 100%; }
    #prov-select-wrapper { width: 100% !important; max-width: none; }
    .select-trigger { width: 100%; }
}
