/* =========================================================
   DESIGN SYSTEM - WALI DATA DESA TEMATIK
   ========================================================= */

:root {
    --green-950: #042f1d;
    --green-900: #064426;
    --green-800: #086b3c;
    --green-700: #0f8b51;
    --green-600: #17a361;
    --green-500: #2ecc71;
    --green-400: #58d68d;
    --green-300: #85e3ae;
    --green-200: #bbf2d4;
    --green-100: #e5f9ee;
    --green-50:  #f4fbf7;
    --white: #ffffff;
    --text-main: #142e22;
    --text-muted: #5e7468;
    --border: #d7ebe0;
    --border-soft: #eef6f1;
    --shadow-subtle: 0 4px 20px rgba(6, 68, 38, 0.05);
    --shadow-card: 0 10px 30px rgba(6, 68, 38, 0.08);
    --shadow-hover: 0 18px 45px rgba(6, 68, 38, 0.12);
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 22px;
}

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

html {
    width: 100%;
    min-height: 100%;
    scroll-behavior: smooth;
}

body {
    width: 100%;
    min-height: 100vh;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--text-main);
    background: radial-gradient(circle at 88% 8%, rgba(46, 204, 113, 0.09), transparent 28%), 
                radial-gradient(circle at 10% 65%, rgba(15, 139, 81, 0.06), transparent 30%), 
                var(--green-50);
    overflow-x: hidden;
}

.app {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* ================= SIDEBAR ================= */
.sidebar {
    width: 270px;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    padding: 24px 18px;
    color: white;
    background: linear-gradient(165deg, #086b3c 0%, #054527 50%, #022b17 100%);
    box-shadow: 10px 0 40px rgba(2, 43, 23, 0.15);
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    transition: transform 0.4s cubic-bezier(.16, 1, .3, 1);
}
.sidebar::-webkit-scrollbar { display: none; }

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 6px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    margin-bottom: 20px;
}
.brand-logo {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: white;
    border: 2px solid rgba(255, 255, 255, 0.35);
    object-fit: cover;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}
.brand h2 {
    font-size: 16px;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.3px;
}
.brand small {
    font-size: 9px;
    letter-spacing: 1.5px;
    opacity: 0.65;
    display: block;
    font-weight: 600;
}
.menu-title {
    margin: 16px 8px 8px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.4px;
    color: rgba(255, 255, 255, 0.45);
    font-weight: 700;
}
.menu {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.menu a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, 0.72);
    text-decoration: none;
    font-size: 12.5px;
    font-weight: 600;
    transition: all 0.25s ease;
}
.menu a .menu-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.menu a i {
    width: 18px;
    font-size: 15px;
    text-align: center;
}
.menu a:hover {
    background: rgba(255, 255, 255, 0.12);
    color: white;
    transform: translateX(4px);
}
.menu a.active {
    background: linear-gradient(135deg, rgba(46, 204, 113, 0.35), rgba(15, 139, 81, 0.55));
    border: 1px solid rgba(133, 227, 174, 0.35);
    color: #ffffff;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
}
.badge-soon {
    font-size: 9px;
    font-weight: 700;
    padding: 2px 7px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    color: #bbf2d4;
}
.badge-active {
    font-size: 9px;
    font-weight: 700;
    padding: 2px 7px;
    background: var(--green-400);
    border-radius: 20px;
    color: #022b17;
}
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(4, 47, 29, 0.6);
    backdrop-filter: blur(4px);
    z-index: 999;
}

/* ================= TOPBAR ================= */
.main {
    margin-left: 270px;
    width: calc(100% - 270px);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    padding: 14px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}
