/* ============================================================
   AutoDealer — app.css
   Multi-tenant theme + SB-Admin layout
   ============================================================ */

/* ── Root Variables ─────────────────────────────────────── */
:root {
  --brand: #1a56db;
  --brand-rgb: 26, 86, 219;
  --brand-dark: #1440b3;
  --brand-light: #eef2ff;
  --sidebar-width: 225px;
  --topnav-height: 56px;
  --font-sans: 'Nunito', system-ui, -apple-system, sans-serif;
}

/* ── Base ─────────────────────────────────────────────────── */
body { font-family: var(--font-sans); background: #f0f4f8; color: #1e293b; font-feature-settings: 'cv02','cv03','cv04','cv11'; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); }
code { color: var(--brand-dark); }

/* ── Brand shortcuts ─────────────────────────────────────── */
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-brand:focus { box-shadow: 0 0 0 .25rem rgba(var(--brand-rgb), .3); }
.bg-brand { background: var(--brand) !important; }
.text-brand { color: var(--brand) !important; }
.border-brand { border-color: var(--brand) !important; }
.badge.bg-brand { background: var(--brand) !important; }

/* Soft backgrounds */
.bg-primary-soft { background: rgba(var(--brand-rgb), .12); }
.bg-success-soft  { background: rgba(25,135,84,.12); }
.bg-warning-soft  { background: rgba(255,193,7,.12); }
.bg-info-soft     { background: rgba(13,202,240,.12); }
.bg-danger-soft   { background: rgba(220,53,69,.12); }
.bg-brand-soft    { background: rgba(var(--brand-rgb), .08); }

/* ── Layout (SB-Admin style) ─────────────────────────────── */
.sb-nav-fixed .sb-topnav  { position: fixed; top: 0; right: 0; left: 0; z-index: 1030; height: var(--topnav-height); }
.sb-nav-fixed #layoutSidenav { padding-top: var(--topnav-height); }

#layoutSidenav {
  display: flex;
  min-height: calc(100vh - var(--topnav-height));
}

#layoutSidenav_nav {
  flex-basis: var(--sidebar-width);
  flex-shrink: 0;
  transition: all .15s ease-in-out;
  z-index: 1028;
}

#layoutSidenav_content {
  position: relative;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

