/* ===========================================================================
   CourierHub — application stylesheet
   Layered on top of Bootstrap 5. Brand colours are injected as CSS variables
   by the layout from Admin → Settings → Branding, so this file never hardcodes
   the palette.
   =========================================================================== */

:root {
  --ch-radius: .75rem;
  --ch-radius-sm: .5rem;
  --ch-shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --ch-shadow-lg: 0 8px 24px rgba(16, 24, 40, .10);
  --ch-border: #e6e9ef;
  --ch-muted: #667085;
  --ch-bg: #f6f8fb;
  --ch-sidebar-width: 260px;
}

body {
  background: var(--ch-bg);
  color: #1d2939;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Cards ---------------------------------------------------------------- */
.card {
  border: 1px solid var(--ch-border);
  border-radius: var(--ch-radius);
  box-shadow: var(--ch-shadow);
}
.card-header {
  background: #fff;
  border-bottom: 1px solid var(--ch-border);
  font-weight: 600;
  padding: .875rem 1.25rem;
}
.card-header .card-title { margin: 0; font-size: 1rem; font-weight: 600; }

/* --- Stat tiles ----------------------------------------------------------- */
.stat-card {
  background: #fff;
  border: 1px solid var(--ch-border);
  border-radius: var(--ch-radius);
  padding: 1.15rem 1.25rem;
  height: 100%;
  box-shadow: var(--ch-shadow);
  transition: transform .15s ease, box-shadow .15s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--ch-shadow-lg); }
.stat-card .stat-label {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ch-muted);
  font-weight: 600;
  margin-bottom: .35rem;
}
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.15; }
.stat-card .stat-meta { font-size: .8125rem; color: var(--ch-muted); margin-top: .25rem; }
.stat-card .stat-icon {
  width: 42px; height: 42px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--ch-radius-sm);
  font-size: 1.15rem;
}

/* --- Tables --------------------------------------------------------------- */
.table-panel { background: #fff; border: 1px solid var(--ch-border); border-radius: var(--ch-radius); overflow: hidden; }
.table > :not(caption) > * > * { padding: .7rem .9rem; vertical-align: middle; }
.table thead th {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ch-muted);
  font-weight: 600;
  background: #fafbfc;
  border-bottom: 1px solid var(--ch-border);
  white-space: nowrap;
}
.table tbody tr:hover { background: #fbfcfe; }
.table-empty { padding: 3rem 1rem; text-align: center; color: var(--ch-muted); }
.table-empty i { font-size: 2.25rem; display: block; margin-bottom: .5rem; opacity: .4; }

/* Card-per-row on small screens for dense admin tables. */
@media (max-width: 767.98px) {
  .table-responsive-cards thead { display: none; }
  .table-responsive-cards tbody tr {
    display: block;
    border: 1px solid var(--ch-border);
    border-radius: var(--ch-radius-sm);
    margin-bottom: .75rem;
    padding: .35rem 0;
  }
  .table-responsive-cards tbody td {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    border: 0;
    padding: .4rem .9rem;
  }
  .table-responsive-cards tbody td::before {
    content: attr(data-label);
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ch-muted);
    font-weight: 600;
    flex: 0 0 45%;
  }
}

/* --- Badges --------------------------------------------------------------- */
.badge { font-weight: 600; letter-spacing: .01em; padding: .35em .6em; }
.status-badge { font-size: .7rem; }

/* --- Sidebar layout ------------------------------------------------------- */
.panel-wrapper { display: flex; min-height: 100vh; }

