/* ============================================================
   PANEN CLASSIFIER — Main Stylesheet
   Colors: Brown #3D1C02, Gold #C8922A, Cream #FAF6EF
   ============================================================ */

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

:root {
  --brown:       #3D1C02;
  --brown-mid:   #4D2807;
  --brown-light: #6B3A0F;
  --gold:        #C8922A;
  --gold-light:  #E8B84B;
  --gold-bg:     #FDF3E0;
  --cream:       #FAF6EF;
  --white:       #FFFFFF;
  --gray:        #9CA3AF;
  --gray-light:  #E5E7EB;
  --gray-bg:     #F3F4F6;
  --red:         #DC4444;
  --red-light:   #FEE5E5;
  --green:       #2DAB66;
  --green-light: #E0F7EC;
  --orange:      #EE8833;
  --orange-light:#FFF1E0;
  --text-dark:   #1F1F1F;
  --text-mid:    #555555;
  --radius:      10px;
  --radius-lg:   14px;
  --shadow:      0 2px 8px rgba(0,0,0,0.08);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.12);
  --sidebar-w:   220px;
  --topbar-h:    64px;
}

body { font-family: 'Inter', sans-serif; font-size: 14px; color: var(--text-dark); background: var(--cream); }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

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

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  background: var(--brown);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px;
  background: var(--brown-mid);
  min-height: var(--topbar-h);
}
.logo-icon { font-size: 24px; width: 40px; height: 40px; background: var(--gold); border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.logo-title { display: block; font-size: 13px; font-weight: 700; color: var(--white); line-height: 1.2; }
.logo-sub   { display: block; font-size: 10px; font-weight: 400; color: var(--gold); }

.sidebar-nav { flex: 1; padding: 8px 0; overflow-y: auto; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  color: var(--white);
  font-size: 14px;
  transition: background 0.15s;
  position: relative;
}
.nav-item:hover { background: rgba(200,146,42,0.12); }
.nav-item.active {
  background: var(--gold);
  color: var(--brown);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 6px; bottom: 6px;
  width: 4px; background: var(--white); border-radius: 2px;
}
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 12px;
  border-top: 1px solid var(--brown-mid);
}
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--gold); color: var(--brown);
  font-weight: 700; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-info { flex: 1; overflow: hidden; }
