/* ==========================================================================
   TRAVELOKA DESIGN SYSTEM (SKY BLUE #0194f3 & TRAVELOKA ORANGE #ff5e1f)
   ========================================================================== */

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

:root {
  --tvk-blue: #0194f3;
  --tvk-blue-dark: #0178d2;
  --tvk-blue-light: #e6f4fe;
  --tvk-orange: #ff5e1f;
  --tvk-orange-hover: #e54e12;
  --tvk-emerald: #00b67a;
  --tvk-amber: #f99d1c;
  --tvk-red: #f53157;

  --bg-base: #f2f4f7;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --border-color: #e5e9f0;

  --text-primary: #03121a;
  --text-secondary: #687176;
  --text-muted: #969e9e;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 6px rgba(3, 18, 26, 0.06);
  --shadow-md: 0 6px 18px rgba(3, 18, 26, 0.08);
  --shadow-lg: 0 12px 30px rgba(3, 18, 26, 0.12);
}

[data-theme="dark"] {
  --bg-base: #0f172a;
  --bg-surface: #1e293b;
  --bg-card: #1e293b;
  --border-color: #334155;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
}

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

body {
  font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, sans-serif;
  background-color: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* TRAVELOKA AUTH SCREEN */
.auth-screen {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #0194f3 0%, #0178d2 50%, #005bb5 100%);
  z-index: 999; display: flex; align-items: center; justify-content: center; padding: 1.5rem;
}

.auth-card {
  width: 100%; max-width: 440px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 2.25rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.auth-tabs {
  display: flex; background: #f2f4f7; padding: 4px; border-radius: var(--radius-md); margin-bottom: 1.5rem;
}
[data-theme="dark"] .auth-tabs { background: #0f172a; }

.auth-tab {
  flex: 1; padding: 10px; border: none; background: transparent;
  color: var(--text-secondary); font-weight: 700; font-size: 0.9rem; border-radius: var(--radius-sm); cursor: pointer;
}
.auth-tab.active { background: var(--tvk-blue); color: #ffffff; box-shadow: var(--shadow-sm); }

/* TRAVELOKA TOP NAVBAR */
.tvk-navbar {
  background: var(--tvk-blue);
  color: #ffffff;
  padding: 0.85rem 2rem;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 4px 12px rgba(1, 148, 243, 0.25);
  position: sticky; top: 0; z-index: 100;
}

.tvk-brand {
  display: flex; align-items: center; gap: 0.75rem; color: #ffffff; text-decoration: none; font-size: 1.35rem; font-weight: 800;
}

.tvk-brand-badge {
  background: var(--tvk-orange); padding: 2px 8px; border-radius: var(--radius-full); font-size: 0.7rem; font-weight: 800; text-transform: uppercase;
}

/* CONTAINER & SIDEBAR */
.app-container { display: flex; min-height: calc(100vh - 60px); }

.sidebar {
  width: 260px; background: var(--bg-surface); border-right: 1px solid var(--border-color); display: flex; flex-direction: column;
}

.nav-section { padding: 1.25rem 0.85rem; flex: 1; display: flex; flex-direction: column; gap: 0.35rem; }
.nav-label { padding: 0.4rem 0.85rem; font-size: 0.7rem; text-transform: uppercase; color: var(--text-muted); font-weight: 800; letter-spacing: 0.05em; }

.nav-item {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.65rem 1rem;
  color: var(--text-secondary); text-decoration: none; border-radius: var(--radius-md); font-weight: 700; font-size: 0.875rem; cursor: pointer; transition: all 0.2s ease;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--tvk-blue-light); color: var(--tvk-blue); }
[data-theme="dark"] .nav-item:hover { background: rgba(1, 148, 243, 0.15); }
.nav-item.active { background: var(--tvk-blue); color: #ffffff; box-shadow: 0 4px 12px rgba(1, 148, 243, 0.3); }

/* MAIN CONTENT */
.main-content { flex: 1; padding: 2rem; overflow-y: auto; }

.tvk-card {
  background: var(--bg-card); border-radius: var(--radius-lg); border: 1px solid var(--border-color);
  padding: 1.5rem; box-shadow: var(--shadow-sm); margin-bottom: 1.5rem;
}
.tvk-card:hover { box-shadow: var(--shadow-md); }

/* BUTTONS */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.5rem 1.1rem; font-size: 0.85rem; font-weight: 700;
  border-radius: var(--radius-full); border: none; cursor: pointer; transition: all 0.2s ease; text-decoration: none;
  line-height: 1.2;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn-orange { background: var(--tvk-orange); color: #ffffff; box-shadow: 0 4px 12px rgba(255, 94, 31, 0.3); }
.btn-orange:hover { background: var(--tvk-orange-hover); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(255, 94, 31, 0.4); }
.btn-blue { background: var(--tvk-blue); color: #ffffff; box-shadow: 0 4px 12px rgba(1, 148, 243, 0.3); }
.btn-blue:hover { background: var(--tvk-blue-dark); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-base); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover { background: var(--border-color); }
.btn-sm { padding: 0.32rem 0.7rem; font-size: 0.78rem; gap: 0.3rem; }
.btn-sm svg { width: 14px; height: 14px; }

.form-control {
  width: 100%; padding: 0.7rem 0.95rem; border-radius: var(--radius-md); border: 1px solid var(--border-color);
  background: var(--bg-surface); color: var(--text-primary); font-size: 0.9rem; font-family: inherit;
}
.form-control:focus { outline: none; border-color: var(--tvk-blue); box-shadow: 0 0 0 3px rgba(1, 148, 243, 0.2); }

/* STATS GRID */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.25rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg); padding: 1.35rem; display: flex; align-items: center; justify-content: space-between; }
.stat-val { font-size: 1.6rem; font-weight: 800; color: var(--tvk-blue); margin-top: 0.25rem; }

/* EXCEL SPREADSHEET TABLE */
.excel-table-wrapper { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border-color); background: var(--bg-surface); }
.excel-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.excel-table th { background: #f7f9fa; color: #43494d; padding: 1rem; text-align: left; font-weight: 800; border-bottom: 2px solid var(--border-color); white-space: nowrap; }
[data-theme="dark"] .excel-table th { background: #0f172a; color: #94a3b8; }
.excel-table td { padding: 0.85rem 1rem; border-bottom: 1px solid var(--border-color); }
.excel-input { width: 95px; padding: 0.45rem; background: var(--bg-base); border: 1px solid var(--border-color); border-radius: var(--radius-sm); text-align: right; font-weight: 700; color: var(--text-primary); }

/* BADGES */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 0.3rem 0.75rem; border-radius: var(--radius-full); font-size: 0.75rem; font-weight: 800; text-transform: uppercase; }
.badge-paid { background: #e6f9f2; color: var(--tvk-emerald); border: 1px solid #b3f2db; }
.badge-pending { background: #fff2ec; color: var(--tvk-orange); border: 1px solid #ffd4c2; }
.badge-open { background: #ffecee; color: var(--tvk-red); border: 1px solid #ffc2c9; }
.badge-resolved { background: var(--tvk-blue-light); color: var(--tvk-blue); border: 1px solid #bce2fd; }

/* MODAL */
.modal-backdrop { position: fixed; inset: 0; background: rgba(3, 18, 26, 0.65); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; z-index: 200; opacity: 0; pointer-events: none; transition: all 0.25s ease; }
.modal-backdrop.active { opacity: 1; pointer-events: auto; }
.modal-card { width: 100%; max-width: 650px; max-height: 90vh; overflow-y: auto; padding: 2rem; background: var(--bg-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }

/* TOAST */
.toast-container { position: fixed; bottom: 2rem; right: 2rem; display: flex; flex-direction: column; gap: 0.75rem; z-index: 1000; }
.toast { padding: 1rem 1.25rem; border-radius: var(--radius-md); background: var(--bg-surface); color: var(--text-primary); border: 1px solid var(--border-color); box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 0.75rem; }

/* MOBILE MENU TOGGLE (hidden on desktop) */
.btn-menu-toggle {
  display: none; align-items: center; justify-content: center; width: 38px; height: 38px;
  background: rgba(255, 255, 255, 0.15); border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-md); color: #ffffff; cursor: pointer; flex-shrink: 0;
}

.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(3, 18, 26, 0.55); z-index: 149;
}
.sidebar-overlay.active { display: block; }

/* ==========================================================================
   RESPONSIVE LAYOUT — 3 TIERS
   Desktop: > 1100px (persistent sidebar, single-row navbar)
   Tablet:  577px – 1100px (off-canvas sidebar, compact navbar, 2-col stats)
   Mobile:  <= 576px (single column, minimal chrome)
   ========================================================================== */

/* ---------- TABLET (also applies to mobile, which layers on top below) ---------- */
@media (max-width: 1100px) {
  .app-container { position: relative; }

  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 150; width: 280px; max-width: 82vw;
    transform: translateX(-100%); transition: transform 0.25s ease; box-shadow: var(--shadow-lg);
    padding-top: 64px;
  }
  .sidebar.open { transform: translateX(0); }

  .btn-menu-toggle { display: inline-flex; }

  .main-content { padding: 1.5rem; }

  /* Sidebar is off-canvas here, so the navbar owns the full width — but it still
     carries a lot of controls, so let it wrap and drop verbose labels. */
  .tvk-navbar { padding: 0.65rem 1.25rem; flex-wrap: wrap; gap: 0.5rem; row-gap: 0.5rem; }
  .tvk-navbar > div:last-child { flex-wrap: wrap; gap: 0.5rem; justify-content: flex-start; }

  #nav-house-box label,
  .tvk-navbar label { display: none; }
  #nav-house-box select,
  .tvk-navbar select.form-control { width: auto; flex: 1; min-width: 130px; }

  /* Explicit 2 columns reads better than auto-fit here, which can strand a lone
     4th card on its own row once the sidebar is gone and content is full-width. */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 1rem; }
}

/* ---------- TABLET PORTRAIT (narrow enough that side-by-side content grids no
   longer have room to breathe — stack them; wide tablet-landscape above keeps
   its 2-column layouts) ---------- */
@media (max-width: 820px) {
  [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
}

/* ---------- MOBILE ---------- */
@media (max-width: 576px) {
  .tvk-navbar { padding: 0.65rem 1rem; }
  .tvk-brand { font-size: 1.1rem; }
  .tvk-brand-badge { display: none; }

  .main-content { padding: 1rem; }

  .stats-grid { grid-template-columns: 1fr; gap: 0.75rem; }
  .stat-card { padding: 1rem; }
  .stat-val { font-size: 1.25rem; }

  .icon-picker-grid { grid-template-columns: repeat(4, 1fr); }

  .modal-card { max-width: 94vw; padding: 1.25rem; max-height: 88vh; }
  .auth-card { padding: 1.5rem; }

  .toast-container { left: 1rem; right: 1rem; bottom: 1rem; }
  .toast { width: 100%; }

  .invoice-paper { padding: 1.25rem; }

  .excel-table th, .excel-table td { padding: 0.6rem 0.7rem; }
}