main {
  flex-grow: 1;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sb-sidenav {
  display: flex;
  flex-direction: column;
  height: 100%;
  flex-wrap: nowrap;
  background: #fff;
  position: fixed;
  top: var(--topnav-height);
  bottom: 0;
  width: var(--sidebar-width);
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid #e2e8f0;
}

.sb-sidenav-menu { flex-grow: 1; }

.sb-sidenav-menu .nav-link {
  display: flex;
  align-items: center;
  padding: .6rem 1.2rem;
  font-size: .875rem;
  font-weight: 500;
  color: #64748b;
  border-left: 3px solid transparent;
  transition: all .15s;
}

.sb-sidenav-menu .nav-link:hover {
  color: var(--brand);
  background: var(--brand-light);
  border-left-color: var(--brand);
}

.sb-sidenav-menu .nav-link.active {
  color: var(--brand);
  background: var(--brand-light);
  border-left-color: var(--brand);
  font-weight: 600;
}

.sb-sidenav-menu .nav-link.disabled { opacity: .5; cursor: default; }

.sb-nav-link-icon {
  display: inline-flex;
  margin-right: .5rem;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sb-nav-link-icon svg, .sb-nav-link-icon i {
  width: 18px;
  height: 18px;
}

.sb-sidenav-menu-heading {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #94a3b8;
  padding: 1rem 1.2rem .4rem;
}

.sb-sidenav-footer {
  padding: .8rem 1.2rem;
  border-top: 1px solid #e2e8f0;
  font-size: .78rem;
}

/* ── Topbar ───────────────────────────────────────────────── */
.sb-topnav .navbar-brand {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

/* ── Stats cards ──────────────────────────────────────────── */
.stat-card { border-radius: .75rem; border: none; }
.stat-value { font-size: 1.8rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: .78rem; color: #64748b; margin-top: .2rem; text-transform: uppercase; letter-spacing: .05em; }
.stat-icon {
  width: 52px; height: 52px;
  border-radius: .75rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 26px; height: 26px; }
.stat-icon-sm {
  width: 40px; height: 40px;
  border-radius: .6rem;
  display: flex; align-items: center; justify-content: center;
}
.stat-icon-sm svg { width: 20px; height: 20px; }

/* ── Cards ────────────────────────────────────────────────── */
.card { border: none; border-radius: .75rem; }
.card-header {
  background: transparent;
  border-bottom: 1px solid #f1f5f9;
  font-weight: 600;
}
.card.shadow-sm { box-shadow: 0 1px 8px rgba(0,0,0,.08) !important; }

/* ── Tables ───────────────────────────────────────────────── */
.table th { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: #64748b; border-top: none; }
.table-light th { background: #f8fafc; }

/* ── Buttons xs ───────────────────────────────────────────── */
.btn-xs { padding: .2rem .45rem; font-size: .75rem; border-radius: .35rem; }

/* ── Icons ────────────────────────────────────────────────── */
.icon-sm { width: 16px; height: 16px; }
[data-feather] { pointer-events: none; }

/* ── Vehicles ─────────────────────────────────────────────── */
.vehicle-card { border-radius: .75rem; transition: transform .15s, box-shadow .15s; }
.vehicle-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,.12) !important; }

/* ── Hover BG ────────────────────────────────────────────── */
.hover-bg:hover { background: #f8fafc; }

/* ── Form focus ──────────────────────────────────────────── */
.form-control:focus, .form-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 .2rem rgba(var(--brand-rgb), .2);
}

/* ── Responsive sidebar ───────────────────────────────────── */
@media (max-width: 991.98px) {
  #layoutSidenav_nav {
    transform: translateX(calc(-1 * var(--sidebar-width)));
    position: fixed;
    top: var(--topnav-height);
    bottom: 0;
    z-index: 1029;
  }
  .sb-sidenav-toggled #layoutSidenav_nav {
    transform: translateX(0);
  }
  #layoutSidenav_content {
    margin-left: 0 !important;
  }
}

/* Sidebar offset handled by flexbox (#layoutSidenav_nav flex-basis)
   No margin-left needed on content — sidebar is position:fixed
   but #layoutSidenav_nav reserves the space in the flex row */

/* ── Alerts ───────────────────────────────────────────────── */
.alert { border: none; border-radius: .6rem; }

/* ── Object fit ───────────────────────────────────────────── */
.object-fit-cover { object-fit: cover; }

/* ── Breadcrumb ───────────────────────────────────────────── */
.breadcrumb-item + .breadcrumb-item::before { color: #94a3b8; }
.breadcrumb-item a { color: var(--brand); text-decoration: none; }

/* ── Phase 2 additions ─────────────────────────────────── */

/* Cotización wizard steps */
.step-badge {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
}

/* Price summary sticky card */
.price-summary-card {
  border-left: 4px solid var(--brand);
}
.price-total-row {
  background: var(--brand-light);
  border-radius: .5rem;
  padding: .75rem 1rem;
}

/* Payment badge colors */
.badge-pagado     { background: #0d6efd; }
.badge-pendiente  { background: #ffc107; color: #000; }
.badge-entregado  { background: #198754; }
.badge-anulada    { background: #dc3545; }
.badge-parcial    { background: #0dcaf0; color: #000; }

/* PDF preview link */
.pdf-link {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  color: #dc3545;
  text-decoration: none;
  font-weight: 500;
  font-size: .9rem;
}
.pdf-link:hover { text-decoration: underline; }

/* Trade-in card */
.trade-in-card {
  border: 2px dashed #cbd5e1;
  border-radius: .75rem;
  padding: 1.25rem;
  background: #fafbff;
}

/* Venta progress bar */
.payment-progress {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: #e2e8f0;
}
.payment-progress-bar {
  height: 100%;
  background: var(--brand);
  border-radius: 999px;
  transition: width .4s ease;
}

/* Status timeline */
.timeline { position: relative; padding-left: 2rem; }
.timeline::before {
  content: '';
  position: absolute;
  left: .65rem;
  top: 0; bottom: 0;
  width: 2px;
  background: #e2e8f0;
}
.timeline-item { position: relative; padding-bottom: 1.25rem; }
.timeline-dot {
  position: absolute;
  left: -1.55rem;
  top: .2rem;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--brand);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--brand);
}

/* Reserva countdown chip */
.countdown-chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: #fff8f0;
  border: 1px solid #fed7aa;
  border-radius: 999px;
  padding: .2rem .75rem;
  font-size: .8rem;
  color: #c2410c;
  font-weight: 600;
}

/* Vehicle card — compact list view */
.vehicle-list-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .75rem;
  border-radius: .5rem;
  transition: background .15s;
}
.vehicle-list-item:hover { background: var(--brand-light); }
.vehicle-thumb {
  width: 72px; height: 54px;
  object-fit: cover;
  border-radius: .375rem;
  flex-shrink: 0;
  background: #f3f4f6;
}

/* Adicionales row (cotizacion wizard) */
.adicional-row input { transition: border-color .15s; }
.adicional-row input:focus { border-color: var(--brand); }

/* Responsive table cards on mobile */
@media (max-width: 576px) {
  .table-card-mobile thead { display: none; }
  .table-card-mobile tr {
    display: block;
    border: 1px solid #e2e8f0;
    border-radius: .5rem;
    margin-bottom: .5rem;
    padding: .5rem;
  }
  .table-card-mobile td {
    display: flex;
    justify-content: space-between;
    border: none;
    padding: .25rem .5rem;
    font-size: .85rem;
  }
  .table-card-mobile td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #64748b;
    flex-shrink: 0;
    margin-right: .5rem;
  }
}