.mobile-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    color: var(--green-950);
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
}
.breadcrumb {
    font-size: 11px;
    font-weight: 600;
    color: var(--green-700);
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
}
.top-title {
    font-size: 19px;
    font-weight: 800;
    color: var(--green-950);
    letter-spacing: -0.4px;
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    background: var(--green-100);
    color: var(--green-800);
    font-size: 11px;
    font-weight: 600;
    border: 1px solid var(--border);
}
.status-dot {
    width: 7px;
    height: 7px;
    background: var(--green-600);
    border-radius: 50%;
    animation: pulse 1.8s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.8); }
}

/* BUTTONS */
.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 15px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.btn-outline {
    background: white;
    border: 1px solid var(--border);
    color: var(--green-800);
}
.btn-outline:hover {
    background: var(--green-50);
    border-color: var(--green-600);
    transform: translateY(-1px);
}
.btn-primary {
    background: linear-gradient(135deg, var(--green-700), var(--green-800));
    border: none;
    color: white;
    box-shadow: 0 4px 14px rgba(15, 139, 81, 0.25);
}
.btn-primary:hover {
    background: var(--green-900);
    transform: translateY(-1px);
}

/* ================= HERO BANNER ================= */
.content {
    padding: 26px 32px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}
.hero-banner {
    background: linear-gradient(135deg, #054527 0%, #0a6338 55%, #12874f 100%);
    border-radius: var(--radius-lg);
    padding: 28px 34px;
    color: white;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-card);
}
.hero-banner::after {
    content: "🌾";
    position: absolute;
    right: 28px;
    top: -10px;
    font-size: 130px;
    opacity: 0.12;
    pointer-events: none;
    transform: rotate(-12deg);
}
.hero-top {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.hero-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 11px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.16);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.6px;
}
.hero-title {
    font-size: 23px;
    font-weight: 800;
    letter-spacing: -0.4px;
    margin-bottom: 6px;
}
.hero-desc {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
    max-width: 650px;
    line-height: 1.5;
    margin-bottom: 20px;
}

/* REGIONAL PILLS */
.region-filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.region-pill {
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}
.region-pill:hover {
    background: rgba(255, 255, 255, 0.25);
}
.region-pill.active {
    background: white;
    color: var(--green-950);
    border-color: white;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ================= KPI CARDS ================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
    gap: 16px;
}
.stat-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    box-shadow: var(--shadow-subtle);
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}
.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
    border-color: var(--green-400);
}
.stat-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: var(--green-600);
}
.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: var(--green-100);
    color: var(--green-800);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
.stat-meta small {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 3px;
}
.stat-meta strong {
    font-size: 20px;
    font-weight: 800;
    color: var(--green-950);
    letter-spacing: -0.4px;
    display: block;
}
.stat-meta span {
    font-size: 10.5px;
    color: var(--green-700);
    font-weight: 600;
}

/* ================= COMMODITY CARDS ================= */
.commodity-section {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    box-shadow: var(--shadow-subtle);
}
.section-header-compact {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.section-header-compact h3 {
    font-size: 14px;
    font-weight: 800;
    color: var(--green-950);
    display: flex;
    align-items: center;
    gap: 8px;
}
.section-header-compact span {
    font-size: 11px;
    color: var(--text-muted);
}
.commodity-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
}
.commodity-card {
    background: var(--green-50);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    text-align: center;
    transition: all 0.2s ease;
}
.commodity-card:hover {
    background: white;
    border-color: var(--green-400);
    box-shadow: var(--shadow-subtle);
    transform: translateY(-2px);
}
.commodity-icon {
    font-size: 24px;
    margin-bottom: 4px;
    display: block;
}
.commodity-name {
    font-size: 11px;
    font-weight: 700;
    color: var(--green-950);
    margin-bottom: 2px;
}
.commodity-count {
    font-size: 12px;
    font-weight: 800;
    color: var(--green-800);
}
.commodity-bar-wrap {
    width: 100%;
    height: 4px;
    background: #e1ede6;
    border-radius: 4px;
    margin-top: 6px;
    overflow: hidden;
}
.commodity-bar {
    height: 100%;
    background: var(--green-600);
    border-radius: 4px;
}

