/* ── Variables ─────────────────────────────────────────────── */
:root {
  --color-primary:   #ff8000;
  --color-primary-dark: #cc6600;
  --color-secondary: #6b7280;
  --color-success:   #057a55;
  --color-warning:   #c27803;
  --color-danger:    #c81e1e;
  --color-bg:        #f3f4f6;
  --color-sidebar:   #333333;
  --sidebar-w:       240px;
  --header-h:        56px;

  /* Bootstrap 5 override */
  --bs-primary:          #ff8000;
  --bs-primary-rgb:      255, 128, 0;
  --bs-link-color:       #ff8000;
  --bs-link-hover-color: #cc6600;
}

/* ── Reset / base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; background: var(--color-bg); color: #111827; }
a { color: inherit; text-decoration: none; }

/* ── Login ─────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #333333 0%, #1a1a1a 60%, #ff8000 100%);
}
.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18);
}
.login-logo { text-align: center; margin-bottom: 1.5rem; }
.login-logo img { height: 56px; }
.login-logo h1 { font-size: 1.6rem; font-weight: 700; color: var(--color-primary); }

/* ── Layout ────────────────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  min-height: 100vh;
}

/* Header */
.app-header {
  grid-column: 1 / -1;
  background: var(--color-sidebar);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-header .brand { font-size: 1.2rem; font-weight: 700; letter-spacing: .04em; }
.app-header .spacer { flex: 1; }
.notif-btn { position: relative; background: none; border: none; color: #fff; cursor: pointer; font-size: 1.25rem; }
.notif-badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--color-danger); color: #fff;
  font-size: .65rem; font-weight: 700;
  width: 16px; height: 16px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

/* Sidebar */
.app-sidebar {
  background: var(--color-sidebar);
  color: #d1d5db;
  padding-top: .5rem;
  overflow-y: auto;
}
.sidebar-nav { list-style: none; }
.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1.25rem;
  border-radius: 6px;
  margin: 2px 8px;
  font-size: .9rem;
  transition: background .15s, color .15s;
}
.sidebar-nav li a:hover,
.sidebar-nav li a.active {
  background: rgba(255,255,255,.1);
  color: #fff;
}
.sidebar-nav li a .icon { font-size: 1.1rem; width: 20px; text-align: center; }

/* Main content */
.app-main {
  overflow-y: auto;
  padding: 1.5rem;
}

/* ── Cards y tablas ────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: 10px;
  padding: 1.25rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
  margin-bottom: 1.25rem;
}
.card-title { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; color: #374151; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th, td { padding: .65rem .85rem; text-align: left; border-bottom: 1px solid #e5e7eb; }
th { background: #f9fafb; font-weight: 600; color: #374151; }
tr:hover td { background: #f9fafb; }

/* ── Badges de estado ──────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-recibido        { background:#dbeafe; color:#1e40af; }
.badge-en_alistamiento { background:#fef3c7; color:#92400e; }
.badge-listo           { background:#d1fae5; color:#065f46; }
.badge-facturado       { background:#ede9fe; color:#5b21b6; }
.badge-en_reparto      { background:#ffedd5; color:#9a3412; }
.badge-entregado       { background:#d1fae5; color:#065f46; }
.badge-cancelado       { background:#fee2e2; color:#991b1b; }

/* ── Pines del mapa ────────────────────────────────────────── */
.pin-verde   { background: #10b981; }
.pin-naranja { background: #f59e0b; }
.pin-rojo    { background: #ef4444; }
.pin-gris    { background: #9ca3af; }

/* ── KPI cards (dashboard) ─────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.kpi-card {
  background: #fff;
  border-radius: 10px;
  padding: 1.25rem 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,.07);
  text-align: center;
}
.kpi-card .kpi-value { font-size: 1.75rem; font-weight: 700; color: var(--color-primary); }
.kpi-card .kpi-label { font-size: .8rem; color: #6b7280; margin-top: .25rem; }

/* ── Modales ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.modal-header h2 { font-size: 1.05rem; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: #6b7280; }

/* ── Botones ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: .875rem;
  font-weight: 500;
  transition: opacity .15s;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary  { background: var(--color-primary);  color: #fff; }
.btn-success  { background: var(--color-success);  color: #fff; }
.btn-danger   { background: var(--color-danger);   color: #fff; }
.btn-outline  { background: transparent; border: 1px solid #d1d5db; color: #374151; }
.btn-whatsapp { background: #25d366; color: #fff; }
.btn-fab {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: 1.5rem;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Formularios ───────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: .3rem; }
.form-control {
  width: 100%;
  padding: .55rem .8rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: .875rem;
  outline: none;
  transition: border-color .15s;
}
.form-control:focus { border-color: var(--color-primary); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

/* ── Mapa ──────────────────────────────────────────────────── */
#map-container { height: calc(100vh - var(--header-h) - 3rem); border-radius: 10px; overflow: hidden; }

/* ── Overrides Bootstrap con colores Yarvis ────────────────── */
.bg-primary,
.navbar.bg-primary           { background-color: #333333 !important; }
.btn-primary                 { background-color: #ff8000 !important; border-color: #ff8000 !important; }
.btn-primary:hover           { background-color: #cc6600 !important; border-color: #cc6600 !important; }
.btn-outline-primary         { color: #ff8000 !important; border-color: #ff8000 !important; }
.btn-outline-primary:hover   { background-color: #ff8000 !important; color: #fff !important; }
.text-primary                { color: #ff8000 !important; }
.border-primary              { border-color: #ff8000 !important; }
.badge.bg-primary            { background-color: #ff8000 !important; }
.form-control:focus,
.form-select:focus           { border-color: #ff8000 !important; box-shadow: 0 0 0 .2rem rgba(255,128,0,.2) !important; }
.nav-link.active             { color: #ff8000 !important; }
.navbar-dark .nav-link:hover { color: #ff8000 !important; }
.navbar-brand img            { height: 38px; }

/* Sidebar ítem activo con acento naranja */
.sidebar-nav li a.active {
  background: rgba(255,128,0,.15);
  color: #ff8000 !important;
  border-left: 3px solid #ff8000;
}
.sidebar-nav li a:hover { color: #ff8000 !important; }

/* ── Responsive (móvil) ────────────────────────────────────── */
@media (max-width: 768px) {
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-h) 1fr auto;
  }
  .app-sidebar {
    display: none;
    position: fixed;
    inset: var(--header-h) auto 0 0;
    width: var(--sidebar-w);
    z-index: 150;
  }
  .app-sidebar.open { display: block; }
  .app-main { grid-column: 1; padding: 1rem; }
  .form-row { grid-template-columns: 1fr; }
}
