@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ========================
   DESIGN TOKENS
   ======================== */
:root {
  --primary:        #6366f1;
  --primary-dark:   #4f46e5;
  --primary-light:  #eef2ff;
  --primary-glow:   rgba(99,102,241,0.18);
  --success:        #10b981;
  --success-light:  #d1fae5;
  --warning:        #f59e0b;
  --warning-light:  #fef3c7;
  --danger:         #ef4444;
  --danger-light:   #fee2e2;
  --bg:             #f8fafc;
  --surface:        #ffffff;
  --border:         #e2e8f0;
  --text:           #0f172a;
  --text-muted:     #64748b;
  --radius:         10px;
  --radius-lg:      16px;
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.05);
  --shadow:         0 2px 8px rgba(0,0,0,0.07), 0 0 0 1px rgba(0,0,0,0.02);
  --shadow-md:      0 4px 20px rgba(0,0,0,0.09), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-lg:      0 12px 40px rgba(0,0,0,0.13), 0 2px 10px rgba(0,0,0,0.06);
  --transition:     150ms ease;
  --transition-md:  250ms cubic-bezier(0.4,0,0.2,1);
  --bnav-h:         64px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 0.9375rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.125rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.brand-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 1rem; flex-shrink: 0;
  box-shadow: 0 3px 10px var(--primary-glow);
}

.brand-name { font-weight: 700; font-size: 1rem; color: var(--text); }

.sidebar-nav {
  flex: 1;
  padding: 0.875rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background var(--transition), color var(--transition);
  font-family: inherit;
}

.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}
.nav-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  line-height: 1.4;
}

.sidebar-user strong {
  display: block;
  font-size: 0.875rem;
  color: var(--text);
  font-weight: 600;
  margin-bottom: 1px;
}

.main-content {
  flex: 1;
  padding: 2rem;
  min-width: 0;
}

/* ========================
   LAYOUT — Bidang Topbar
   ======================== */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-brand {
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.topbar-user {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.topbar-user strong { color: var(--text); }

.page-wrap {
  max-width: 1140px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
}

/* ========================
   MOBILE TOPBAR (Admin)
   ======================== */
.mobile-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: var(--shadow-sm);
}

.mobile-topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.mobile-topbar-brand .brand-icon {
  width: 30px; height: 30px;
  font-size: 0.875rem;
  border-radius: 8px;
}

.mobile-topbar-brand span {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
}

.mobile-page-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Hamburger — kept in DOM for JS but visually hidden */
.hamburger {
  display: none !important;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 40;
}
.sidebar-overlay.active { display: block; }

/* ========================
   BOTTOM NAVIGATION
   ======================== */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bnav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 24px rgba(0,0,0,0.07);
  z-index: 90;
  padding: 6px 0.25rem;
  padding-bottom: max(6px, env(safe-area-inset-bottom, 6px));
  align-items: stretch;
}

.bnav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 2px 4px;
  transition: color var(--transition);
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}

.bnav-icon-wrap {
  width: 44px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 999px;
  font-size: 1.125rem;
  transition: background var(--transition-md), transform var(--transition-md);
  margin-bottom: 1px;
}

.bnav-item.active {
  color: var(--primary);
}

.bnav-item.active .bnav-icon-wrap {
  background: var(--primary-light);
  transform: translateY(-2px);
}

/* ========================
   PAGE HEADER
   ======================== */
.page-header { margin-bottom: 1.5rem; }

.page-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

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

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
}

.card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.card-body { padding: 1.25rem; }

/* ========================
   BUTTONS
   ======================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1.125rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition),
              box-shadow var(--transition), transform var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: translateY(1px); }

.btn-primary {
  background: var(--primary); color: #fff; border-color: var(--primary);
  box-shadow: 0 1px 4px var(--primary-glow);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark); border-color: var(--primary-dark);
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { filter: brightness(0.92); }

.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(0.92); }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg); }

.btn-outline   { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover:not(:disabled) { background: var(--primary-light); }

.btn-ghost     { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--bg); color: var(--text); }

.btn-warning   { background: var(--warning); color: #fff; }
.btn-warning:hover:not(:disabled) { filter: brightness(0.92); }

.btn-sm  { padding: 0.375rem 0.875rem; font-size: 0.8125rem; }
.btn-xs  { padding: 0.25rem 0.625rem;  font-size: 0.75rem; border-radius: 6px; }
.btn-block { width: 100%; }

/* ========================
   FORMS
   ======================== */
