/* ============================================================
   SIKAP SUMSEL - Main Stylesheet
   Sistem Informasi Ketersediaan & Kerawanan Pangan
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Lora:ital,wght@0,400;0,600;1,400&display=swap');

/* ============================================================
   CSS VARIABLES
   ============================================================ */
:root {
    /* Brand Colors */
    --green-950: #052e16;
    --green-900: #14532d;
    --green-800: #166534;
    --green-700: #15803d;
    --green-600: #16a34a;
    --green-500: #22c55e;
    --green-400: #4ade80;
    --green-300: #86efac;
    --green-100: #dcfce7;
    --green-50:  #f0fdf4;

    --amber-500: #f59e0b;
    --amber-100: #fef3c7;
    --amber-50:  #fffbeb;

    --red-600:   #dc2626;
    --red-100:   #fee2e2;
    --red-50:    #fef2f2;

    --blue-600:  #2563eb;
    --blue-100:  #dbeafe;

    /* UI Colors */
    --bg-body:     #f1f5f0;
    --bg-card:     #ffffff;
    --bg-sidebar:  #052e16;
    --sidebar-w:   260px;

    --text-primary:   #0f172a;
    --text-secondary: #475569;
    --text-muted:     #94a3b8;

    --border:       #e2e8f0;
    --border-green: #bbf7d0;

    --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
    --shadow-md: 0 4px 16px rgba(0,0,0,.10);
    --shadow-lg: 0 8px 32px rgba(0,0,0,.12);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --transition: 0.2s ease;
    --font-sans: 'Plus Jakarta Sans', sans-serif;
    --font-serif: 'Lora', serif;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
    font-family: var(--font-sans);
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--green-700); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--green-500); }

img { max-width: 100%; display: block; }

/* ============================================================
   LAYOUT
   ============================================================ */
.layout {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--transition);
}

.page-content {
    flex: 1;
    padding: 28px 32px;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-sidebar);
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.1) transparent;
}

.sidebar-brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-brand-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}

.sidebar-brand-icon {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, var(--green-500), var(--green-400));
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.sidebar-brand-text h1 {
    font-size: 1rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -.3px;
    line-height: 1.2;
}

.sidebar-brand-text small {
    font-size: .65rem;
    color: rgba(255,255,255,.45);
    letter-spacing: .3px;
    line-height: 1.3;
    display: block;
}

.sidebar-user {
    padding: 14px 20px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--green-600), var(--green-400));
    display: flex; align-items: center; justify-content: center;
    font-size: .9rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.sidebar-user-info {
    overflow: hidden;
}

.sidebar-user-name {
    font-size: .8rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: .68rem;
    color: var(--green-400);
    font-weight: 500;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 12px;
}

.nav-label {
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: rgba(255,255,255,.3);
    padding: 14px 8px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,.65);
    font-size: .83rem;
    font-weight: 500;
    transition: all var(--transition);
    cursor: pointer;
    margin-bottom: 2px;
    white-space: nowrap;
}

.nav-item:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
}

.nav-item.active {
    background: var(--green-600);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(21,128,61,.35);
    position: relative;
}

/* Garis aksen di sisi kiri menu aktif */
.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 20%;
    height: 60%;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--green-300);
}

.nav-item.active:hover {
    background: var(--green-500);
}

.nav-item .nav-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,.08);
}

.sidebar-footer .nav-item {
    color: rgba(255,255,255,.5);
}

.sidebar-footer .nav-item:hover {
    background: rgba(220,38,38,.15);
    color: #fca5a5;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 32px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

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

.topbar-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .78rem;
    color: var(--text-muted);
}

.breadcrumb span { color: var(--text-secondary); font-weight: 500; }
.breadcrumb i { font-size: .6rem; }

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

.topbar-badge {
    position: relative;
    width: 38px; height: 38px;
    border-radius: var(--radius-sm);
    background: var(--green-50);
    border: 1px solid var(--border-green);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: all var(--transition);
    color: var(--green-700);
    font-size: .95rem;
}

.topbar-badge:hover { background: var(--green-100); }

.badge-dot {
    position: absolute;
    top: 6px; right: 6px;
    width: 8px; height: 8px;
    background: var(--red-600);
    border-radius: 50%;
    border: 2px solid white;
}

.topbar-date {
    font-size: .75rem;
    color: var(--text-muted);
    text-align: right;
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
    margin-bottom: 24px;
}

.page-header h2 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -.3px;
}

