/* ============================================
   VARIABLES GLOBALES (Design Tokens)
   ============================================ */
:root {
  /* Colores base */
  --color-bg: #f4f6f9;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;

  /* Sidebar */
  --color-sidebar: #0b2545;
  --color-sidebar-hover: #123762;
  --color-sidebar-text: #c6d4e6;
  --color-sidebar-text-active: #ffffff;

  /* Colores de marca */
  --color-primary: #1d6fb8;
  --color-primary-dark: #144e85;

  /* Estados */
  --color-success: #1f9d55;
  --color-danger: #d0453a;
  --color-warning: #e3a62d;

  /* Texto */
  --color-text: #1a2332;
  --color-text-muted: #64748b;

  /* Tipografía */
  --font-display: "Manrope", sans-serif;
  --font-body: "Inter", sans-serif;
  --font-mono: "JetBrains Mono", monospace;

  /* Medidas de layout */
  --sidebar-width: 260px;
  --sidebar-width-collapsed: 72px;
  --topbar-height: 64px;
  --radius: 8px;

  /* Agregar dentro del bloque :root existente */
  --color-purple: #6d4aae;
  --color-orange: #e07b39;

  /* Agregar dentro del bloque :root existente */
  --color-gris: #64748b;
}

/* ============================================
   RESET BÁSICO
   ============================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  background-color: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.5;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  color: var(--color-text);
}

a {
  text-decoration: none;
  color: inherit;
}

button {
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  background: none;
}

ul {
  list-style: none;
}

/* Clase de utilidad para cifras clave (kilometraje, precios, IDs) */
.dato-numerico {
  font-family: var(--font-mono);
  font-weight: 600;
}

/* ============================================
   ESTRUCTURA GENERAL (App Shell)
   ============================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* --------- SIDEBAR --------- */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--color-sidebar);
  color: var(--color-sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  transition:
    transform 0.25s ease,
    width 0.25s ease;
  z-index: 100;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  color: #ffffff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar__brand-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

.sidebar__item {
  position: relative;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-sidebar-text);
  border-left: 3px solid transparent;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar__link:hover {
  background-color: var(--color-sidebar-hover);
  color: var(--color-sidebar-text-active);
}

.sidebar__item.is-active .sidebar__link {
  background-color: var(--color-sidebar-hover);
  border-left-color: var(--color-primary);
  color: var(--color-sidebar-text-active);
}

.sidebar__icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar__label {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Botón para colapsar/expandir en tablet, y abrir/cerrar en móvil */
.sidebar__toggle {
  display: none;
}

/* --------- TOPBAR --------- */
.topbar {
  height: var(--topbar-height);
  background-color: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar__left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar__menu-btn {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
}

.topbar__menu-btn:hover {
  background-color: var(--color-bg);
}

.topbar__title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 18px;
}

.topbar__search {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 8px 12px;
  width: 260px;
}

.topbar__search input {
  border: none;
  background: none;
  outline: none;
  font-size: 13px;
  width: 100%;
  font-family: var(--font-body);
}

.topbar__user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar__user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background-color: var(--color-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.topbar__user-name {
  font-weight: 600;
  font-size: 13px;
  line-height: 1.2;
}

.topbar__user-role {
  font-size: 12px;
  color: var(--color-text-muted);
}

/* --------- CONTENIDO PRINCIPAL --------- */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  transition: margin-left 0.25s ease;
}

.content-inner {
  padding: 24px;
}

/* ============================================
   COMPONENTES REUTILIZABLES BASE
   ============================================ */
.card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  transition:
    background-color 0.15s ease,
    opacity 0.15s ease;
}

.btn-primary {
  background-color: var(--color-primary);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--color-primary-dark);
}

.btn-secondary {
  background-color: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background-color: var(--color-border);
}
/* ============================================
   PANTALLA DE LOGIN
   ============================================ */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--color-sidebar) 0%, #163a63 100%);
  padding: 20px;
}

.login-box {
  background-color: var(--color-surface);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 50px rgba(11, 37, 69, 0.35);
}

.login-box__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.login-box__brand h1 {
  font-size: 20px;
}

.login-box__subtitulo {
  color: var(--color-text-muted);
  font-size: 13px;
  margin-bottom: 24px;
}

.campo {
  margin-bottom: 16px;
}

.campo label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.campo input[type="text"],
.campo input[type="password"] {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font-body);
  outline: none;
  transition: border-color 0.15s ease;
}

.campo input[type="text"]:focus,
.campo input[type="password"]:focus {
  border-color: var(--color-primary);
}

.campo__password-wrapper {
  position: relative;
}

.campo__password-wrapper input {
  padding-right: 40px;
}

.campo__toggle-password {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  display: flex;
}

.campo--checkbox label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
}

.campo--checkbox input {
  width: auto;
}

.btn--full {
  width: 100%;
  justify-content: center;
  padding: 12px;
  font-size: 14px;
}

.mensaje-error {
  background-color: #fdecec;
  color: var(--color-danger);
  border: 1px solid #f5c6c6;
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
}

.login-box__ayuda {
  margin-top: 20px;
  font-size: 12px;
  color: var(--color-text-muted);
  text-align: center;
}
.topbar__logout-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  color: var(--color-text-muted);
}

.topbar__logout-btn:hover {
  background-color: #fdecec;
  color: var(--color-danger);
}

/* ============================================
   ALERTAS (campanita en el topbar)
   ============================================ */
.topbar__alertas-wrapper {
  position: relative;
}

.topbar__alertas-btn {
  position: relative;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  color: var(--color-text-muted);
}

.topbar__alertas-btn:hover {
  background-color: var(--color-bg);
}

.topbar__alertas-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background-color: var(--color-warning);
  color: var(--color-text);
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

.topbar__alertas-badge--urgente {
  background-color: var(--color-danger);
  color: #ffffff;
}

.topbar__alertas-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: -10px;
  width: 340px;
  max-height: 420px;
  overflow-y: auto;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 12px 30px rgba(11, 37, 69, 0.18);
  z-index: 150;
}

.topbar__alertas-header {
  padding: 14px 16px;
  font-weight: 700;
  font-size: 13px;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  background-color: var(--color-surface);
}

.topbar__alertas-vacio {
  padding: 30px 16px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 13px;
}

.topbar__alertas-lista {
  display: flex;
  flex-direction: column;
}

.topbar__alerta-item {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
}

.topbar__alerta-item:last-child {
  border-bottom: none;
}

.topbar__alerta-punto {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--color-warning);
  margin-top: 5px;
  flex-shrink: 0;
}

.topbar__alerta-item--urgente .topbar__alerta-punto {
  background-color: var(--color-danger);
}

.topbar__alerta-contenido {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12.5px;
}

.topbar__alerta-contenido strong {
  font-size: 13px;
}

.topbar__alerta-contenido span {
  color: var(--color-text-muted);
}

.topbar__alerta-monto {
  color: var(--color-text) !important;
  font-weight: 600;
  margin-top: 2px;
}

@media (max-width: 480px) {
  .topbar__alertas-panel {
    width: calc(100vw - 32px);
    right: -60px;
  }
}

.topbar__sucursal-wrapper {
  margin-right: 4px;
}

.topbar__sucursal-select {
  padding: 8px 12px;
  border: 1.5px solid var(--color-primary);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-primary);
  background-color: #e5f0fa;
  cursor: pointer;
  outline: none;
}

@media (max-width: 480px) {
  .topbar__sucursal-select {
    font-size: 11px;
    padding: 6px 8px;
  }
}
