/* ==========================================================================
   TravelPlus — compact admin theme
   Overrides Bootstrap defaults for a dense, production-grade back-office UI.
   ========================================================================== */

:root {
  --tp-teal: #0f766e;
  --tp-teal-dark: #0b5c56;
  --tp-teal-light: #e6f4f3;
  --tp-gold: #d4a017;
  --tp-gold-light: #fbf1d6;
  --tp-ink: #1f2937;
  --tp-muted: #6b7280;
  --tp-border: #e5e7eb;
  --tp-bg: #f6f7f5;
  --tp-danger: #dc2626;
  --tp-danger-light: #fdecec;
  --tp-success: #16a34a;
  --tp-success-light: #eaf7ee;
  --tp-amber: #b45309;
  --tp-amber-light: #fef3e0;
  --tp-sidebar-w: 224px;
  --tp-header-h: 56px;
  font-size: 15px;
}

* { box-sizing: border-box; }

html, body {
  background: var(--tp-bg);
  color: var(--tp-ink);
  font-family: "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
}

h1, h2, h3, h4, h5, h6 { color: var(--tp-ink); font-weight: 600; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h5 { font-size: 1.05rem; }
p { margin-bottom: 0.5rem; }

a { color: var(--tp-teal); text-decoration: none; }
a:hover { color: var(--tp-teal-dark); }

/* ---------- layout shell ---------- */
.tp-shell { display: flex; min-height: 100vh; }

.tp-sidebar {
  width: var(--tp-sidebar-w);
  flex-shrink: 0;
  background: #0d2e2b;
  color: #cfe8e4;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 1030;
}

.tp-sidebar .brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.02em;
}
.tp-sidebar .brand .mark {
  width: 26px; height: 26px;
  background: var(--tp-gold);
  color: #1f2937;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
}

.tp-nav { flex: 1; padding: 0.6rem 0.5rem; overflow-y: auto; }
.tp-nav .nav-section-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(207,232,228,0.5);
  padding: 0.7rem 0.6rem 0.25rem;
}
.tp-nav a.nav-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #cfe8e4;
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  font-size: 0.92rem;
  margin-bottom: 2px;
  white-space: nowrap;
}
.tp-nav a.nav-link i { width: 18px; text-align: center; font-size: 0.95rem; opacity: 0.9; }
.tp-nav a.nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.tp-nav a.nav-link.active {
  background: var(--tp-teal);
  color: #fff;
  font-weight: 600;
}

.tp-sidebar-footer {
  padding: 0.6rem 1rem;
  font-size: 0.8rem;
  color: rgba(207,232,228,0.5);
  border-top: 1px solid rgba(255,255,255,0.08);
}

.tp-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(13,46,43,0.45);
  z-index: 1029;
}

.tp-main {
  margin-left: var(--tp-sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.tp-header {
  height: var(--tp-header-h);
  background: #fff;
  border-bottom: 1px solid var(--tp-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  position: sticky;
  top: 0;
  z-index: 1020;
  gap: 1rem;
}

.tp-header .tp-search {
  max-width: 320px;
  flex: 1;
}
.tp-header .tp-search .form-control {
  font-size: 0.9rem;
  padding: 0.38rem 0.7rem;
}

.tp-header .tp-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}
.tp-header .tp-user img {
  width: 30px; height: 30px;
  border-radius: 50%;
  object-fit: cover;
}
.tp-header .icon-btn {
  width: 32px; height: 32px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--tp-muted);
  position: relative;
}
.tp-header .icon-btn:hover { background: var(--tp-bg); color: var(--tp-ink); }
.tp-header .icon-btn .dot {
  position: absolute; top: 4px; right: 5px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--tp-danger);
  border: 1.5px solid #fff;
}

.content {
  padding: 1rem 1.1rem 2rem;
}

.content .page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.9rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.content .page-head .subtitle { color: var(--tp-muted); font-size: 0.9rem; margin-top: 0.15rem; }

/* ---------- cards & tiles ---------- */
.card {
  border: 1px solid var(--tp-border);
  border-radius: 10px;
  box-shadow: none;
}
.card-header {
  background: #fff;
  border-bottom: 1px solid var(--tp-border);
  padding: 0.7rem 0.9rem;
  font-weight: 600;
  font-size: 0.95rem;
}
.card-body { padding: 0.9rem; }