.page-header p {
    font-size: .83rem;
    color: var(--text-secondary);
    margin-top: 3px;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    padding: 18px 22px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    font-size: .92rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title .icon {
    width: 28px; height: 28px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: .8rem;
}

.card-body {
    padding: 20px 22px;
}

/* ============================================================
   STAT CARDS
   ============================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 20px 22px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    transition: all var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
}

.stat-card.green::before  { background: linear-gradient(90deg, var(--green-500), var(--green-400)); }
.stat-card.amber::before  { background: linear-gradient(90deg, var(--amber-500), #fbbf24); }
.stat-card.red::before    { background: linear-gradient(90deg, var(--red-600), #f87171); }
.stat-card.blue::before   { background: linear-gradient(90deg, var(--blue-600), #60a5fa); }

.stat-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    margin-bottom: 14px;
}

.stat-card.green .stat-icon  { background: var(--green-100); color: var(--green-700); }
.stat-card.amber .stat-icon  { background: var(--amber-100); color: #b45309; }
.stat-card.red .stat-icon    { background: var(--red-100);   color: var(--red-600); }
.stat-card.blue .stat-icon   { background: var(--blue-100);  color: var(--blue-600); }

.stat-value {
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 4px;
    letter-spacing: -.5px;
}

.stat-label {
    font-size: .78rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-change {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: .72rem;
    font-weight: 600;
    margin-top: 8px;
    padding: 2px 8px;
    border-radius: 100px;
}

.stat-change.up   { background: var(--green-100); color: var(--green-700); }
.stat-change.down { background: var(--red-100);   color: var(--red-600); }

/* ============================================================
   STATUS BADGES
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .2px;
}

.badge-aman    { background: var(--green-100); color: var(--green-800); }
.badge-waspada { background: var(--amber-100); color: #92400e; }
.badge-rawan   { background: var(--red-100);   color: #991b1b; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrapper {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .82rem;
}

.table th {
    background: var(--green-50);
    color: var(--green-900);
    font-weight: 700;
    font-size: .72rem;
    letter-spacing: .5px;
    text-transform: uppercase;
    padding: 10px 14px;
    text-align: left;
    white-space: nowrap;
    border-bottom: 2px solid var(--border-green);
}

.table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: middle;
}

.table tbody tr:hover { background: var(--green-50); }
.table tbody tr:last-child td { border-bottom: none; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-label span { color: var(--red-600); margin-left: 3px; }

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: .85rem;
    color: var(--text-primary);
    background: #fff;
    transition: all var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--green-500);
    box-shadow: 0 0 0 3px rgba(34,197,94,.12);
}

.form-control:disabled {
    background: var(--bg-body);
    color: var(--text-muted);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: .83rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
}

.btn-primary {
    background: var(--green-700);
    color: white;
}
.btn-primary:hover {
    background: var(--green-800);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(21,128,61,.3);
}

.btn-secondary {
    background: var(--bg-body);
    color: var(--text-secondary);
    border: 1.5px solid var(--border);
}
.btn-secondary:hover {
    background: var(--border);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--red-600);
    color: white;
}
.btn-danger:hover {
    background: #b91c1c;
    color: white;
}

.btn-sm {
    padding: 5px 12px;
    font-size: .75rem;
    border-radius: 6px;
}

.btn-icon {
    width: 34px; height: 34px;
    padding: 0;
    border-radius: 8px;
    justify-content: center;
}

/* ============================================================
   ALERTS / FLASH MESSAGES
   ============================================================ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: .83rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    border: 1px solid transparent;
}

.alert-success {
    background: var(--green-50);
    border-color: var(--border-green);
    color: var(--green-800);
}

.alert-danger {
    background: var(--red-50);
    border-color: #fecaca;
    color: #991b1b;
}

.alert-warning {
    background: var(--amber-50);
    border-color: #fde68a;
    color: #92400e;
}

/* ============================================================
   GRID LAYOUTS
   ============================================================ */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

/* ============================================================
   CHART CONTAINERS
   ============================================================ */
.chart-container {
    position: relative;
    height: 280px;
}

.chart-container-sm {
    position: relative;
    height: 200px;
}

/* ============================================================
   MAP
   ============================================================ */
#map {
    width: 100%;
    height: 420px;
    border-radius: var(--radius-md);
    z-index: 1;
}

.map-legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-size: .78rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-dot {
    width: 12px; height: 12px;
    border-radius: 50%;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    background: linear-gradient(135deg, var(--green-950) 0%, var(--green-800) 50%, var(--green-700) 100%);
    position: relative;
    overflow: hidden;
}

.login-wrapper::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Ccircle cx='30' cy='30' r='4'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.login-brand {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 60px;
    position: relative;
    z-index: 1;
}

.login-brand-icon {
    font-size: 3.5rem;
    margin-bottom: 20px;
}

.login-brand h1 {
    font-size: 2.2rem;
    font-weight: 800;
    color: white;
    line-height: 1.2;
    margin-bottom: 12px;
    letter-spacing: -.5px;
}

.login-brand h1 em {
    font-style: normal;
    color: var(--green-300);
    font-family: var(--font-serif);
}

.login-brand p {
    color: rgba(255,255,255,.6);
    font-size: .95rem;
    line-height: 1.7;
    max-width: 380px;
}

.login-features {
    margin-top: 40px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-feature-item {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255,255,255,.75);
    font-size: .85rem;
    font-weight: 500;
}

.login-feature-item i {
    color: var(--green-400);
    width: 16px;
}

.login-form-side {
    width: 440px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: white;
    padding: 60px 48px;
    position: relative;
    z-index: 1;
}

.login-form-side h2 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 6px;
    letter-spacing: -.3px;
}

.login-form-side p {
    color: var(--text-secondary);
    font-size: .85rem;
    margin-bottom: 32px;
}

.login-form-side .demo-creds {
    background: var(--green-50);
    border: 1px solid var(--border-green);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: .78rem;
    color: var(--text-secondary);
    margin-top: 20px;
    line-height: 1.7;
}

.login-form-side .demo-creds strong {
    color: var(--green-800);
    display: block;
    margin-bottom: 4px;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ============================================================
   UTILITIES
   ============================================================ */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.text-sm { font-size: .78rem; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
    .login-brand { display: none; }
    .login-form-side { width: 100%; max-width: 480px; margin: auto; }
    .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .main-content { margin-left: 0; }
    .page-content { padding: 20px 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .topbar { padding: 0 16px; }
}
