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

/* Prevent layout shift from font loading */
@font-face {
  font-family: 'Playfair Display';
  font-display: swap;
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-display: swap;
}

:root {
  /* Surface & Background */
  --surface: #f9faf2;
  --surface-dim: #d9dbd3;
  --surface-bright: #f9faf2;
  --surface-container-lowest: #ffffff;
  --surface-container-low: #f3f4ed;
  --surface-container: #edefe7;
  --surface-container-high: #e7e9e1;
  --surface-container-highest: #e2e3dc;
  --on-surface: #191c18;
  --on-surface-variant: #42493e;
  --inverse-surface: #2e312c;
  --inverse-on-surface: #f0f1ea;
  
  /* Borders & Outlines */
  --outline: #72796e;
  --outline-variant: #c2c9bb;
  --border-light: #e8e5df;

  /* Brand Primary */
  --surface-tint: #3b6934;
  --primary: #154212;
  --on-primary: #ffffff;
  --primary-container: #2d5a27;
  --on-primary-container: #9dd090;
  --inverse-primary: #a1d494;

  /* Secondary */
  --secondary: #3e6842;
  --on-secondary: #ffffff;
  --secondary-container: #bfefbe;
  --on-secondary-container: #446e47;

  /* Tertiary */
  --tertiary: #323c35;
  --on-tertiary: #ffffff;
  --tertiary-container: #48534c;
  --on-tertiary-container: #bbc6bd;

  /* Error & Warning */
  --error: #ba1a1a;
  --on-error: #ffffff;
  --error-container: #ffdad6;
  --on-error-container: #93000a;

  /* Fixed Variants */
  --primary-fixed: #bcf0ae;
  --primary-fixed-dim: #a1d494;
  --on-primary-fixed: #002201;
  --on-primary-fixed-variant: #23501e;
  --secondary-fixed: #bfefbe;
  --secondary-fixed-dim: #a4d2a4;
  --on-secondary-fixed: #002107;
  --on-secondary-fixed-variant: #274f2c;
  --tertiary-fixed: #dae5dc;
  --tertiary-fixed-dim: #bec9c0;
  --on-tertiary-fixed: #141e18;
  --on-tertiary-fixed-variant: #3f4942;
  --background: #f9faf2;
  --on-background: #191c18;
  --surface-variant: #e2e3dc;

  /* Fonts */
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* Elevation */
  --shadow-soft: 0 10px 25px -5px rgba(31, 41, 35, 0.05);
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.03);
}

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

html {
  overflow-x: hidden;
  scroll-behavior: smooth;
  height: 100%;
}

body {
  font-family: var(--font-sans);
  background-color: var(--background);
  color: var(--on-surface);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100%;
}

p {
  line-height: 1.65;
  margin-bottom: 12px;
}

/* Anti-FOUC: hide until fonts + icons render */
body:not(.is-loaded) .main-content-wrapper {
  opacity: 0;
}
body.is-loaded .main-content-wrapper {
  opacity: 1;
  transition: opacity 0.2s ease-out;
}

/* Typography Helpers */
.font-serif { font-family: var(--font-serif); }
.font-sans { font-family: var(--font-sans); }

.display-lg { font-family: var(--font-serif); font-size: 32px; font-weight: 700; line-height: 44px; letter-spacing: -0.02em; margin-bottom: 10px; }
.display-md { font-family: var(--font-serif); font-size: 24px; font-weight: 700; line-height: 34px; letter-spacing: -0.01em; margin-bottom: 8px; }
.headline-lg { font-family: var(--font-serif); font-size: 22px; font-weight: 600; line-height: 32px; margin-bottom: 10px; }
.title-lg { font-family: var(--font-serif); font-size: 18px; font-weight: 700; line-height: 28px; letter-spacing: -0.01em; margin-bottom: 6px; }
.body-lg { font-family: var(--font-sans); font-size: 15px; font-weight: 400; line-height: 26px; }
.body-md { font-family: var(--font-sans); font-size: 14px; font-weight: 400; line-height: 24px; }
.label-md { font-family: var(--font-sans); font-size: 11px; font-weight: 600; line-height: 18px; letter-spacing: 0.08em; text-transform: uppercase; }
.caption { font-family: var(--font-sans); font-size: 11px; font-weight: 500; line-height: 17px; letter-spacing: 0.015em; display: inline-block; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-lg);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease-in-out;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--primary);
  color: var(--on-primary);
}
.btn-primary:hover {
  background-color: var(--primary-container);
  box-shadow: var(--shadow-soft);
}

