/* ============================================================================
   SURVEI HARGA — Design System: "Ledger" (warm editorial)
   ----------------------------------------------------------------------------
   Grounding: this app is a price ledger for field surveyors and branch admins,
   not a marketing SaaS product. The visual language borrows from price
   ledgers, market bulletins and till receipts rather than generic dashboard
   chrome: hairline rules instead of card shadows, right-aligned tabular
   figures instead of decorative numerals, tag-shaped badges instead of pill
   badges. Deliberately NOT the cream-background + terracotta-accent + serif
   display combination that has become the default "AI-generated" look —
   the palette here sits in stone/oxblood/mustard/bottle-green instead.
   ============================================================================ */

:root {
  /* --- Paper & ink --- */
  --ink:          #2A2118;
  --ink-soft:     #4A3D30;
  --muted:        #6E6255;
  --paper:        #E9E1D0;   /* app background: warm stone/putty, not glossy cream */
  --surface:      #FBF7EE;   /* card/panel background */
  --surface-alt:  #F1E9D8;   /* zebra stripe / subtle recessed areas */
  --border:       #D8CBAE;
  --border-soft:  #E4D9C0;

  /* --- Accent family (all warm, each reserved for its own meaning) --- */
  --accent:       #7A2E22;   /* oxblood/brick — primary actions, links */
  --accent-hover: #5E2118;
  --accent-soft:  #F0DCD2;
  --green:        #3F5D46;   /* bottle green — positive / murah / aktif */
  --green-hover:  #304939;
  --green-soft:   #DEE6DA;
  --gold:         #96701F;   /* mustard — warning / caution */
  --gold-hover:   #7A5B18;
  --gold-soft:    #EEE1BE;
  --danger:       #AE3527;   /* brighter brick-red — destructive / lebih mahal */
  --danger-hover: #8C2A1F;
  --danger-soft:  #F2DAD1;
  --slate:        #5B5346;   /* neutral secondary (replaces bootstrap grey) */
  --slate-soft:   #E7DFCB;

  /* --- Sidebar (ledger cover) --- */
  --sidebar-bg:        #211A14;
  --sidebar-bg-active: #362A1E;
  --sidebar-ink:       #EBE1CE;
  --sidebar-muted:     #A6957D;
  --sidebar-border:    #3A2E22;

  /* --- Shape & type --- */
  --radius-sm: 3px;
  --radius-md: 4px;
  --radius-lg: 6px;
  --font-serif: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  --font-sans: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  --sidebar-width: 258px;
  --topbar-height: 60px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--paper);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

body { font-size: 15px; line-height: 1.5; }

h1, h2, h3, h4, h5, h6,
.panel-title, .sidebar-brand, .topbar-title, .login-brand {
  font-family: var(--font-serif);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

/* Price/quantity figures line up like a ledger column */
.money, .num-tabular, td.money, .stat-value {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

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

/* ---------------------------------------------------------------------- */
/* Sidebar                                                                 */
/* ---------------------------------------------------------------------- */
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  position: fixed;
  top: 0; bottom: 0; left: 0;
  overflow-y: auto;
  z-index: 1040;
  transition: transform .2s ease;
  border-right: 1px solid var(--sidebar-border);
}

.sidebar-brand {
  height: var(--topbar-height);
  display: flex;
  align-items: baseline;
  gap: .5rem;
  padding: 0 1.15rem;
  font-size: 1.2rem;
  font-style: italic;
  color: var(--sidebar-ink);
  border-bottom: 1px solid var(--sidebar-border);
}
.sidebar-brand i { font-style: normal; color: var(--gold); font-size: 1rem; }

.sidebar-nav { padding: 1rem 0 2rem; }
.sidebar-nav .nav-section {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: .82rem;
  color: var(--sidebar-muted);
  padding: 1.1rem 1.15rem .4rem;
  border-top: 1px solid var(--sidebar-border);
  margin-top: .4rem;
}
.sidebar-nav .nav-section:first-child { border-top: none; margin-top: 0; }
.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: .6rem;
  color: var(--sidebar-ink);
  padding: .55rem 1.15rem;
  font-size: .92rem;
  border-left: 3px solid transparent;
}
.sidebar-nav .nav-link i { color: var(--sidebar-muted); width: 1.1em; text-align: center; }
.sidebar-nav .nav-link:hover { background: var(--sidebar-bg-active); }
.sidebar-nav .nav-link.active {
  background: var(--sidebar-bg-active);
  border-left-color: var(--gold);
}
.sidebar-nav .nav-link.active i { color: var(--gold); }

/* ---------------------------------------------------------------------- */
/* Topbar / content shell                                                  */
/* ---------------------------------------------------------------------- */
.app-content { margin-left: var(--sidebar-width); flex: 1; min-width: 0; display: flex; flex-direction: column; }