.panel-sidebar {
  width: var(--ch-sidebar-width);
  flex: 0 0 var(--ch-sidebar-width);
  background: #101828;
  color: #cdd5df;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  overflow-y: auto;
  z-index: 1045;
  transition: transform .2s ease;
}
.panel-sidebar .sidebar-brand {
  display: flex; align-items: center; gap: .6rem;
  padding: 1.1rem 1.25rem;
  color: #fff; font-weight: 700; font-size: 1.05rem;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.panel-sidebar .sidebar-brand:hover { text-decoration: none; color: #fff; }
.panel-sidebar .nav-section {
  padding: 1rem 1.25rem .35rem;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #7d8898;
  font-weight: 700;
}
.panel-sidebar .nav-link {
  color: #cdd5df;
  padding: .55rem 1.25rem;
  display: flex; align-items: center; gap: .65rem;
  font-size: .9rem;
  border-left: 3px solid transparent;
}
.panel-sidebar .nav-link:hover { background: rgba(255, 255, 255, .05); color: #fff; text-decoration: none; }
.panel-sidebar .nav-link.active {
  background: rgba(255, 255, 255, .08);
  color: #fff;
  border-left-color: var(--bs-primary);
  font-weight: 600;
}
.panel-sidebar .nav-link i { width: 1.15rem; text-align: center; opacity: .9; }
.panel-sidebar .nav-link .badge { margin-left: auto; }

.panel-main { flex: 1 1 auto; margin-left: var(--ch-sidebar-width); min-width: 0; }

.panel-topbar {
  background: #fff;
  border-bottom: 1px solid var(--ch-border);
  padding: .65rem 1.25rem;
  position: sticky; top: 0; z-index: 1030;
  display: flex; align-items: center; gap: 1rem;
}
.panel-content { padding: 1.5rem 1.25rem 3rem; }

.page-header { margin-bottom: 1.25rem; }
.page-header h1 { font-size: 1.4rem; font-weight: 700; margin: 0; }
.page-header .page-subtitle { color: var(--ch-muted); font-size: .9rem; margin-top: .15rem; }

.sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(16, 24, 40, .5);
  z-index: 1040;
  display: none;
}

@media (max-width: 991.98px) {
  .panel-sidebar { transform: translateX(-100%); }
  .panel-sidebar.open { transform: translateX(0); }
  .panel-main { margin-left: 0; }
  .sidebar-backdrop.show { display: block; }
}

/* --- Public site ---------------------------------------------------------- */
.site-navbar { background: #fff; border-bottom: 1px solid var(--ch-border); }
.site-navbar .navbar-brand { font-weight: 700; }
.site-navbar .nav-link { font-weight: 500; font-size: .95rem; }

.hero {
  background: linear-gradient(135deg, #0b2545 0%, #133b6b 55%, #1d5fa8 100%);
  color: #fff;
  padding: 4rem 0 6rem;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute; inset: auto -10% -60% -10%;
  height: 60%;
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, .10), transparent 65%);
}
.hero h1 { font-weight: 800; font-size: clamp(1.9rem, 4vw, 3rem); line-height: 1.15; }
.hero .lead { opacity: .9; max-width: 42rem; }

.quote-widget {
  background: #fff;
  border-radius: var(--ch-radius);
  box-shadow: var(--ch-shadow-lg);
  padding: 1.5rem;
  color: #1d2939;
  margin-top: -4rem;
  position: relative;
  z-index: 2;
}
.quote-widget .form-label { font-size: .8rem; font-weight: 600; color: #344054; margin-bottom: .25rem; }

.section { padding: 3.5rem 0; }
.section-title { font-weight: 700; font-size: clamp(1.4rem, 2.5vw, 1.9rem); }
.section-subtitle { color: var(--ch-muted); max-width: 44rem; }

.feature-icon {
  width: 46px; height: 46px;
  border-radius: var(--ch-radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  background: rgba(13, 110, 253, .1);
  color: var(--bs-primary);
  margin-bottom: .85rem;
}

.step-number {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--bs-primary);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700;
}

/* --- Courier comparison --------------------------------------------------- */
.courier-result {
  background: #fff;
  border: 1px solid var(--ch-border);
  border-radius: var(--ch-radius);
  padding: 1.1rem 1.25rem;
  margin-bottom: .9rem;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.courier-result:hover { border-color: var(--bs-primary); box-shadow: var(--ch-shadow-lg); }
.courier-result.is-recommended { border-color: var(--bs-primary); border-width: 2px; }
.courier-result .courier-logo {
  width: 52px; height: 52px;
  border-radius: var(--ch-radius-sm);
  background: #f2f4f7;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; color: #475467; font-size: 1.05rem;
  object-fit: contain;
}
.courier-result .price { font-size: 1.45rem; font-weight: 700; }
.courier-result .price small { font-size: .75rem; font-weight: 500; color: var(--ch-muted); }
.recommended-flag {
  position: absolute; top: -.65rem; left: 1rem;
  font-size: .68rem; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase;
}

.rating-stars { color: #f5a524; font-size: .8rem; letter-spacing: .05em; }

.availability-dot { width: .55rem; height: .55rem; border-radius: 50%; display: inline-block; }
.availability-available { background: var(--bs-success); }
.availability-limited { background: var(--bs-warning); }
.availability-not_accepting, .availability-closed { background: var(--bs-danger); }

/* --- Booking wizard ------------------------------------------------------- */
.wizard-steps { display: flex; gap: .25rem; overflow-x: auto; padding-bottom: .25rem; }
.wizard-step {
  flex: 1 1 0;
  min-width: 110px;
  text-align: center;
  font-size: .78rem;
  color: var(--ch-muted);
  padding: .6rem .35rem;
  border-bottom: 3px solid var(--ch-border);
  white-space: nowrap;
}
.wizard-step.active { color: var(--bs-primary); border-bottom-color: var(--bs-primary); font-weight: 600; }
.wizard-step.done { color: var(--bs-success); border-bottom-color: var(--bs-success); }
.wizard-step .step-index { display: block; font-weight: 700; font-size: .95rem; }

/* --- Tracking timeline ---------------------------------------------------- */
.tracking-timeline { position: relative; padding-left: 2rem; }
.tracking-timeline::before {
  content: ""; position: absolute;
  left: .55rem; top: .4rem; bottom: .4rem;
  width: 2px; background: var(--ch-border);
}
.tracking-event { position: relative; padding-bottom: 1.35rem; }
.tracking-event::before {
  content: ""; position: absolute;
  left: -1.72rem; top: .3rem;
  width: .85rem; height: .85rem;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--ch-border);
}
.tracking-event.is-done::before { background: var(--bs-success); border-color: var(--bs-success); }
.tracking-event.is-current::before {
  background: var(--bs-primary);
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 4px rgba(13, 110, 253, .18);
}
.tracking-event .event-title { font-weight: 600; }
.tracking-event .event-meta { font-size: .82rem; color: var(--ch-muted); }

/* --- Invoice / label print ------------------------------------------------ */
.print-sheet {
  background: #fff;
  max-width: 820px;
  margin: 1.5rem auto;
  padding: 2.25rem;
  border: 1px solid var(--ch-border);
  border-radius: var(--ch-radius);
}
.shipping-label {
  width: 384px;
  border: 2px solid #000;
  padding: 10px;
  font-family: "Courier New", monospace;
  font-size: 12px;
  background: #fff;
  margin: 1.5rem auto;
}
.shipping-label .label-section { border-bottom: 1px solid #000; padding: 6px 0; }
.shipping-label .label-section:last-child { border-bottom: 0; }
.shipping-label .label-heading { font-size: 9px; text-transform: uppercase; letter-spacing: .08em; font-weight: bold; }

@media print {
  body { background: #fff; }
  .no-print, .panel-sidebar, .panel-topbar, .site-navbar, .site-footer, .alert { display: none !important; }
  .panel-main { margin-left: 0; }
  .panel-content, .print-sheet { padding: 0; margin: 0; border: 0; box-shadow: none; }
  .shipping-label { margin: 0; page-break-after: always; }
}

/* --- Utilities ------------------------------------------------------------ */
.text-muted-sm { font-size: .8125rem; color: var(--ch-muted); }
.fw-num { font-variant-numeric: tabular-nums; }
.cursor-pointer { cursor: pointer; }
.min-w-0 { min-width: 0; }

.avatar-circle {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--bs-primary);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: .8rem;
}

.notification-item { padding: .6rem .9rem; border-bottom: 1px solid var(--ch-border); }
.notification-item:last-child { border-bottom: 0; }
.notification-item.unread { background: #f0f6ff; }

.filter-bar {
  background: #fff;
  border: 1px solid var(--ch-border);
  border-radius: var(--ch-radius);
  padding: .85rem 1rem;
  margin-bottom: 1rem;
}

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--ch-muted); }
.empty-state i { font-size: 2.75rem; opacity: .35; display: block; margin-bottom: .75rem; }

.site-footer { background: #101828; color: #98a2b3; padding: 3rem 0 1.5rem; }
.site-footer a { color: #cdd5df; }
.site-footer h6 { color: #fff; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; margin-bottom: .9rem; }
.site-footer .footer-bottom { border-top: 1px solid rgba(255, 255, 255, .08); margin-top: 2rem; padding-top: 1.25rem; font-size: .85rem; }