.btn-secondary {
  background-color: var(--secondary-container);
  color: var(--on-secondary-container);
}
.btn-secondary:hover {
  background-color: var(--secondary-fixed-dim);
}

.btn-outline {
  background-color: transparent;
  border-color: var(--outline-variant);
  color: var(--on-surface-variant);
}
.btn-outline:hover {
  background-color: var(--surface-container);
  border-color: var(--outline);
}

.btn-danger {
  background-color: var(--error);
  color: var(--on-error);
}
.btn-danger:hover {
  background-color: #93000a;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: var(--radius-md);
}

/* Organic Modernism Cards */
.card {
  background-color: var(--surface-container-lowest);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-2xl);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease;
}
.card:hover {
  box-shadow: var(--shadow-soft);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 22px;
}

.form-label {
  display: block;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  color: var(--on-surface);
  margin-bottom: 6px;
  line-height: 18px;
  letter-spacing: 0.02em;
}

.form-control, .form-select {
  width: 100%;
  padding: 10px 15px;
  background-color: var(--surface-bright);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-lg);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.5;
  color: var(--on-surface);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus, .form-select:focus {
  border-color: var(--surface-tint);
  box-shadow: 0 0 0 3px rgba(59, 105, 52, 0.15);
}

/* Custom Table Styling */
.table-container {
  background-color: var(--surface-container-lowest);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.table th {
  background-color: var(--surface-container-low);
  color: var(--on-surface-variant);
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 12px 18px;
  line-height: 1.5;
  border-bottom: 1px solid var(--border-light);
}

.table td {
  padding: 12px 18px;
  line-height: 1.55;
  border-bottom: 1px solid var(--surface-container-low);
  font-size: 13px;
  color: var(--on-surface);
}

.table tbody tr:hover {
  background-color: var(--surface-container-lowest);
}

/* Badges & Chips */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-success {
  background-color: var(--secondary-container);
  color: var(--on-secondary-container);
}

.badge-warning {
  background-color: #fef3c7;
  color: #92400e;
}

.badge-danger {
  background-color: var(--error-container);
  color: var(--on-error-container);
}

.badge-info {
  background-color: var(--tertiary-fixed);
  color: var(--on-tertiary-fixed-variant);
}

.badge-primary {
  background-color: var(--primary-fixed);
  color: var(--on-primary-fixed-variant);
}

/* Computation Matrix Style for SAW */
.saw-matrix-box {
  background-color: var(--surface-container-low);
  border: 1px dashed var(--outline-variant);
  border-radius: var(--radius-xl);
  padding: 16px;
  margin-bottom: 20px;
  overflow-x: auto;
}

/* Stepper Progress Bar */
.stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 30px;
  position: relative;
}

.stepper-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 2;
  background-color: var(--surface);
  padding: 0 12px;
}

.stepper-number {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--surface-container-high);
  color: var(--on-surface-variant);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
}

.stepper-item.active .stepper-number {
  background-color: var(--primary);
  color: var(--on-primary);
}

.stepper-item.completed .stepper-number {
  background-color: var(--secondary);
  color: var(--on-secondary);
}

.stepper-line {
  position: absolute;
  top: 18px;
  left: 10%;
  right: 10%;
  height: 3px;
  background-color: var(--surface-container-high);
  z-index: 1;
}

/* Layout Elements */
.app-wrapper {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.sidebar {
  width: 260px;
  min-width: 260px;
  max-width: 260px;
  background-color: var(--primary);
  color: var(--on-primary);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding: 20px 14px;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  z-index: 100;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 36px;
  padding-left: 8px;
}

.sidebar-brand {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.sidebar-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.sidebar-item a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: var(--radius-lg);
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  background-color: transparent;
  border: 1px solid transparent;
  box-shadow: none;
  outline: none;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.sidebar-item:not(.active) a:hover {
  background-color: rgba(255, 255, 255, 0.10);
  color: #ffffff;
  border-color: transparent;
  box-shadow: none;
}

.sidebar-item.active a {
  background-color: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: none;
  outline: none;
}

.sidebar-item.active a:hover {
  background-color: rgba(255, 255, 255, 0.22);
  color: #ffffff;
  box-shadow: none;
}

.sidebar-item a:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.6);
  outline-offset: 2px;
  box-shadow: none;
}