.app-topbar {
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: .75rem;
  position: sticky;
  top: 0;
  z-index: 1020;
}
.btn-burger { display: none; border: none; background: transparent; font-size: 1.4rem; padding: .25rem .4rem; color: var(--ink); }
.topbar-title { font-size: 1.15rem; flex: 1; }

.app-main { padding: 1.4rem; flex: 1; }
.app-footer { text-align: center; padding: 1.1rem; color: var(--muted); font-size: .8rem; font-family: var(--font-serif); font-style: italic; }

.app-overlay { display: none; position: fixed; inset: 0; background: rgba(33,26,20,.45); z-index: 1030; }

/* ---------------------------------------------------------------------- */
/* Panels — bordered paper, not shadowed cards                            */
/* ---------------------------------------------------------------------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.35rem;
  margin-bottom: 1.25rem;
}
.panel-title {
  font-size: 1.15rem;
  margin-bottom: 1rem;
  padding-bottom: .6rem;
  border-bottom: 1px solid var(--border);
}

/* ---------------------------------------------------------------------- */
/* Buttons                                                                 */
/* ---------------------------------------------------------------------- */
.btn { border-radius: var(--radius-sm); font-weight: 500; }
.btn:focus, .btn:focus-visible { box-shadow: 0 0 0 .2rem var(--accent-soft); }

.btn-primary {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--accent);
  --bs-btn-border-color: var(--accent);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--accent-hover);
  --bs-btn-hover-border-color: var(--accent-hover);
  --bs-btn-active-bg: var(--accent-hover);
  --bs-btn-active-border-color: var(--accent-hover);
  --bs-btn-disabled-bg: var(--accent);
  --bs-btn-disabled-border-color: var(--accent);
  --bs-btn-focus-shadow-rgb: 122,46,34;
}
.btn-outline-primary {
  --bs-btn-color: var(--accent);
  --bs-btn-border-color: var(--accent);
  --bs-btn-hover-bg: var(--accent);
  --bs-btn-hover-border-color: var(--accent);
  --bs-btn-active-bg: var(--accent);
  --bs-btn-active-border-color: var(--accent);
}
.btn-success {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--green);
  --bs-btn-border-color: var(--green);
  --bs-btn-hover-bg: var(--green-hover);
  --bs-btn-hover-border-color: var(--green-hover);
  --bs-btn-active-bg: var(--green-hover);
  --bs-btn-active-border-color: var(--green-hover);
}
.btn-secondary {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--slate);
  --bs-btn-border-color: var(--slate);
  --bs-btn-hover-bg: var(--ink-soft);
  --bs-btn-hover-border-color: var(--ink-soft);
  --bs-btn-active-bg: var(--ink-soft);
  --bs-btn-active-border-color: var(--ink-soft);
}
.btn-outline-secondary {
  --bs-btn-color: var(--slate);
  --bs-btn-border-color: var(--border);
  --bs-btn-hover-bg: var(--slate);
  --bs-btn-hover-border-color: var(--slate);
  --bs-btn-active-bg: var(--slate);
  --bs-btn-active-border-color: var(--slate);
}
.btn-outline-danger {
  --bs-btn-color: var(--danger);
  --bs-btn-border-color: var(--danger);
  --bs-btn-hover-bg: var(--danger);
  --bs-btn-hover-border-color: var(--danger);
  --bs-btn-active-bg: var(--danger);
  --bs-btn-active-border-color: var(--danger);
}
.btn-outline-warning {
  --bs-btn-color: var(--gold);
  --bs-btn-border-color: var(--gold);
  --bs-btn-hover-bg: var(--gold);
  --bs-btn-hover-border-color: var(--gold);
  --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: var(--gold);
  --bs-btn-active-border-color: var(--gold);
}

/* ---------------------------------------------------------------------- */
/* Badges — rectangular tags with a colored flag, not filled pills        */
/* ---------------------------------------------------------------------- */
.badge {
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: .74rem;
  padding: .32em .55em;
  letter-spacing: .01em;
}
.text-bg-primary { background-color: var(--accent-soft) !important; color: var(--accent) !important; border: 1px solid var(--accent); }
.text-bg-success { background-color: var(--green-soft) !important; color: var(--green) !important; border: 1px solid var(--green); }
.text-bg-danger  { background-color: var(--danger-soft) !important; color: var(--danger) !important; border: 1px solid var(--danger); }
.text-bg-secondary { background-color: var(--slate-soft) !important; color: var(--slate) !important; border: 1px solid var(--border); }
.text-bg-light { background-color: var(--surface-alt) !important; color: var(--muted) !important; border: 1px solid var(--border); }