/* ================= CHARTS ================= */
.charts-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 20px;
}
.chart-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px 22px;
    box-shadow: var(--shadow-subtle);
    display: flex;
    flex-direction: column;
}
.chart-card-full {
    grid-column: 1 / -1;
}
.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-soft);
}
.chart-title h3 {
    font-size: 14px;
    font-weight: 800;
    color: var(--green-950);
}
.chart-title p {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 1px;
}
.chart-body {
    position: relative;
    height: 300px;
    width: 100%;
}

/* ================= TABLE ================= */
.table-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 22px;
    box-shadow: var(--shadow-subtle);
}
.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}
.search-box {
    position: relative;
    display: flex;
    align-items: center;
}
.search-box i {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    font-size: 12px;
}
.search-box input {
    padding: 8px 14px 8px 34px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: inherit;
    outline: none;
    width: 260px;
    transition: all 0.2s ease;
}
.search-box input:focus {
    border-color: var(--green-600);
    box-shadow: 0 0 0 3px rgba(46, 204, 113, 0.15);
    width: 300px;
}
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
}
table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 12px;
}
thead th {
    background: var(--green-50);
    color: var(--green-950);
    font-weight: 700;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    user-select: none;
    cursor: pointer;
    transition: background 0.15s;
}
thead th:hover {
    background: var(--green-100);
}
thead th.no-sort {
    cursor: default;
}
thead th.no-sort:hover {
    background: var(--green-50);
}
thead th .th-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}
tbody tr {
    border-bottom: 1px solid #f2f7f4;
    transition: background 0.15s ease;
}
tbody tr:hover {
    background: rgba(46, 204, 113, 0.06);
}
tbody td {
    padding: 12px 14px;
    color: var(--text-main);
    white-space: nowrap;
}
.td-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    background: var(--green-100);
    color: var(--green-800);
}
.td-region {
    font-size: 10.5px;
    color: var(--text-muted);
    background: #eef6f1;
    padding: 2px 7px;
    border-radius: 4px;
}
.td-currency {
    font-weight: 600;
    color: var(--green-900);
}
.btn-view-detail {
    padding: 4px 10px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--green-800);
    cursor: pointer;
    transition: all 0.2s;
}
.btn-view-detail:hover {
    background: var(--green-700);
    color: white;
    border-color: var(--green-700);
}
.center {
    text-align: center;
}
.loading-state {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--green-200);
    border-top-color: var(--green-700);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ================= MODAL ================= */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(3, 35, 19, 0.65);
    backdrop-filter: blur(6px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.25s ease;
}
.modal-overlay.show {
    display: flex;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.modal-box {
    background: white;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    animation: scaleUp 0.3s cubic-bezier(.16, 1, .3, 1);
}
@keyframes scaleUp {
    from { transform: scale(0.92); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.modal-header {
    padding: 20px 24px;
    background: linear-gradient(135deg, var(--green-800), var(--green-950));
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.modal-header h3 {
    font-size: 18px;
    font-weight: 800;
}
.modal-header p {
    font-size: 11.5px;
    opacity: 0.8;
    margin-top: 2px;
}
.btn-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.btn-modal-close:hover {
    background: rgba(255, 255, 255, 0.35);
}
.modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.modal-stat-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
.modal-stat-box {
    background: var(--green-50);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 14px;
}
.modal-stat-box small {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    font-weight: 600;
}
.modal-stat-box strong {
    font-size: 16px;
    color: var(--green-950);
    font-weight: 800;
}
.modal-table {
    width: 100%;
    border-collapse: collapse;
}
.modal-table td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border-soft);
    font-size: 12px;
}
.modal-table td:first-child {
    color: var(--text-muted);
    width: 45%;
    font-weight: 500;
}
.modal-table td:last-child {
    color: var(--green-950);
    font-weight: 700;
}
