/* ==========================================================
   Interpebol — Estilo FinTech premium (negro + dorado)
   ========================================================== */

:root {
  --bg-0: #0A0A0A;
  --bg-1: #121212;
  --bg-2: #1A1A1A;
  --bg-3: #242424;
  --border: #2A2A2A;
  --border-strong: #3A3A3A;

  --text-primary: #F5F5F5;
  --text-secondary: #A0A0A0;
  --text-muted: #6B6B6B;

  --gold: #D4AF37;
  --gold-bright: #E8C76A;
  --gold-dark: #B89525;
  --gold-soft: rgba(212, 175, 55, 0.12);
  --gold-glow: rgba(212, 175, 55, 0.35);

  --success: #2EBD85;
  --danger:  #E55353;
  --warning: #F0B429;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;

  --shadow-card: 0 8px 30px rgba(0, 0, 0, 0.45);
  --shadow-gold: 0 6px 24px rgba(212, 175, 55, 0.18);
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-0);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  /* Soporte para safe-area en iPhones con notch / Dynamic Island */
  padding-bottom: env(safe-area-inset-bottom);
}

body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(212, 175, 55, 0.07), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(212, 175, 55, 0.05), transparent 60%),
    var(--bg-0);
}

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-bright); }

/* ===== Layout helpers ===== */
.container        { max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.container-narrow { max-width: 460px;  margin: 0 auto; padding: 0 24px; }

.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

/* ===== Brand ===== */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.5px;
}
.brand-mark {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: #111;
  font-weight: 800;
  box-shadow: var(--shadow-gold);
}
.brand-name { color: var(--text-primary); }
.brand-name span { color: var(--gold); }

/* ===== Cards ===== */
.card {
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-card);
}
.card-tight { padding: 22px; border-radius: var(--radius-md); }

.card h1, .card h2 { margin-top: 0; }

/* ===== Typography ===== */
h1 { font-size: 28px; letter-spacing: -0.01em; margin: 0 0 6px; }
h2 { font-size: 20px; margin: 0 0 8px; }
h3 { font-size: 16px; margin: 0 0 6px; color: var(--text-secondary); font-weight: 600; }
.muted { color: var(--text-secondary); }
.tiny  { font-size: 12px; color: var(--text-muted); }

.gold { color: var(--gold); }
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
  margin: 22px 0;
}

/* ===== Forms ===== */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}
.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  gap: 8px;
}
.field-head label { margin-bottom: 0; }

/* ===== Botón Copiar (pequeño, dorado, junto al label) ===== */
.btn-copy {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--gold-soft);
  border: 1px solid rgba(212, 175, 55, 0.3);
  color: var(--gold-bright);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}
.btn-copy:hover {
  background: rgba(212, 175, 55, 0.2);
  border-color: var(--gold);
  transform: translateY(-1px);
}
.btn-copy:active { transform: translateY(0); }
.btn-copy.copied {
  background: rgba(46, 189, 133, 0.15);
  border-color: rgba(46, 189, 133, 0.4);
  color: var(--success);
}
.btn-copy .copy-icon { font-size: 13px; line-height: 1; }

.input, select, textarea {
  width: 100%;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  outline: none;
}
.input:focus, select:focus, textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
  background: var(--bg-2);
}
.input::placeholder { color: var(--text-muted); }
.input[readonly] { background: var(--bg-0); color: var(--gold-bright); font-weight: 600; }
.input.large {
  font-size: 22px;
  font-weight: 600;
  padding: 16px 18px;
  letter-spacing: 0.5px;
}

select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23D4AF37' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  text-decoration: none;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: #1a1a1a;
  box-shadow: var(--shadow-gold);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(212, 175, 55, 0.28);
}