.main-content-wrapper {
  flex: 1 1 0%;
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: calc(100vw - 260px);
  margin-left: 260px;
  background-color: var(--background);
  overflow-x: hidden;
  min-height: 100vh;
}

.topbar {
  height: 56px;
  min-height: 56px;
  background-color: var(--surface-container-lowest);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.content-body {
  padding: 24px 28px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* Quick Access Card Grid */
.demo-quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 20px;
}

/* Lucide icon sizing to prevent CLS */
[data-lucide] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar [data-lucide] {
  width: 18px;
  height: 18px;
}

/* Smooth page entrance */
.content-body {
  animation: contentSlideIn 0.25s ease-out;
}
@keyframes contentSlideIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Sidebar scrollbar styling */
.sidebar::-webkit-scrollbar {
  width: 4px;
}
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.2);
  border-radius: 4px;
}
.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

/* ============================================
   HAMBURGER MENU BUTTON
   ============================================ */
.hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  border-radius: var(--radius-md);
  transition: background-color 0.15s ease;
  flex-shrink: 0;
}
.hamburger-btn:hover {
  background-color: var(--surface-container);
}
.hamburger-btn svg {
  width: 22px;
  height: 22px;
  color: var(--on-surface);
}

/* Sidebar close button (mobile only) */
.sidebar-close-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255,255,255,0.15);
  color: #ffffff;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background-color 0.15s ease;
  flex-shrink: 0;
}
.sidebar-close-btn:hover {
  background: rgba(255,255,255,0.25);
}
.sidebar-close-btn svg {
  width: 18px;
  height: 18px;
}

/* Sidebar overlay backdrop */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 99;
  opacity: 0;
  /* Overlay tersembunyi tidak boleh menyerap klik (menyebabkan hamburger tidak bisa diklik) */
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.sidebar-overlay.active {
  opacity: 1;
  /* Hanya aktif saat sidebar terbuka */
  pointer-events: auto;
}

/* ============================================
   RESPONSIVE: TABLET (≤1024px)
   ============================================ */
@media (max-width: 1024px) {
  .sidebar {
    width: 240px;
    min-width: 240px;
    max-width: 240px;
  }
  .main-content-wrapper {
    width: calc(100vw - 240px);
    margin-left: 240px;
  }
  .topbar {
    padding: 0 20px;
  }
  .content-body {
    padding: 20px;
  }
  .demo-quick-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
}

/* ============================================
   RESPONSIVE: MOBILE (≤768px) — HAMBURGER MODE
   ============================================ */
@media (max-width: 768px) {
  /* Show hamburger button */
  .hamburger-btn {
    display: flex;
  }

  /* Show sidebar close button */
  .sidebar-close-btn {
    display: flex;
  }

  /* Sidebar becomes an off-canvas drawer */
  .sidebar {
    width: 280px;
    min-width: 280px;
    max-width: 280px;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 200;
  }
  .sidebar.open {
    transform: translateX(0);
  }

  /* Show overlay when sidebar is open */
  .sidebar-overlay {
    display: block;
    /* Keluarkan overlay dari hit-testing saat tertutup agar klik hamburger tidak terhalang */
    visibility: hidden;
  }
  .sidebar-overlay.active {
    visibility: visible;
  }

  /* Main content takes full width */
  .main-content-wrapper {
    width: 100%;
    margin-left: 0;
    max-width: 100vw;
  }

  /* Topbar adjustments */
  .topbar {
    height: 52px;
    min-height: 52px;
    padding: 0 16px;
    gap: 8px;
  }

  /* Content body padding */
  .content-body {
    padding: 16px;
  }

  /* Typography scaling for mobile */
  .display-lg { font-size: 24px; line-height: 32px; }
  .display-md { font-size: 20px; line-height: 28px; }
  .headline-lg { font-size: 18px; line-height: 26px; }

  /* Cards */
  .card {
    padding: 16px;
    border-radius: var(--radius-xl);
  }

  /* Table horizontal scroll */
  .table-container {
    border-radius: var(--radius-lg);
  }
  .table th, .table td {
    padding: 8px 12px;
    white-space: nowrap;
  }

  /* Grid adjustments */
  .demo-quick-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
  }

  /* Stepper becomes more compact */
  .stepper {
    gap: 4px;
    margin-bottom: 20px;
  }
  .stepper-item {
    padding: 0 6px;
  }
  .stepper-number {
    width: 30px;
    height: 30px;
    font-size: 12px;
  }
  .stepper-line {
    top: 15px;
  }

  /* Badge */
  .badge {
    font-size: 10px;
    padding: 2px 8px;
  }

  /* Buttons */
  .btn {
    padding: 7px 14px;
    font-size: 12px;
  }
  .btn-sm {
    padding: 4px 8px;
    font-size: 11px;
  }

  /* SAW matrix scroll */
  .saw-matrix-box {
    padding: 12px;
  }

  /* Form inputs */
  .form-control, .form-select {
    padding: 8px 12px;
    font-size: 14px; /* Slightly larger for touch targets */
  }

  /* Topbar user info: hide email, shrink role badge */
  .topbar .badge {
    font-size: 11px;
    padding: 4px 10px;
  }
}

