/* ══════════════════════════════════════════════════
   PAYFORMS — main.css
   Estilos base: variables, layout, sidebar, topbar,
   botones, cards, tabla, badges, responsive.
   ══════════════════════════════════════════════════ */

/* ── VARIABLES GLOBALES ── */
:root {
  --sidebar-width: 240px;
  --sidebar-collapsed: 64px;
  --topbar-height: 56px;
  --bottomnav-height: 60px;

  /* Colores principales */
  --color-primary: #2C2C2A;
  --color-primary-soft: #444441;
  --color-accent: #378ADD;
  --color-accent-bg: #E6F1FB;
  --color-accent-text: #0C447C;

  /* Superficies */
  --color-bg: #F5F5F3;
  --color-surface: #FFFFFF;
  --color-border: rgba(0, 0, 0, 0.08);

  /* Texto */
  --color-text: #2C2C2A;
  --color-muted: #888780;

  /* Sidebar */
  --color-sidebar-bg: #2C2C2A;
  --color-sidebar-text: #D3D1C7;
  --color-sidebar-hover: rgba(255, 255, 255, 0.07);
  --color-sidebar-active: rgba(55, 138, 221, 0.18);
  --color-sidebar-active-text: #85B7EB;

  /* Radios */
  --radius: 8px;
  --radius-lg: 12px;
}

/* ── RESET BASE ── */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
}

/* ── CONTROL DE PANTALLAS Y VISTAS (JS) ── */
.screen { display: none; }
.screen.active { display: flex; }

.view { display: none; }
.view.active { display: block; }

/* ══════════════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--color-sidebar-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width 0.2s ease;
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-header {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 0.5px solid rgba(255, 255, 255, 0.07);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-logo .s-icon {
  width: 30px; height: 30px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 16px;
}

.sidebar-logo .s-name {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.2px;
}

.sidebar-logo .s-name span { color: #85B7EB; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

.sidebar-nav::-webkit-scrollbar { width: 0; }

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(255, 255, 255, 0.25);
  padding: 14px 20px 6px;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar.collapsed .nav-section-label { opacity: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 20px;
  color: var(--color-sidebar-text);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
  text-decoration: none;
}

.nav-item:hover { background: var(--color-sidebar-hover); color: #fff; text-decoration: none; }

.nav-item.active {
  background: var(--color-sidebar-active);
  color: var(--color-sidebar-active-text);
}

.nav-item i { font-size: 18px; flex-shrink: 0; }

.nav-item .nav-label { font-size: 13px; font-weight: 400; }

.sidebar.collapsed .nav-label { opacity: 0; width: 0; overflow: hidden; }

.nav-badge {
  margin-left: auto;
  background: var(--color-accent);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
}

.sidebar.collapsed .nav-badge { display: none; }

.sidebar-footer {
  padding: 12px 0;
  border-top: 0.5px solid rgba(255, 255, 255, 0.07);
}

/* ══════════════════════════════════════════════════
   TOPBAR
   ══════════════════════════════════════════════════ */
.topbar {
  position: fixed;
  top: 0; right: 0;
  left: var(--sidebar-width);
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 0.5px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 90;
  transition: left 0.2s ease;
}

.topbar.sidebar-collapsed-mode { left: var(--sidebar-collapsed); }

.topbar-left { display: flex; align-items: center; gap: 12px; }

.topbar-title { font-size: 15px; font-weight: 500; color: var(--color-text); }

.topbar-right { display: flex; align-items: center; gap: 10px; }

.topbar-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--color-primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 600;
  cursor: pointer;
}

.topbar-role-badge {
  font-size: 11px; font-weight: 500;
  padding: 3px 8px; border-radius: 20px;
  background: var(--color-accent-bg);
  color: var(--color-accent-text);
}

/* Logo visible solo en móvil */
.topbar-mobile-logo {
  display: none;
  font-size: 15px; font-weight: 600;
  color: var(--color-text);
}

.topbar-mobile-logo span { color: var(--color-accent); }

/* ══════════════════════════════════════════════════
   MAIN CONTENT
   ══════════════════════════════════════════════════ */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  padding: 1.5rem;
  min-height: calc(100vh - var(--topbar-height));
  transition: margin-left 0.2s ease;
  flex: 1;
}

.main-content.sidebar-collapsed-mode { margin-left: var(--sidebar-collapsed); }

/* ── PAGE HEADER ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title { font-size: 20px; font-weight: 500; }

.page-subtitle { font-size: 13px; color: var(--color-muted); margin-top: 2px; }

/* ══════════════════════════════════════════════════
   BOTONES
   ══════════════════════════════════════════════════ */
.btn-primary-solid {
  width: 100%; padding: 10px;
  background: var(--color-primary); color: #fff;
  border: none; border-radius: var(--radius);
  font-size: 14px; font-weight: 500;
  cursor: pointer; transition: background 0.15s;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none;
}

.btn-primary-solid:hover { background: var(--color-primary-soft); text-decoration: none; }

.btn-action {
  padding: 8px 16px;
  background: var(--color-primary); color: #fff;
  border: none; border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  cursor: pointer; transition: background 0.12s;
  display: flex; align-items: center; gap: 6px;
  text-decoration: none;
}

.btn-action:hover { background: var(--color-primary-soft); text-decoration: none; }