.btn-ghost {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.btn-ghost:hover:not(:disabled) {
  border-color: var(--gold);
  color: var(--gold);
}

.btn-danger {
  background: rgba(229, 83, 83, 0.1);
  color: var(--danger);
  border-color: rgba(229, 83, 83, 0.35);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(229, 83, 83, 0.2);
}

.btn-success {
  background: rgba(46, 189, 133, 0.12);
  color: var(--success);
  border-color: rgba(46, 189, 133, 0.4);
}
.btn-success:hover:not(:disabled) {
  background: rgba(46, 189, 133, 0.22);
}

.btn-block { width: 100%; }
.btn-sm    { padding: 7px 12px; font-size: 13px; }

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-pending    { color: var(--warning); background: rgba(240, 180, 41, 0.1); border-color: rgba(240, 180, 41, 0.3); }
.badge-approved   { color: var(--success); background: rgba(46, 189, 133, 0.1); border-color: rgba(46, 189, 133, 0.3); }
.badge-rejected   { color: var(--danger);  background: rgba(229, 83, 83, 0.1);  border-color: rgba(229, 83, 83, 0.3); }
.badge-admin      { color: var(--gold);    background: var(--gold-soft);        border-color: rgba(212, 175, 55, 0.3); }
.badge-superadmin { color: #fff;           background: linear-gradient(135deg,#7c3aed,#4f46e5); border-color: rgba(124,58,237,.4); font-weight: 700; }
.badge-user       { color: #60a5fa;        background: rgba(96,165,250,.1);      border-color: rgba(96,165,250,.3); }

/* Permission chips en modal */
.perm-chip:hover { background: var(--surface-3, #3a3a50) !important; }

/* Modal actions footer (compartido con admin.html) */
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  gap: 8px;
}

/* Modal backdrop compartido (alias — el CSS principal está en book.css) */
.modal-backdrop.hidden { display: none !important; }

/* ===== Topbar ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 10, 10, 0.65);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 10;
}
.topbar .user-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-1);
  font-size: 13px;
}
.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: #111;
  font-weight: 800;
  display: grid; place-items: center;
  font-size: 12px;
}

/* ===== Grid ===== */
.grid { display: grid; gap: 24px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-dash { grid-template-columns: 1.1fr 1fr; }
@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-dash { grid-template-columns: 1fr; }
}

.stat {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
}
.stat .label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); }
.stat .value { font-size: 24px; font-weight: 700; color: var(--gold); margin-top: 4px; }

/* ===== Calculator ===== */
.calc-arrow {
  display: grid; place-items: center;
  height: 36px;
  color: var(--gold);
  font-size: 18px;
}
.calc-rate-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--gold-soft);
  border: 1px solid rgba(212, 175, 55, 0.25);
  color: var(--gold-bright);
  font-size: 12px;
  font-weight: 600;
}

/* ===== Tables ===== */
.table-wrap {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th {
  background: var(--bg-3);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255, 255, 255, 0.02); }

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 1000;
}
.toast {
  padding: 14px 18px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius-md);
  min-width: 280px;
  max-width: 380px;
  box-shadow: var(--shadow-card);
  animation: slideIn 0.25s ease;
  font-size: 14px;
}
.toast-success { border-left-color: var(--success); }
.toast-error   { border-left-color: var(--danger); }
.toast-info    { border-left-color: var(--gold); }
@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ===== Auth pages ===== */
.auth-card { width: 100%; max-width: 440px; }
.auth-header { text-align: center; margin-bottom: 24px; }
.auth-footer { text-align: center; margin-top: 18px; font-size: 14px; color: var(--text-secondary); }

/* ===== Utils ===== */
.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.gap-sm { gap: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }
.text-center { text-align: center; }
.fw-700 { font-weight: 700; }

.error-text {
  color: var(--danger);
  font-size: 13px;
  margin-top: 6px;
  min-height: 18px;
}

/* ===== Transitions ===== */
[x-cloak] { display: none !important; }
.fade-enter { opacity: 0; transform: translateY(4px); }
.fade-enter-active { transition: all 0.2s ease; opacity: 1; transform: none; }

/* =================================================================
   MOBILE — optimizaciones específicas (≤ 600px)
   ================================================================= */