.stat-tile {
  background: #fff;
  border: 1px solid var(--tp-border);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.stat-tile .icon {
  width: 38px; height: 38px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.stat-tile .icon.income { background: var(--tp-teal-light); color: var(--tp-teal); }
.stat-tile .icon.expense { background: var(--tp-danger-light); color: var(--tp-danger); }
.stat-tile .icon.profit { background: var(--tp-gold-light); color: var(--tp-gold); }
.stat-tile .icon.due { background: var(--tp-amber-light); color: var(--tp-amber); }
.stat-tile .label { font-size: 0.8rem; color: var(--tp-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.stat-tile .value { font-size: 1.35rem; font-weight: 700; line-height: 1.25; }
.stat-tile .delta { font-size: 0.8rem; }
.stat-tile .delta.up { color: var(--tp-success); }
.stat-tile .delta.down { color: var(--tp-danger); }

/* ---------- tables ---------- */
.table-compact {
  font-size: 0.92rem;
  margin-bottom: 0;
}
.table-compact thead th {
  background: #fafaf9;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--tp-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--tp-border);
  padding: 0.6rem 0.7rem;
  white-space: nowrap;
}
.table-compact td {
  padding: 0.55rem 0.7rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--tp-border);
}
.table-compact tbody tr:hover { background: var(--tp-bg); }
.table-compact tbody tr:last-child td { border-bottom: none; }

.avatar-sm {
  width: 28px; height: 28px;
  border-radius: 50%;
  object-fit: cover;
}
.avatar-xs {
  width: 20px; height: 20px;
  border-radius: 50%;
  object-fit: cover;
}

/* ---------- badges ---------- */
.badge-tp { font-size: 0.8rem; font-weight: 600; padding: 0.32em 0.6em; border-radius: 5px; }
.badge-pending { background: var(--tp-amber-light); color: var(--tp-amber); }
.badge-done { background: var(--tp-success-light); color: var(--tp-success); }
.badge-due { background: var(--tp-danger-light); color: var(--tp-danger); }
.badge-paid { background: var(--tp-success-light); color: var(--tp-success); }
.badge-partial { background: var(--tp-amber-light); color: var(--tp-amber); }
.badge-type { background: var(--tp-teal-light); color: var(--tp-teal); }
.badge-muted { background: #f1f1ef; color: var(--tp-muted); }

/* ---------- buttons ---------- */
.btn { font-size: 0.9rem; padding: 0.4rem 0.85rem; border-radius: 7px; }
.btn-sm { font-size: 0.82rem; padding: 0.3rem 0.65rem; border-radius: 6px; }
.btn-teal { background: var(--tp-teal); border-color: var(--tp-teal); color: #fff; }
.btn-teal:hover { background: var(--tp-teal-dark); border-color: var(--tp-teal-dark); color: #fff; }
.btn-outline-teal { border: 1px solid var(--tp-teal); color: var(--tp-teal); background: #fff; }
.btn-outline-teal:hover { background: var(--tp-teal-light); color: var(--tp-teal-dark); }
.btn-gold { background: var(--tp-gold); border-color: var(--tp-gold); color: #1f2937; font-weight: 600; }
.btn-gold:hover { filter: brightness(0.95); color: #1f2937; }
.btn-icon { width: 30px; height: 30px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }

/* ---------- forms ---------- */
label.form-label { font-size: 0.86rem; font-weight: 600; color: var(--tp-ink); margin-bottom: 0.3rem; }
.form-control, .form-select {
  font-size: 0.92rem;
  padding: 0.42rem 0.65rem;
  border-color: var(--tp-border);
}
.form-control:focus, .form-select:focus {
  border-color: var(--tp-teal);
  box-shadow: 0 0 0 3px var(--tp-teal-light);
}
.form-text { font-size: 0.8rem; }
.form-check-input:checked { background-color: var(--tp-teal); border-color: var(--tp-teal); }
.input-group-text { font-size: 0.88rem; background: var(--tp-bg); }

/* ---------- select2 ---------- */
/* Select2 replaces the <select> with an inline-block container sized via JS
   (width:'style', so it reads the element's own inline width). Filter bars
   rely on that container staying an inline flex item, not stretching to
   fill its row. */
.select2-container {
  display: inline-block;
  vertical-align: middle;
}
.d-flex > .select2-container,
.d-flex > select.select2 + .select2-container {
  flex: 0 0 auto;
}
.select2-container .select2-selection--single {
  height: calc(1.5em + 0.84rem + 2px);
  padding: 0.42rem 0.65rem;
  font-size: 0.92rem;
  border-color: var(--tp-border);
  display: flex;
  align-items: center;
}
.select2-container .select2-selection--single .select2-selection__rendered {
  padding: 0;
  line-height: normal;
}
.select2-container .select2-selection--single .select2-selection__arrow {
  height: 100%;
}
.select2-container--default .select2-selection--multiple {
  min-height: calc(1.5em + 0.84rem + 2px);
  border-color: var(--tp-border);
  font-size: 0.92rem;
}
.select2-dropdown {
  font-size: 0.92rem;
  border-color: var(--tp-border);
}
.select2-container--default .select2-results__option--highlighted[aria-selected] {
  background-color: var(--tp-teal);
}
/* Select2 dropdowns opened inside a modal must render above the modal itself */
.modal .select2-container--open {
  z-index: 1071;
}
.select2-container--open .select2-dropdown {
  z-index: 1072;
}

.section-title {
  font-size: 0.86rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--tp-muted);
  margin: 1.2rem 0 0.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ---------- tour / package cards ---------- */
.tour-card {
  background: #fff;
  border: 1px solid var(--tp-border);
  border-radius: 12px;
  overflow: hidden;
}
.tour-card .cover { height: 110px; width: 100%; object-fit: cover; display: block; }
.tour-card .body { padding: 0.75rem 0.85rem; }
.tour-card .guide-chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  background: var(--tp-teal-light); color: var(--tp-teal-dark);
  border-radius: 20px; padding: 0.2rem 0.6rem 0.2rem 0.2rem;
  font-size: 0.82rem; font-weight: 600;
}

.package-card {
  background: #fff;
  border: 1px solid var(--tp-border);
  border-radius: 12px;
  padding: 0.9rem;
  height: 100%;
}
.package-card .price-tag { font-size: 1.15rem; font-weight: 700; color: var(--tp-teal-dark); }
.service-pill {
  display: inline-block;
  font-size: 0.82rem;
  background: var(--tp-bg);
  border: 1px solid var(--tp-border);
  border-radius: 20px;
  padding: 0.15rem 0.55rem;
  margin: 0 0.25rem 0.25rem 0;
}

/* ---------- skeleton loader ---------- */
.skeleton {
  background: linear-gradient(90deg, #eceeec 25%, #f4f5f3 37%, #eceeec 63%);
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
  border-radius: 6px;
}
@keyframes skeleton-shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}
.skeleton-loader { padding: 1rem; display: flex; flex-direction: column; gap: 0.6rem; }
.skeleton-line {
  background: linear-gradient(90deg, #eceeec 25%, #f4f5f3 37%, #eceeec 63%);
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
  border-radius: 4px;
}
[x-cloak] { display: none !important; }

/* ---------- login ---------- */
.tp-auth {
  height: 100vh;
  display: flex;
  overflow: hidden;
}
.tp-auth .visual {
  flex: 1.1;
  position: relative;
  color: #fff;
  height: 100%;
  overflow: hidden;
}
.tp-auth .visual img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tp-auth .form-pane { height: 100%; overflow-y: auto; }
.tp-auth .visual .overlay {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(13,46,43,0.35), rgba(13,46,43,0.85));
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 2.5rem;
}
.tp-auth .form-pane {
  flex: 1;
  max-width: 460px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: #fff;
}

/* ---------- misc ---------- */
.tp-scroll-x { overflow-x: auto; }
.text-muted-tp { color: var(--tp-muted); }
.divider-dashed { border-top: 1px dashed var(--tp-border); margin: 0.75rem 0; }
.totals-panel {
  background: var(--tp-teal-light);
  border: 1px solid #cfe8e4;
  border-radius: 10px;
  padding: 0.85rem 1rem;
}
.totals-panel .row-line { display: flex; justify-content: space-between; padding: 0.2rem 0; font-size: 0.95rem; }
.totals-panel .row-line.grand { font-size: 1.1rem; font-weight: 700; border-top: 1px dashed #b9ddd8; margin-top: 0.4rem; padding-top: 0.5rem; }

.nowrap { white-space: nowrap; }

/* ==========================================================================
   Responsive — off-canvas sidebar below the lg breakpoint
   ========================================================================== */
@media (max-width: 991.98px) {
  .tp-sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 0 0 0 rgba(0,0,0,0);
  }
  .tp-sidebar.is-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.25);
  }
  .tp-sidebar-backdrop.is-visible {
    display: block;
  }
  .tp-main {
    margin-left: 0;
  }
}

@media (max-width: 767.98px) {
  .tp-header { padding: 0 0.6rem; gap: 0.5rem; }
  .tp-header .tp-search { max-width: none; }
  .tp-header .tp-user > div.d-none.d-md-block { display: none !important; }

  .content { padding: 0.75rem 0.65rem 1.5rem; }

  .page-head { flex-direction: column; align-items: stretch; }
  .page-head > div:last-child { display: flex; flex-wrap: wrap; }
  .page-head > div:last-child > * { flex: 1 1 auto; }

  .stat-tile { padding: 0.6rem 0.7rem; }
  .stat-tile .value { font-size: 1rem; }

  .tour-card .cover { height: 90px; }

  .totals-panel { position: static !important; }
}

@media (max-width: 575.98px) {
  .row.g-2 > [class^="col-6"],
  .row.g-2 > [class*=" col-6"] {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

/* Impersonation ("Login as customer") banner */
.impersonation-banner {
  background: #d4a017;
  color: #1c2b26;
  text-align: center;
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1050;
}

.impersonation-banner a {
  color: #1c2b26;
  font-weight: 700;
  text-decoration: underline;
}

body:has(.impersonation-banner) {
  --banner-height: 38px;
}

body:has(.impersonation-banner) .tp-sidebar {
  top: var(--banner-height, 0px);
}

body:has(.impersonation-banner) .tp-header {
  top: var(--banner-height, 0px);
}