/* ============================================
   RESPONSIVE: SMALL MOBILE (≤480px)
   ============================================ */
@media (max-width: 480px) {
  .sidebar {
    width: 260px;
    min-width: 260px;
    max-width: 260px;
  }

  .topbar {
    height: 48px;
    min-height: 48px;
    padding: 0 12px;
  }

  .content-body {
    padding: 12px;
  }

  .display-lg { font-size: 20px; line-height: 28px; }
  .display-md { font-size: 18px; line-height: 24px; }
  .headline-lg { font-size: 16px; line-height: 22px; }
  .title-lg { font-size: 14px; line-height: 20px; }

  .card {
    padding: 14px;
    border-radius: var(--radius-lg);
  }

  .demo-quick-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  /* Stack card headers vertically on very small screens */
  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .form-group {
    margin-bottom: 14px;
  }
}

/* ============================================
   UTILITY: Prevent body scroll when sidebar is open
   ============================================ */
body.sidebar-open {
  overflow: hidden;
}

/* ============================================
   RESPONSIVE: EVALUATION SCREENS
   ============================================ */
.table-container.evaluation-table-container {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  min-width: 0;
  touch-action: pan-x pan-y;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
}

.evaluation-table {
  min-width: 900px;
}

.evaluation-work-queue-card {
  min-width: 0;
}

.evaluation-work-queue-controls {
  min-width: 0;
}

.evaluation-work-queue-search input {
  max-width: 100%;
}

@media (max-width: 768px) {
  .evaluation-work-queue-header {
    align-items: stretch !important;
  }

  .evaluation-work-queue-header > div:first-child,
  .evaluation-work-queue-controls,
  .evaluation-work-queue-search {
    width: 100%;
  }

  .evaluation-work-queue-controls {
    align-items: stretch !important;
    flex-direction: column;
  }

  .evaluation-work-queue-controls > div:first-child {
    width: 100%;
    justify-content: space-between;
  }

  .evaluation-work-queue-controls > div:first-child button {
    flex: 1 1 0;
    padding-left: 8px !important;
    padding-right: 8px !important;
  }

  .evaluation-work-queue-search input {
    width: 100% !important;
    box-sizing: border-box;
  }

  .topbar-leading {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
  }

  .topbar-leading > div {
    min-width: 0;
    overflow: hidden;
  }

  .topbar-leading h1,
  .topbar-leading span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar-user {
    flex: 0 0 auto;
    gap: 6px !important;
  }

  .topbar-user-details {
    display: none;
  }

  .evaluation-summary-grid,
  .computation-metrics-grid {
    grid-template-columns: 1fr !important;
  }

  .evaluation-debtor-header {
    padding: 16px !important;
    flex-direction: column;
    gap: 12px !important;
  }

  .evaluation-debtor-status {
    width: 100%;
    text-align: left !important;
  }

  .evaluation-progress-labels {
    overflow-x: auto;
    padding-bottom: 3px;
  }

  .score-chips {
    flex-wrap: wrap;
  }

  .evaluation-actions {
    align-items: stretch !important;
    flex-direction: column;
  }

  .evaluation-action-buttons {
    width: 100%;
    justify-content: stretch;
  }

  .evaluation-action-buttons .btn {
    flex: 1 1 0;
  }
}