@media (max-width: 600px) {

  /* --- Layout base --- */
  body {
    background:
      radial-gradient(800px 400px at 80% -10%, rgba(212, 175, 55, 0.06), transparent 60%),
      var(--bg-0);
  }
  .container        { padding: 0 14px; }
  .container-narrow { padding: 0 14px; }
  .center-screen    { padding: 16px 12px; min-height: 100dvh; }

  /* --- Tipografía --- */
  h1 { font-size: 24px; }
  h2 { font-size: 18px; }
  h3 { font-size: 14px; }

  /* --- Cards --- */
  .card       { padding: 20px 18px; border-radius: 14px; }
  .card-tight { padding: 16px; border-radius: 12px; }

  /* --- Inputs: 16px mínimo evita el zoom-in automático de iOS --- */
  .input, select, textarea { font-size: 16px; padding: 11px 13px; }
  .input.large {
    font-size: 19px;
    padding: 13px 15px;
    letter-spacing: 0.3px;
  }

  /* --- Topbar compacto --- */
  .topbar {
    padding: 12px 14px;
    gap: 8px;
  }
  .topbar .user-chip {
    padding: 4px 4px;
    gap: 0;
  }
  .topbar .user-chip span { display: none; }   /* esconde nombre, deja avatar */
  .brand-name { font-size: 17px; }
  .brand-mark { width: 32px; height: 32px; border-radius: 8px; font-size: 14px; }
  .topbar .btn-sm {
    padding: 6px 10px;
    font-size: 12px;
  }
  /* En admin: el badge ADMIN dentro del brand-name */
  .brand-name .badge { font-size: 9px; padding: 3px 7px; margin-left: 4px !important; }

  /* --- Brand de los formularios de login/register --- */
  .auth-header { margin-bottom: 18px; }
  .auth-card .brand-mark { width: 42px; height: 42px; }

  /* --- Stat cards: más compactas --- */
  .stat { padding: 14px 16px; }
  .stat .label { font-size: 10px; }
  .stat .value { font-size: 20px; }

  /* --- Grids --- */
  .grid { gap: 14px; }
  .grid-2, .grid-3 { gap: 12px; }

  /* Stats del dashboard: 2 por fila, la última centrada full-width si es impar */
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-3 > :last-child:nth-child(odd) { grid-column: 1 / -1; }

  /* --- Sección "tasas + actualizado": apila el timestamp debajo --- */
  .row-between {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* --- Pill de "tasa activa" en calculadora: full-width abajo del título --- */
  .calc-rate-pill {
    width: 100%;
    justify-content: center;
    font-size: 11px;
    padding: 7px 12px;
  }

  /* --- Botones Guardar/Limpiar: ancho completo apilados --- */
  .row.gap-sm.mt-16 {
    flex-direction: column;
    align-items: stretch;
  }
  .row.gap-sm.mt-16 .btn { width: 100%; }

  /* --- Calculadora: arrow más sutil --- */
  .calc-arrow { height: 28px; font-size: 16px; }

  /* --- Field-head (label + Copiar): copy más touch-friendly --- */
  .field-head { gap: 6px; }
  .btn-copy   { padding: 5px 11px; font-size: 11px; }

  /* --- Tablas → tarjetas en mobile --- */
  .table-wrap { background: transparent; border: none; }
  .table-wrap table,
  .table-wrap thead,
  .table-wrap tbody,
  .table-wrap th,
  .table-wrap td,
  .table-wrap tr { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tr {
    margin-bottom: 12px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-2);
  }
  .table-wrap tr:hover { background: var(--bg-2); }
  .table-wrap td {
    padding: 6px 0;
    border: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 14px;
  }
  .table-wrap td::before {
    content: attr(data-label);
    color: var(--text-secondary);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    flex-shrink: 0;
  }
  .table-wrap td[data-label=""]::before,
  .table-wrap td:not([data-label])::before { content: none; }
  /* Fila con un solo texto centrado (loading/empty) */
  .table-wrap td[colspan] {
    text-align: center;
    justify-content: center;
  }
  /* Botones dentro de fila card: alineados a la derecha */
  .table-wrap td .btn { margin-left: auto; }
  /* En la fila de acciones de admin: si hay 2 botones, los apilamos cuando es muy estrecho */
  .table-wrap td .row.gap-sm { width: 100%; }

  /* --- Admin: filtros + buscador apilados a ancho completo --- */
  .row.gap-sm {
    flex-wrap: wrap;
  }
  /* Override de inline styles para los filtros del admin */
  #statusFilter,
  #searchInput {
    width: 100% !important;
  }

  /* --- Tasas en admin: el grid-2 ya colapsa a 1col por la regla de 900px --- */

  /* --- Toast: relativo al viewport, no se desborda --- */
  .toast-container {
    left: 12px;
    right: 12px;
    bottom: 12px;
  }
  .toast {
    min-width: 0;
    max-width: 100%;
    padding: 12px 14px;
    font-size: 13px;
  }

  /* --- Card de perfil: status badge en línea separada cuando es estrecho --- */
  #profileName + .muted, #profileEmail { word-break: break-all; }
}

/* =================================================================
   EXTRA-NARROW (≤ 360px) — iPhone SE, Galaxy Fold cerrado, etc.
   ================================================================= */
@media (max-width: 360px) {
  .container { padding: 0 10px; }
  .topbar    { padding: 10px 10px; }
  .card      { padding: 16px 14px; }
  .input.large { font-size: 18px; padding: 12px 13px; }
  .brand-name { font-size: 15px; }
  .topbar .btn-sm { padding: 5px 8px; font-size: 11px; }
  .stat .value { font-size: 17px; }
  /* En esta franja, apila también los pares de botones Aprobar/Rechazar */
  .table-wrap td .row.gap-sm {
    flex-direction: column;
    align-items: stretch;
  }
  .table-wrap td .row.gap-sm .btn { width: 100%; }
}

/* =================================================================
   TABLET (601–900px) — el grid-dash sigue siendo 1col por la regla
   existente; aquí solo afinamos algunos paddings.
   ================================================================= */
@media (min-width: 601px) and (max-width: 900px) {
  .container { padding: 0 20px; }
  .card { padding: 26px; }
}