/* ---------------------------------------------------------------------- */
/* Alerts                                                                  */
/* ---------------------------------------------------------------------- */
.alert { border-radius: var(--radius-md); border-width: 1px; font-size: .92rem; }
.alert-danger  { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.alert-success { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.alert-info    { background: var(--slate-soft); border-color: var(--border); color: var(--ink-soft); }
.alert-warning { background: var(--gold-soft); border-color: var(--gold); color: var(--gold-hover); }

/* ---------------------------------------------------------------------- */
/* Forms                                                                   */
/* ---------------------------------------------------------------------- */
.form-control, .form-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: .94rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 .2rem var(--accent-soft);
}
.form-label { font-size: .86rem; font-weight: 600; color: var(--ink-soft); margin-bottom: .3rem; }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-check-input:focus { border-color: var(--accent); box-shadow: 0 0 0 .2rem var(--accent-soft); }
::placeholder { color: var(--muted); opacity: .8; }

/* ---------------------------------------------------------------------- */
/* Tables — ledger rows: warm zebra, right-aligned tabular figures         */
/* ---------------------------------------------------------------------- */
.table { color: var(--ink); font-size: .89rem; }
.table > :not(caption) > * > * { border-bottom-color: var(--border); }
.table-striped > tbody > tr:nth-of-type(odd) > * { background: var(--surface-alt); }
.table thead th {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: .78rem;
  color: var(--muted);
  border-bottom: 2px solid var(--ink) !important;
  white-space: nowrap;
}
.table-bordered, .table-bordered th, .table-bordered td { border-color: var(--border); }
.table-responsive { border-radius: var(--radius-md); }

/* dropdown */
.dropdown-menu { border: 1px solid var(--border); border-radius: var(--radius-md); font-size: .9rem; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--surface-alt); }
.dropdown-item.active, .dropdown-item:active { background: var(--accent); color: #fff; }

/* modal */
.modal-content { border: 1px solid var(--border); border-radius: var(--radius-md); }
.modal-header { border-bottom: 1px solid var(--border); }
.modal-footer { border-top: 1px solid var(--border); }
.modal-title { font-size: 1.1rem; }

/* stat cards on dashboard — paper surface with a colored ledger flag, not a solid gradient tile */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 1rem 1.2rem;
  color: var(--ink);
}
.stat-card .stat-value { font-family: var(--font-serif); font-size: 1.9rem; font-weight: 600; line-height: 1.1; }
.stat-card .stat-label { font-size: .8rem; color: var(--muted); margin-top: .2rem; }
.stat-card.accent-green  { border-left-color: var(--green); }
.stat-card.accent-gold   { border-left-color: var(--gold); }
.stat-card.accent-slate  { border-left-color: var(--slate); }

table.dataTable { font-size: .875rem; }
.dt-filter-row input, .dt-filter-row select { font-size: .8rem; padding: .3rem .45rem; }

/* DataTables paging / info text recolor to match ink/paper palette */
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter { color: var(--muted); font-size: .85rem; }
.dataTables_wrapper .page-link { color: var(--accent); border-color: var(--border); }
.dataTables_wrapper .page-item.active .page-link { background: var(--accent); border-color: var(--accent); }
.dataTables_wrapper .page-item.disabled .page-link { color: var(--muted); }

/* Photo preview thumbnails (nota / survei foto) */
.photo-preview {
  width: 100%; max-width: 220px; border-radius: var(--radius-md); border: 1px solid var(--border);
  display: block; margin-top: .5rem;
}

/* ---------------------------------------------------------------------- */
/* Mobile / tablet — surveyor works from the field                        */
/* ---------------------------------------------------------------------- */
@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); }
  .app-sidebar.show { transform: translateX(0); }
  .app-content { margin-left: 0; }
  .btn-burger { display: inline-block; }
  .app-overlay.show { display: block; }
  .app-main { padding: 1rem; }
}

@media (max-width: 767.98px) {
  /* Touch targets: keep every interactive control comfortably tappable */
  .btn, .form-control, .form-select, .page-link {
    min-height: 44px;
  }
  .form-check-input { min-height: 1.25em; } /* checkboxes/radios stay their native small size */
  .btn-sm { min-height: 38px; }
  input[type="date"], input[type="text"], input[type="number"], input[type="file"], select {
    font-size: 16px; /* prevents iOS auto-zoom on focus */
  }
  .panel { padding: 1rem; border-radius: var(--radius-md); }
  .topbar-title { font-size: 1rem; }
  .table { font-size: .84rem; }
}

@media (max-width: 575.98px) {
  .app-main { padding: .8rem; }
  .panel-title { font-size: 1.05rem; }
}