.form-group { margin-bottom: 1.125rem; }

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.375rem;
}

.form-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }

input, select, textarea {
  width: 100%;
  padding: 0.5625rem 0.875rem;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

input::placeholder { color: #94a3b8; }
input[type="file"] { padding: 0.5rem; cursor: pointer; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.875rem;
}

/* ========================
   TABLES
   ======================== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

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

thead th {
  padding: 0.625rem 1rem;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafbfd; }

.cell-primary { font-weight: 500; }
.cell-muted { color: var(--text-muted); font-size: 0.8125rem; }
.cell-actions { display: flex; gap: 0.375rem; align-items: center; flex-wrap: wrap; }

/* ========================
   BADGES
   ======================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
}

.badge-pending  { background: var(--warning-light); color: var(--warning); }
.badge-setuju   { background: var(--success-light); color: var(--success); }
.badge-tertolak { background: var(--danger-light);  color: var(--danger); }
.badge-blue     { background: #dbeafe; color: #1d4ed8; }
.badge-yellow   { background: #fef9c3; color: #92400e; }

/* ========================
   TOAST NOTIFICATIONS
   ======================== */
#toast-container {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.875rem 1.125rem;
  box-shadow: var(--shadow-md);
  border-left: 3px solid var(--border);
  font-size: 0.875rem;
  font-weight: 500;
  max-width: 340px;
  min-width: 220px;
  opacity: 0;
  transform: translateX(12px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: auto;
}

.toast.show { opacity: 1; transform: translateX(0); }
.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error   { border-left-color: var(--danger); }
.toast.toast-warning { border-left-color: var(--warning); }

/* ========================
   INLINE STATUS (Login)
   ======================== */
#status-message {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  display: none;
  font-size: 0.875rem;
  font-weight: 500;
}

.status-success { background: var(--success-light); color: #065f46; display: block !important; }
.status-error   { background: var(--danger-light); color: #991b1b; display: block !important; }

/* ========================
   MODALS
   ======================== */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop.active { display: flex; }

.modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.2s ease;
}

.modal-box.modal-lg { max-width: 580px; }

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

.modal-header {
  padding: 1.125rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title { font-size: 1rem; font-weight: 600; }

.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 4px 8px;
  border-radius: var(--radius); font-size: 1.125rem; line-height: 1;
  transition: color var(--transition), background var(--transition);
}
.modal-close:hover { color: var(--danger); background: var(--danger-light); }

.modal-body { padding: 1.25rem; }

.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

/* ========================
   AVAILABILITY STATUS
   ======================== */
#availability-status {
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  text-align: center;
  margin-top: 0.75rem;
}

.avail-ok       { background: var(--success-light); color: var(--success); }
.avail-no       { background: var(--danger-light);  color: var(--danger); }
.avail-checking { background: #f8fafc; color: var(--text-muted); }

/* ========================
   AI EXTRACTION BOX
   ======================== */
.ai-box {
  background: var(--primary-light);
  border: 1.5px solid #c7d2fe;
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

.ai-box-label { font-size: 0.875rem; font-weight: 600; color: var(--primary); margin-bottom: 0.5rem; }
.ai-status { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.375rem; text-align: center; }

/* ========================
   UTILITIES
   ======================== */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.flex           { display: flex; }
.items-center   { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2          { gap: 0.5rem; }
.gap-3          { gap: 0.75rem; }
.mt-3           { margin-top: 0.75rem; }
.mb-4           { margin-bottom: 1rem; }
.mb-5           { margin-bottom: 1.25rem; }
.text-muted     { color: var(--text-muted); }
.text-sm        { font-size: 0.8125rem; }
.text-xs        { font-size: 0.75rem; }
.font-semibold  { font-weight: 600; }
.text-center    { text-align: center; }
.text-danger    { color: var(--danger); }
.text-success   { color: var(--success); }

/* Loader */
.loader {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  display: inline-block;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes sheet-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.fade-in { animation: fadeInUp 0.35s ease both; }

/* ========================
   BIDANG SECTION TABS
   Desktop: grid layout; Mobile: switched by bottom nav
   ======================== */
.bidang-layout {
  display: grid;
  grid-template-areas:
    "booking history"
    "all     all";
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

#section-booking { grid-area: booking; }
#section-history { grid-area: history; }
#section-all     { grid-area: all; }

/* ========================
   RESPONSIVE — MOBILE ≤ 640px
   ======================== */
@media (max-width: 640px) {
  .two-col {
    grid-template-columns: 1fr;
    gap: 0.875rem;
    margin-bottom: 0.875rem;
  }
}

/* ========================
   RESPONSIVE — MOBILE ≤ 768px
   ======================== */
@media (max-width: 768px) {

  body { padding-bottom: var(--bnav-h); }

  /* --- Bottom Nav: visible --- */
  .bottom-nav { display: flex; }

  /* --- Sidebar: hidden on mobile, bottom nav replaces it --- */
  .sidebar        { display: none !important; }
  .sidebar-overlay { display: none !important; }

  /* --- Mobile topbar: visible --- */
  .mobile-topbar { display: flex; }

  /* --- Spacing --- */
  .main-content { padding: 1rem; }
  .page-wrap    { padding: 0.875rem; }
  .topbar       { padding: 0 1rem; height: 52px; }
  .topbar-user  { display: none; }

  /* --- Card --- */
  .card-header { flex-wrap: wrap; gap: 0.5rem; padding: 0.875rem 1rem; }
  .card-body   { padding: 1rem; }

  /* --- Forms --- */
  .form-row { grid-template-columns: 1fr; gap: 0; }
  input, select, textarea { font-size: 1rem; } /* prevent iOS auto-zoom */

  /* --- Touch targets (≥ 44px) --- */
  .btn     { min-height: 44px; }
  .btn-sm  { min-height: 40px; }
  .btn-xs  { min-height: 34px; }
  .nav-item { min-height: 44px; }

  /* --- Tables --- */
  thead th { font-size: 0.7rem; padding: 0.5rem 0.75rem; }
  tbody td { padding: 0.75rem; }
  .cell-actions { flex-wrap: wrap; gap: 0.25rem; }
  .table-wrap { border-radius: 0; }

  /* --- Bidang layout: single column --- */
  .bidang-layout {
    display: block;
  }
  .bidang-layout > * {
    margin-bottom: 0;
  }

  /* --- Modal: bottom sheet --- */
  .modal-backdrop.active {
    align-items: flex-end;
    padding: 0;
  }
  .modal-box {
    max-width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 20px 20px 0 0;
    animation: sheet-up 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  }
  .modal-box.modal-lg { max-width: 100%; }

  /* Bottom sheet drag handle */
  .modal-box::before {
    content: '';
    display: block;
    width: 36px; height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 10px auto 0;
  }

  .modal-header {
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
  }

  /* --- Toast: full-width at top --- */
  #toast-container {
    top: 0.625rem;
    right: 0.875rem;
    left: 0.875rem;
    align-items: stretch;
  }
  .toast {
    max-width: 100%;
    min-width: 0;
  }

  /* --- Page header --- */
  .page-header { margin-bottom: 1rem; }
  .page-title  { font-size: 1.125rem; }
}

/* ========================
   RESPONSIVE — DESKTOP ≥ 769px
   ======================== */
@media (min-width: 769px) {
  .mobile-topbar { display: none; }
  .bottom-nav    { display: none !important; }

  /* Force all bidang sections visible on desktop */
  #section-booking,
  #section-history,
  #section-all { display: block !important; }
}

/* ========================
   RESPONSIVE — LARGE DESKTOP ≥ 1280px
   ======================== */
@media (min-width: 1280px) {
  .sidebar { width: 260px; }
  .main-content { padding: 2.5rem; }
  .page-wrap { max-width: 1360px; padding: 2rem 2.5rem; }
  .two-col { gap: 1.5rem; margin-bottom: 1.5rem; }
  .bidang-layout { gap: 1.5rem; }
  .card-header { padding: 1.125rem 1.5rem; }
  .card-body   { padding: 1.5rem; }
  tbody td     { padding: 1rem 1.25rem; }
  thead th     { padding: 0.75rem 1.25rem; }
}