.user-name  { display: block; font-size: 13px; font-weight: 600; color: var(--white); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { display: block; font-size: 11px; color: var(--gold); }
.logout-btn { color: var(--gray); font-size: 16px; padding: 4px; border-radius: 4px; transition: color 0.15s; }
.logout-btn:hover { color: var(--red); }

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

/* TOPBAR */
.topbar {
  height: var(--topbar-h);
  background: var(--white);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--gray-light);
  position: sticky; top: 0; z-index: 50;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.page-title { font-size: 20px; font-weight: 700; color: var(--brown); }
.page-sub   { font-size: 13px; color: var(--text-mid); margin-top: 2px; }

/* CONTENT AREA */
.content-area { padding: 24px 28px; flex: 1; }

/* FLASH MESSAGES */
.flash-container { padding: 0 28px 0; }
.flash {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-radius: var(--radius); margin-bottom: 8px;
  font-size: 14px;
}
.flash-error   { background: var(--red-light);    color: var(--red);   border-left: 4px solid var(--red); }
.flash-success { background: var(--green-light);  color: var(--green); border-left: 4px solid var(--green); }
.flash-info    { background: var(--gold-bg);      color: var(--brown); border-left: 4px solid var(--gold); }
.flash-close   { background: none; border: none; font-size: 16px; cursor: pointer; color: inherit; padding: 0 0 0 12px; }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stats-grid { display: grid; gap: 16px; }
.stats-grid-5 { grid-template-columns: repeat(5, 1fr); }
.stats-grid-4 { grid-template-columns: repeat(4, 1fr); }
.stats-grid-2 { grid-template-columns: repeat(2, 1fr); }

.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 16px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.stat-card-sm { padding: 12px 14px; }

.stat-accent {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 4px; border-radius: 2px 0 0 2px;
}
.stat-icon  { font-size: 22px; margin-bottom: 4px; padding-left: 12px; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1; padding-left: 12px; }
.stat-label { font-size: 13px; font-weight: 600; color: var(--text-dark); margin-top: 6px; padding-left: 12px; }
.stat-sub   { font-size: 11px; color: var(--text-mid); padding-left: 12px; }
.stat-card-sm .stat-value { font-size: 22px; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 700; color: var(--brown); }
.card-sub   { font-size: 12px; color: var(--text-mid); }
.ml-auto    { margin-left: auto; }
.card-cta   { background: var(--gold-bg); border: 1px solid var(--gold-light); }
.card-cta p { color: var(--text-mid); font-size: 13px; margin-top: 8px; line-height: 1.5; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:hover { opacity: 0.88; }
.btn:active { transform: scale(0.98); }

.btn-primary        { background: var(--gold);       color: var(--white); }
.btn-dark           { background: var(--brown-mid);  color: var(--gold);  }
.btn-gold           { background: var(--gold);       color: var(--white); }
.btn-outline        { background: transparent; border: 1.5px solid var(--gray-light); color: var(--text-mid); }
.btn-ghost          { background: var(--gray-bg);    color: var(--text-mid); }
.btn-danger         { background: var(--red);        color: var(--white); }
.btn-danger-outline { background: var(--red-light);  color: var(--red); border: 1.5px solid var(--red); }

.btn-full { width: 100%; justify-content: center; padding: 14px; font-size: 15px; }
.btn-sm   { padding: 5px 12px; font-size: 12px; font-weight: 600; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table thead tr {
  background: var(--brown-mid);
}
.table thead th {
  padding: 12px 14px;
  color: var(--white);
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}
.table tbody tr {
  border-bottom: 1px solid var(--gray-light);
  transition: background 0.1s;
}
.table tbody tr:nth-child(even) { background: var(--gray-bg); }
.table tbody tr:hover { background: var(--gold-bg); }
.table tbody td { padding: 13px 14px; color: var(--text-dark); vertical-align: middle; }
.table-footer { padding: 12px 4px 4px; font-size: 12px; color: var(--text-mid); }

.action-cell { white-space: nowrap; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.conf-text   { color: var(--green); font-weight: 700; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-stok-aman { background: var(--green-light);  color: var(--green);  }
.badge-understok { background: var(--red-light);    color: var(--red);    }
.badge-overstok  { background: var(--orange-light); color: var(--orange); }
.badge-role-admin  { background: var(--brown-mid); color: var(--gold);  padding: 4px 12px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-role-petani { background: var(--green-light); color: var(--green); padding: 4px 12px; border-radius: 20px; font-size: 11px; font-weight: 700; }

.status-dot      { font-size: 12px; font-weight: 600; }
.status-aktif    { color: var(--green); }
.status-nonaktif { color: var(--red); }

/* ============================================================
   FORMS
   ============================================================ */
.form-group  { display: flex; flex-direction: column; gap: 6px; }
.form-label  { font-size: 13px; font-weight: 600; color: var(--text-dark); }
.form-hint   { font-size: 11px; color: var(--text-mid); }
.form-input  {
  padding: 12px 14px;
  border: 1.5px solid var(--gray-light);
  border-radius: var(--radius);
  background: var(--gray-bg);
  font-size: 14px;
  color: var(--text-dark);
  transition: border-color 0.15s, background 0.15s;
  width: 100%;
}
.form-input:focus {
  outline: none;
  border-color: var(--gold);
  background: var(--white);
}
.form-grid-2   { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-actions  { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.form-row-between { display: flex; justify-content: space-between; align-items: center; }

.input-wrapper { position: relative; }
.input-wrapper .form-input { padding-right: 44px; }
.input-eye {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; font-size: 16px; cursor: pointer; color: var(--gray);
}

.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--text-mid); }

/* FORM CARD */
.form-card { background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); overflow: hidden; max-width: 900px; }
.form-card-header {
  display: flex; align-items: center; gap: 14px;
  padding: 20px 28px;
  background: var(--brown);
  color: var(--white);
  font-size: 20px;
}
.form-card form { padding: 28px; }
.form-card-title { font-size: 17px; font-weight: 700; color: var(--white); }
.form-card-sub   { font-size: 13px; color: var(--gold-light); margin-top: 2px; }

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar { background: var(--white); padding: 12px 16px; border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.filter-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filter-input  { max-width: 260px; }
.filter-select { max-width: 180px; }

/* ============================================================
   INFO BOX & CHIPS
   ============================================================ */
.info-box {
  display: flex; align-items: flex-start; gap: 10px;
  background: #EEF3FF; border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 13px; color: var(--brown);
  border-left: 4px solid var(--brown);
}
.chip-group { display: inline-flex; gap: 8px; margin-left: 10px; flex-wrap: wrap; }
.chip {
  background: var(--brown-mid); color: var(--gold);
  padding: 3px 12px; border-radius: 20px; font-size: 12px; font-weight: 600;
}

/* ============================================================
   RESULT PAGE
   ============================================================ */
.result-hero {
  display: flex; align-items: flex-start; gap: 24px;
  background: var(--white); border-radius: var(--radius-lg);
  padding: 28px; box-shadow: var(--shadow-md);
  border-top: 8px solid var(--green);
}
.result-hero.result-red    { border-top-color: var(--red);    }
.result-hero.result-orange { border-top-color: var(--orange); }
.result-hero.result-green  { border-top-color: var(--green);  }

.result-icon-wrap {
  font-size: 52px; width: 90px; height: 90px;
  border-radius: 50%; background: var(--green-light);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.result-hero.result-red    .result-icon-wrap { background: var(--red-light); }
.result-hero.result-orange .result-icon-wrap { background: var(--orange-light); }

.result-info { flex: 1; }
.result-label { font-size: 32px; font-weight: 800; color: var(--green); line-height: 1; }
.result-hero.result-red    .result-label { color: var(--red); }
.result-hero.result-orange .result-label { color: var(--orange); }
.result-model { font-size: 13px; color: var(--text-mid); margin-top: 4px; }

.result-conf-row { display: flex; align-items: center; gap: 14px; margin-top: 16px; }
.result-conf-label { font-size: 13px; font-weight: 600; color: var(--text-dark); white-space: nowrap; }
.conf-bar-wrap  { display: flex; align-items: center; gap: 10px; flex: 1; }
.conf-bar-track { flex: 1; height: 10px; background: var(--gray-light); border-radius: 5px; overflow: hidden; }
.conf-bar-fill  { height: 100%; border-radius: 5px; transition: width 0.6s ease; }
.conf-bar-green  { background: var(--green); }
.conf-bar-red    { background: var(--red); }
.conf-bar-orange { background: var(--orange); }
.conf-pct { font-size: 18px; font-weight: 800; color: var(--green); white-space: nowrap; }
.result-hero.result-red    .conf-pct { color: var(--red); }
.result-hero.result-orange .conf-pct { color: var(--orange); }

.result-rek-badge {
  display: inline-block; margin-top: 14px;
  padding: 8px 18px; border-radius: 20px;
  font-size: 13px; font-weight: 600;
}
.result-rek-green  { background: var(--green-light);  color: var(--green); }
.result-rek-red    { background: var(--red-light);    color: var(--red); }
.result-rek-orange { background: var(--orange-light); color: var(--orange); }

.result-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

/* DETAIL TABLE */
.detail-table { width: 100%; border-collapse: collapse; }
.detail-table tr { border-bottom: 1px solid var(--gray-light); }
.dt-label { padding: 11px 0; font-size: 13px; color: var(--text-mid); width: 40%; }
.dt-val   { padding: 11px 0; font-size: 13px; font-weight: 600; color: var(--text-dark); }

/* FEATURE LIST */
.feature-list { display: flex; flex-direction: column; gap: 14px; }
.feature-item {}
.fi-name { font-size: 13px; color: var(--text-mid); margin-bottom: 4px; }
.fi-val  { font-size: 15px; font-weight: 700; color: var(--brown); margin-bottom: 6px; }
.fi-bar  { height: 6px; background: var(--gray-light); border-radius: 3px; overflow: hidden; }
.fi-fill { height: 100%; background: var(--gold); border-radius: 3px; }

/* ============================================================
   ACTION BADGES (dashboard admin)
   ============================================================ */
.action-badges { display: flex; gap: 12px; flex-wrap: wrap; }
.action-badge {
  flex: 1; min-width: 120px;
  padding: 12px 16px; border-radius: var(--radius);
  font-size: 13px;
}
.action-badge-red    { background: var(--red-light);    color: var(--red); }
.action-badge-green  { background: var(--green-light);  color: var(--green); }
.action-badge-orange { background: var(--orange-light); color: var(--orange); }
.ab-label { font-weight: 700; }
.ab-count { font-size: 11px; margin-top: 2px; }

/* BAR ROWS (top lokasi) */
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.bar-label { font-size: 13px; color: var(--text-dark); width: 90px; flex-shrink: 0; }
.bar-track { flex: 1; height: 8px; background: var(--gray-light); border-radius: 4px; overflow: hidden; }
.bar-fill  { height: 100%; background: var(--gold); border-radius: 4px; }
.bar-val   { font-size: 12px; font-weight: 700; color: var(--text-mid); width: 30px; text-align: right; }

/* ============================================================
   LAYOUT HELPERS
   ============================================================ */
.row-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

/* EMPTY STATE */
.empty-state { text-align: center; padding: 48px 20px; }
.empty-icon  { font-size: 48px; margin-bottom: 12px; }
.empty-state p { color: var(--text-mid); font-size: 14px; }
.empty-text  { color: var(--text-mid); font-size: 13px; padding: 16px 0; }

/* DONUT LEGEND */
.donut-wrap   { padding: 8px 0; }
.donut-legend { display: flex; flex-direction: column; gap: 12px; }
.dl-item      { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.dl-dot       { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.dl-item strong { margin-left: auto; font-weight: 700; }

/* CRUD NOTE */
.crud-note { font-size: 12px; color: var(--text-mid); margin-top: 16px; padding: 0 4px; }
.username-text { font-size: 13px; font-family: monospace; background: var(--gray-bg); padding: 2px 8px; border-radius: 4px; }

/* ============================================================
   AUTH PAGES
   ============================================================ */
.auth-body   { background: var(--brown); min-height: 100vh; display: flex; align-items: stretch; }
.auth-layout { display: flex; width: 100%; min-height: 100vh; }

.auth-left {
  width: 45%;
  background: linear-gradient(135deg, rgba(61,28,2,0.95) 0%, rgba(61,28,2,0.5) 100%);
  display: flex; flex-direction: column; justify-content: center;
  padding: 48px 40px;
  position: relative;
  overflow: hidden;
}
.auth-left::before {
  content: '';
  position: absolute; top: -80px; left: -80px;
  width: 320px; height: 320px;
  background: rgba(200,146,42,0.12);
  border-radius: 50%;
}
.auth-left::after {
  content: '';
  position: absolute; bottom: -60px; right: -60px;
  width: 240px; height: 240px;
  background: rgba(200,146,42,0.08);
  border-radius: 50%;
}
.auth-left-content { position: relative; z-index: 1; }

.auth-logo { display: flex; align-items: center; gap: 14px; margin-bottom: 32px; }
.auth-logo-icon {
  width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.auth-logo-icon img { width: 100%; height: 100%; object-fit: contain; }
.auth-logo-icon img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.35); }
.auth-logo-title { display: block; font-size: 20px; font-weight: 800; color: var(--white); }
.auth-logo-sub   { display: block; font-size: 12px; color: var(--gold-light); margin-top: 2px; }

.auth-tagline { font-size: 18px; line-height: 1.6; color: var(--gold-light); font-style: italic; margin-bottom: 40px; }

.auth-steps { display: flex; flex-direction: column; gap: 16px; }
.auth-step  { display: flex; align-items: center; gap: 14px; }
.step-num {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--gold); color: var(--brown);
  font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.auth-step span:last-child { font-size: 14px; color: var(--white); }

.auth-right {
  flex: 1;
  background: var(--white);
  display: flex; align-items: center; justify-content: center;
  padding: 48px 40px;
}
.auth-form-wrap { width: 100%; max-width: 440px; }

.auth-heading { font-size: 26px; font-weight: 800; color: var(--brown); margin-bottom: 6px; }
.auth-desc    { font-size: 14px; color: var(--text-mid); margin-bottom: 28px; line-height: 1.5; }
.auth-footer-text { text-align: center; font-size: 14px; color: var(--text-mid); margin-top: 20px; }
.link-gold  { color: var(--gold); font-weight: 700; }

/* RESPONSIVE: DASHBOARD / CONTENT PAGES (mobile) */
@media (max-width: 900px) {
  html, body { overflow-x: hidden; }
  .app-layout { overflow-x: hidden; }
  .main-content { min-width: 0; }
  .content-area { padding: 16px; min-width: 0; }
  .flash-container { padding: 0 16px; }

  .topbar { flex-wrap: wrap; height: auto; padding: 12px 16px; row-gap: 10px; }
  .topbar-right { flex-wrap: wrap; gap: 8px; width: 100%; justify-content: flex-start; }

  .stats-grid-5,
  .stats-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .stats-grid-2 { grid-template-columns: 1fr; }

  .row-2col { grid-template-columns: 1fr; }
  .form-grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .stats-grid-5,
  .stats-grid-4 { grid-template-columns: 1fr; }
  .stat-value { font-size: 22px; }
  .btn { padding: 9px 16px; font-size: 13px; }

  .filter-form { flex-direction: column; align-items: stretch; }
  .filter-input,
  .filter-select { max-width: 100%; width: 100%; }
  .filter-form .btn { width: 100%; justify-content: center; }
}

/* RESPONSIVE: AUTH PAGES (mobile) */
@media (max-width: 800px) {
  .auth-layout { flex-direction: column; }
  .auth-left {
    width: 100%;
    padding: 28px 24px;
    min-height: auto;
  }
  .auth-left-content { padding-bottom: 8px; }
  .auth-tagline { font-size: 15px; margin-bottom: 20px; }
  .auth-steps { display: none; }
  .auth-right { padding: 32px 22px; }
}

/* ============================================================
   CODE
   ============================================================ */
code { font-family: 'Courier New', monospace; }