.btn-action-outline {
  padding: 8px 16px;
  background: transparent; color: var(--color-text);
  border: 0.5px solid rgba(0, 0, 0, 0.18); border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  cursor: pointer; transition: background 0.12s;
  display: flex; align-items: center; gap: 6px;
  text-decoration: none;
}

.btn-action-outline:hover { background: var(--color-bg); text-decoration: none; }

.btn-icon {
  width: 34px; height: 34px;
  border: 0.5px solid var(--color-border); border-radius: var(--radius);
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--color-text);
  transition: background 0.12s;
  text-decoration: none;
}

.btn-icon:hover { background: var(--color-bg); text-decoration: none; }

/* Botón de regreso compacto (solo flecha) */
.btn-back {
  width: 36px; height: 36px;
  flex-shrink: 0;
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--color-text);
  text-decoration: none;
  transition: background 0.12s;
}
.btn-back:hover { background: var(--color-bg); text-decoration: none; }
.btn-back i { font-size: 18px; }

/* ══════════════════════════════════════════════════
   INPUTS BASE (usados en todo el sistema)
   ══════════════════════════════════════════════════ */
.form-label {
  font-size: 13px; font-weight: 500;
  color: var(--color-text);
  margin-bottom: 5px; display: block;
}

.form-control {
  width: 100%; padding: 9px 12px;
  border: 0.5px solid rgba(0, 0, 0, 0.18); border-radius: var(--radius);
  font-size: 14px; background: #fff; color: var(--color-text);
  outline: none; transition: border-color 0.15s;
}

.form-control:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(55, 138, 221, 0.12);
}

.form-group { margin-bottom: 1rem; }

/* ══════════════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════════════ */
.card-base {
  background: var(--color-surface);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header-bar {
  padding: 14px 1.25rem;
  border-bottom: 0.5px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-between;
}

.card-header-bar h3 { font-size: 14px; font-weight: 500; }

.card-body-pad { padding: 1.25rem; }

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ══════════════════════════════════════════════════
   TABLA GENÉRICA
   ══════════════════════════════════════════════════ */
.tbl { width: 100%; border-collapse: collapse; }

.tbl th {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--color-muted);
  padding: 10px 12px; text-align: left;
  border-bottom: 0.5px solid var(--color-border);
}

.tbl td {
  padding: 11px 12px; font-size: 13px;
  border-bottom: 0.5px solid var(--color-border);
  color: var(--color-text);
}

.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--color-bg); }

/* ══════════════════════════════════════════════════
   BADGES / ETIQUETAS
   ══════════════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 500;
  padding: 3px 8px; border-radius: 20px;
}

.badge-success { background: #EAF3DE; color: #3B6D11; }
.badge-warning { background: #FAEEDA; color: #854F0B; }
.badge-info    { background: var(--color-accent-bg); color: var(--color-accent-text); }
.badge-neutral { background: #F1EFE8; color: #5F5E5A; }

/* ══════════════════════════════════════════════════
   TARJETAS DE MÉTRICAS (dashboard / reportes)
   ══════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--color-surface);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
}

.stat-label { font-size: 12px; color: var(--color-muted); margin-bottom: 6px; font-weight: 500; }
.stat-value { font-size: 24px; font-weight: 500; color: var(--color-text); line-height: 1; }
.stat-sub   { font-size: 11px; color: var(--color-muted); margin-top: 5px; }

.stat-icon-wrap {
  float: right;
  width: 34px; height: 34px;
  background: var(--color-bg); border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: var(--color-accent); font-size: 18px;
}

/* ══════════════════════════════════════════════════
   BOTTOM NAV (móvil)
   ══════════════════════════════════════════════════ */
.bottom-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--bottomnav-height);
  background: var(--color-sidebar-bg);
  z-index: 200;
  border-top: 0.5px solid rgba(255, 255, 255, 0.07);
}

.bottom-nav-inner {
  display: flex;
  height: 100%;
  width: 100%;
  justify-content: space-around;
  align-items: center;
}

/* Forzar que Bootstrap no sobreescriba los links del bottom nav */
.bottom-nav .bn-item,
.bottom-nav .bn-item:hover,
.bottom-nav .bn-item:focus {
  display: flex;
  text-decoration: none;
}

.bn-item {
  flex: 0 0 25%;
  width: 25%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  cursor: pointer; color: var(--color-sidebar-text);
  transition: color 0.12s;
  text-decoration: none;
}

.bn-item:hover { color: #fff; text-decoration: none; }
.bn-item.active { color: #85B7EB; }
.bn-item i { font-size: 24px; }

/* ══════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar            { display: none !important; }
  .topbar             { left: 0 !important; padding: 0 1rem; }
  .topbar-mobile-logo { display: block; }
  .topbar-title       { display: none; }

  /* Ocultar botón hamburger en móvil */
  .topbar .btn-icon:first-child { display: none; }

  .main-content       { margin-left: 0 !important; padding: 1rem; padding-bottom: calc(var(--bottomnav-height) + 1rem); }
  .bottom-nav         { display: flex; }
  .two-col            { grid-template-columns: 1fr; }
  .page-header        { flex-direction: column; }
  .stat-card .stat-value { font-size: 20px; }

  /* Tablas en móvil: ocultar columnas secundarias */
  .tbl .col-hide-mobile { display: none; }

  /* Card header: apilar filtros en móvil */
  .card-header-bar { flex-wrap: wrap; gap: 8px; }
  .card-header-bar > div { flex-wrap: wrap; gap: 6px; }
  .card-header-bar input,
  .card-header-bar select { width: 100% !important; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
}