/* Paleta tomada de la captura de Transportes XEP */
:root {
  --sidebar: #0d3b36;
  --sidebar-hover: #15534b;
  --accent: #0f8a5f;
  --accent-dark: #0b6e4c;
  --accent-light: #1aa57a;
  --teal: #0f6b74;
  --table-head: #0e4a42;
  --bg: #eef2f1;
  --card: #ffffff;
  --text: #1d2b29;
  --muted: #6b7b78;
  --border: #d5dedb;
  --danger: #c0392b;
  --danger-dark: #a93226;
  --radius: 8px;
  --shadow: 0 2px 10px rgba(13, 59, 54, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
}

.hidden { display: none !important; }

h1, h2, h3 { margin: 0; font-weight: 700; }

/* ---------- Marca ---------- */
.brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px 26px; }
.chevrons { width: 52px; height: 42px; flex-shrink: 0; }
.brand-name { color: #fff; font-style: italic; font-weight: 800; line-height: 1; font-size: 19px; letter-spacing: .3px; }
.brand-name em { color: var(--accent-light); font-style: italic; }
.brand-sub { color: #bfe3d8; font-style: italic; font-size: 11px; margin-top: 4px; }
.brand-name.dark, .brand-sub.dark { color: #0d3b36; }
.brand-name.dark span { color: #0d3b36; }
.brand-name.dark em { color: var(--accent); }
.brand-sub.dark { color: #0d3b36; }

.brand-login { justify-content: center; padding: 0 0 18px; }
.brand-login .brand-name { color: var(--sidebar); }
.brand-login .brand-name em { color: var(--accent); }
.brand-login .brand-sub { color: var(--sidebar); }

/* ---------- Inicio de sesión ---------- */
.login-view {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #0d3b36 0%, #0f6b74 55%, #1aa57a 100%);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 12px;
  padding: 32px 28px 28px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.login-card h1 { text-align: center; color: var(--sidebar); font-size: 20px; margin-bottom: 8px; }
.login-card label { font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 6px; }

/* ---------- Layout de la aplicación ---------- */
.app-shell { display: flex; min-height: 100%; }

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--sidebar);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.menu { display: flex; flex-direction: column; gap: 2px; padding: 4px 12px; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  background: transparent;
  color: #e6f4ef;
  border: 0;
  border-radius: var(--radius);
  font-size: 16px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
}
.menu-item:hover { background: var(--sidebar-hover); }
.menu-item.active { background: var(--accent); color: #fff; font-weight: 600; }
.menu-item svg {
  width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: linear-gradient(90deg, #ffffff 0%, #cdeee2 30%, #3fbf93 65%, #0f8a5f 100%);
  gap: 16px;
}
.topbar-brand { display: flex; align-items: center; gap: 12px; }
.topbar-user { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 600; }
.topbar-user #user-name { color: #fff; }
.topbar-brand + .topbar-user { margin-left: auto; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
}
.role-tag {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px; background: rgba(255,255,255,.25); color: #fff;
}
.topbar-user .btn-outline {
  color: #fff; border-color: rgba(255,255,255,.8); background: transparent;
}
.topbar-user .btn-outline:hover { background: rgba(255,255,255,.15); }

.content { padding: 28px 32px 40px; overflow-x: hidden; }
.view { display: none; }
.view.active { display: block; }
.page-title { font-size: 30px; color: #1d2b29; margin-bottom: 22px; }
.section-title { font-size: 22px; margin: 32px 0 14px; color: #1d2b29; }
.hint { font-size: 13px; color: var(--muted); margin: 8px 2px 0; }

/* ---------- Formularios ---------- */
.input {
  width: 100%;
  padding: 11px 13px;
  font-size: 15px;
  font-family: inherit;
  border: 1px solid #8a9a97;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}
.input:focus { outline: 2px solid var(--accent-light); outline-offset: 0; border-color: var(--accent); }
select.input { appearance: auto; }

.form-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.form-row .input { width: 230px; }
.form-row .input-wide { width: 380px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .card label { font-size: 14px; font-weight: 600; color: #2b3a38; }

.form-error { color: var(--danger); font-size: 14px; min-height: 18px; margin: 8px 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 24px; margin-bottom: 14px; }

.search-input { max-width: 380px; }
.search-big { max-width: 640px; padding: 15px 16px; font-size: 17px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-block { width: 100%; justify-content: center; margin-top: 10px; }
.btn-ghost { background: #e7ecea; color: #2b3a38; }
.btn-ghost:hover { background: #d8e0dd; }
.btn-outline { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-outline:hover { background: #e6f5ee; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-dark); }
.btn-small { padding: 7px 12px; font-size: 13px; }
.btn-soft { background: #e4ebe9; color: #1d2b29; }
.btn-soft:hover { background: #d4dedb; }

.icon-btn {
  background: transparent; border: 0; cursor: pointer; padding: 4px 6px;
  color: #e07a3c; display: inline-flex; align-items: center;
}
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.delete { color: #8a9a97; }
.icon-btn.delete:hover { color: var(--danger); }
.icon-btn:hover { color: var(--accent-dark); }
.actions-cell { white-space: nowrap; text-align: center; }
.sep { color: #9aa8a5; margin: 0 6px; }

/* ---------- Tarjetas ---------- */
.card {
  background: var(--card);
  border-radius: 10px;
  box-shadow: var(--shadow);
  margin-bottom: 26px;
  overflow: hidden;
}
.card-header {
  padding: 16px 22px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(90deg, #0f6b74 0%, #1aa57a 100%);
}
.card-header.light { background: #fff; color: #1d2b29; border-bottom: 1px solid var(--border); }
.card-body { padding: 22px; }
.card .btn-primary { margin-top: 4px; }

/* ---------- Tablas ---------- */
.table-wrap { background: #fff; border-radius: 6px; overflow-x: auto; box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table thead th {
  background: #f1f5f4;
  color: #1d2b29;
  font-weight: 700;
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}
.table tbody td {
  padding: 13px 12px;
  border-bottom: 1px solid #e6ecea;
  text-align: center;
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #f7fbf9; }
.table .col-actions { width: 110px; }
.table .codes { font-family: "Consolas", "Courier New", monospace; font-size: 14px; }
.table td.name { font-weight: 600; }
.table tbody tr.clickable { cursor: pointer; }
.table thead th.usr-col { text-align: left; }
.table td.left { text-align: left; }

.mono { font-family: "Consolas", "Courier New", monospace; }

.pill {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 700;
}
.pill-admin { background: #fdf0d2; color: #8a5a00; }
.pill-staff { background: #d8f2e7; color: #0b6e4c; }
.status-active { color: var(--accent); font-weight: 700; }
.status-inactive { color: var(--danger); font-weight: 700; }

.inline-pass { display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.inline-pass .input { width: 180px; padding: 8px 10px; font-size: 14px; }

.empty { text-align: center; color: var(--muted); padding: 26px; }

/* ---------- Resultados de búsqueda ---------- */
.results { margin-top: 18px; display: flex; flex-direction: column; gap: 10px; max-width: 760px; }
.result-item {
  background: #fff; border-radius: 8px; padding: 14px 18px; box-shadow: var(--shadow);
  cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  border-left: 4px solid var(--accent);
}
.result-item:hover { background: #f7fbf9; }
.result-item .r-name { font-weight: 700; }
.result-item .r-meta { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ---------- Chips de códigos ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.chip {
  display: inline-block; background: #e3f4ed; color: var(--accent-dark);
  border: 1px solid #bfe5d4; padding: 3px 9px; border-radius: 6px;
  font-family: "Consolas", "Courier New", monospace; font-size: 13px; font-weight: 600;
}

/* ---------- Ventana emergente ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(13, 59, 54, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal-card {
  background: #fff; border-radius: 12px; width: 100%; max-width: 520px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3); overflow: hidden;
  animation: pop .15s ease-out;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px; color: #fff;
  background: linear-gradient(90deg, #0f6b74 0%, #1aa57a 100%);
}
.modal-header h3 { font-size: 19px; }
.modal-close { background: transparent; border: 0; color: #fff; font-size: 28px; line-height: 1; cursor: pointer; padding: 0 4px; }
.modal-body { padding: 22px; }
.info-row { display: grid; grid-template-columns: 130px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid #eef3f1; align-items: start; }
.info-row:last-child { border-bottom: 0; }
.info-label { color: var(--muted); font-weight: 600; font-size: 14px; }
.info-value { font-weight: 600; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---------- Notificaciones ---------- */
.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--sidebar); color: #fff;
  padding: 13px 18px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.25);
  z-index: 60; max-width: 360px; font-weight: 600;
}
.toast.error { background: var(--danger); }

/* ---------- Control de acceso por rol ---------- */
body.role-staff .admin-only { display: none !important; }
body.role-staff .admin-col { display: none !important; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .menu { flex-direction: row; flex-wrap: wrap; }
  .menu-item { width: auto; flex: 1; justify-content: center; }
  .topbar { height: auto; flex-wrap: wrap; padding: 14px; }
  .content { padding: 18px; }
  .grid-2 { grid-template-columns: 1fr; }
  .form-row .input, .form-row .input-wide { width: 100%; }
  .info-row { grid-template-columns: 1fr; }
}
