/* ============================================================
   PagosControl – Estilos personalizados
   ============================================================ */

/* ----- Variables ------------------------------------------- */
:root {
  --pc-primary:   #2563eb;
  --pc-primary-dark: #1d4ed8;
  --pc-success:   #10b981;
  --pc-danger:    #ef4444;
  --pc-warning:   #f59e0b;
  --pc-info:      #06b6d4;
  --pc-sidebar-w: 260px;
  --pc-topbar-h:  60px;
  --pc-bg:        #f1f5f9;
  --pc-card-bg:   #ffffff;
  --pc-text:      #1e293b;
  --pc-muted:     #64748b;
  --pc-border:    #e2e8f0;
  --pc-radius:    .75rem;
  --pc-shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --pc-shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
}

/* ----- Reset / Base --------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--pc-bg);
  color: var(--pc-text);
  min-height: 100vh;
  margin: 0;
}

a { color: var(--pc-primary); text-decoration: none; }
a:hover { color: var(--pc-primary-dark); }

/* ----- Scrollbar ------------------------------------------ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* =============================================================
   SIDEBAR
   ============================================================= */
#sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--pc-sidebar-w);
  height: 100vh;
  background: linear-gradient(160deg, #1e3a5f 0%, #0f2547 100%);
  display: flex;
  flex-direction: column;
  z-index: 1050;
  transition: transform .3s ease;
  overflow-y: auto;
  overflow-x: hidden;
}

#sidebar .sidebar-brand {
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}
#sidebar .sidebar-brand .brand-logo {
  width: 36px; height: 36px;
  background: var(--pc-primary);
  border-radius: .6rem;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.2rem; color: #fff;
  flex-shrink: 0;
}
#sidebar .brand-name {
  font-weight: 700; font-size: 1.1rem; color: #fff; letter-spacing: -.3px;
}
#sidebar .brand-sub {
  font-size: .7rem; color: rgba(255,255,255,.5); letter-spacing: .5px; text-transform: uppercase;
}

/* Nav items */
#sidebar .nav-section-title {
  font-size: .6875rem; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: rgba(255,255,255,.4);
  padding: 1.25rem 1.5rem .4rem;
}
#sidebar .nav-link {
  display: flex; align-items: center; gap: .75rem;
  padding: .65rem 1.5rem;
  color: rgba(255,255,255,.7);
  border-radius: 0;
  font-size: .9rem;
  transition: all .2s;
  position: relative;
}
#sidebar .nav-link i { font-size: 1.05rem; width: 20px; text-align: center; flex-shrink: 0; }
#sidebar .nav-link:hover,
#sidebar .nav-link.active {
  color: #fff;
  background: rgba(255,255,255,.1);
}
#sidebar .nav-link.active::before {
  content: '';
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%; background: var(--pc-primary);
  border-radius: 0 3px 3px 0;
}
#sidebar .nav-link .badge { margin-left: auto; }

/* Sidebar footer */
#sidebar .sidebar-footer {
  margin-top: auto;
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,.1);
  flex-shrink: 0;
}
#sidebar .sidebar-footer .user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--pc-primary);
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: .85rem; flex-shrink: 0;
}

/* =============================================================
   TOPBAR
   ============================================================= */
#topbar {
  position: fixed;
  top: 0; left: var(--pc-sidebar-w); right: 0;
  height: var(--pc-topbar-h);
  background: var(--pc-card-bg);
  border-bottom: 1px solid var(--pc-border);
  display: flex; align-items: center; padding: 0 1.5rem;
  gap: 1rem; z-index: 1040;
  box-shadow: var(--pc-shadow);
}
#topbar .topbar-title {
  font-weight: 600; font-size: 1.05rem; color: var(--pc-text);
  flex: 1;
}

/* =============================================================
   MAIN CONTENT
   ============================================================= */
#main-content {
  margin-left: var(--pc-sidebar-w);
  margin-top: var(--pc-topbar-h);
  padding: 1.75rem;
  min-height: calc(100vh - var(--pc-topbar-h));
}

/* =============================================================
   CARDS
   ============================================================= */
.pc-card {
  background: var(--pc-card-bg);
  border-radius: var(--pc-radius);
  box-shadow: var(--pc-shadow);
  border: 1px solid var(--pc-border);
}
.pc-card .pc-card-header {
  padding: 1.1rem 1.25rem .75rem;
  border-bottom: 1px solid var(--pc-border);
  display: flex; align-items: center; gap: .75rem;
}
.pc-card .pc-card-body { padding: 1.25rem; }

/* Stat cards */
.stat-card {
  border-radius: var(--pc-radius);
  padding: 1.25rem;
  display: flex; align-items: center; gap: 1rem;
  background: var(--pc-card-bg);
  box-shadow: var(--pc-shadow);
  border: 1px solid var(--pc-border);
  transition: box-shadow .2s, transform .2s;
}
.stat-card:hover { box-shadow: var(--pc-shadow-md); transform: translateY(-1px); }
.stat-icon {
  width: 52px; height: 52px; border-radius: .75rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0;
}
.stat-icon.green  { background: #d1fae5; color: #059669; }
.stat-icon.red    { background: #fee2e2; color: #dc2626; }
.stat-icon.blue   { background: #dbeafe; color: #2563eb; }
.stat-icon.orange { background: #fef3c7; color: #d97706; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-icon.teal   { background: #ccfbf1; color: #0f766e; }
.stat-icon.indigo { background: #e0e7ff; color: #4f46e5; }
.stat-icon.pink   { background: #fce7f3; color: #db2777; }
.stat-body { min-width: 0; }
.stat-label { font-size: .78rem; color: var(--pc-muted); font-weight: 500; margin-bottom: .15rem; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--pc-text); line-height: 1.2; }
.stat-sub   { font-size: .75rem; color: var(--pc-muted); }
.stat-badge { font-size: .7rem; }

/* Stat cards pequeñas (métricas secundarias) */
.stat-card-sm {
  border-radius: .625rem;
  padding: .85rem 1rem;
  display: flex; align-items: center; gap: .65rem;
  background: var(--pc-card-bg);
  box-shadow: var(--pc-shadow);
  border: 1px solid var(--pc-border);
  transition: box-shadow .2s, transform .2s;
}
.stat-card-sm:hover { box-shadow: var(--pc-shadow-md); transform: translateY(-1px); }
.stat-icon-sm {
  width: 38px; height: 38px; border-radius: .5rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem; flex-shrink: 0;
}
.stat-icon-sm.green  { background: #d1fae5; color: #059669; }
.stat-icon-sm.red    { background: #fee2e2; color: #dc2626; }
.stat-icon-sm.blue   { background: #dbeafe; color: #2563eb; }
.stat-icon-sm.orange { background: #fef3c7; color: #d97706; }
.stat-icon-sm.purple { background: #ede9fe; color: #7c3aed; }
.stat-icon-sm.teal   { background: #ccfbf1; color: #0f766e; }
.stat-icon-sm.indigo { background: #e0e7ff; color: #4f46e5; }
.stat-icon-sm.pink   { background: #fce7f3; color: #db2777; }
.stat-body-sm { min-width: 0; flex: 1; }
.stat-label-sm { font-size: .7rem; color: var(--pc-muted); font-weight: 500; margin-bottom: .1rem; line-height: 1.2; }
.stat-value-sm { font-size: 1.1rem; font-weight: 700; color: var(--pc-text); line-height: 1.2; }
.stat-sublabel-sm { font-size: .65rem; color: var(--pc-muted); margin-top: .15rem; line-height: 1.3; }

/* =============================================================
   TABLES
   ============================================================= */
.pc-table thead th {
  background: #f8fafc; font-size: .78rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .04em;
  color: var(--pc-muted); border-color: var(--pc-border);
  white-space: nowrap;
}
.pc-table tbody tr:hover { background: #f8fafc; }
.pc-table td { vertical-align: middle; border-color: var(--pc-border); font-size: .875rem; }

/* =============================================================
   FORMS
   ============================================================= */
.form-control, .form-select {
  border-color: var(--pc-border);
  border-radius: .5rem;
  font-size: .875rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--pc-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-label { font-size: .82rem; font-weight: 600; color: var(--pc-text); margin-bottom: .35rem; }

/* =============================================================
   BUTTONS
   ============================================================= */
.btn { border-radius: .5rem; font-size: .875rem; font-weight: 500; }
.btn-primary { background: var(--pc-primary); border-color: var(--pc-primary); }
.btn-primary:hover { background: var(--pc-primary-dark); border-color: var(--pc-primary-dark); }
.btn-sm { font-size: .8rem; padding: .3rem .65rem; }

/* Icon button */
.btn-icon {
  width: 32px; height: 32px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: .45rem;
}

/* =============================================================
   BADGES
   ============================================================= */
.badge { font-size: .72rem; font-weight: 600; border-radius: .4rem; letter-spacing: .02em; }

/* =============================================================
   PROGRESS
   ============================================================= */
.progress { border-radius: 99px; }
.progress-bar { border-radius: 99px; }

/* =============================================================
   MODAL
   ============================================================= */
.modal-content { border-radius: var(--pc-radius); border: none; box-shadow: var(--pc-shadow-md); }
.modal-header { border-bottom-color: var(--pc-border); }
.modal-footer { border-top-color: var(--pc-border); }

/* =============================================================
   ALERTS / TOASTS
   ============================================================= */
.toast-container { z-index: 9999; }
.pc-alert {
  border-radius: .6rem; font-size: .875rem;
  border: 1px solid transparent;
}

/* =============================================================
   LOGIN PAGE
   ============================================================= */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f2547 0%, #1e3a5f 50%, #0e4c92 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.login-card {
  width: 100%; max-width: 420px;
  background: #fff;
  border-radius: 1.25rem;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  padding: 2.5rem 2rem;
}

/* =============================================================
   RESPONSIVE – Mobile First
   ============================================================= */
@media (max-width: 991.98px) {
  #sidebar {
    transform: translateX(calc(-1 * var(--pc-sidebar-w)));
  }
  #sidebar.sidebar-open { transform: translateX(0); }
  #topbar { left: 0; }
  #main-content { margin-left: 0; padding: 1.1rem .875rem; }
  .stat-value { font-size: 1.25rem; }

  #sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1049;
  }
  #sidebar-backdrop.show { display: block; }
}

@media (min-width: 992px) {
  #sidebar-toggle { display: none; }
  #sidebar-backdrop { display: none !important; }
}

/* ── KPI cards (dashboard) responsivo ───────────────────── */
.dash-kpi-card { cursor: pointer; }

/* Tablet */
@media (max-width: 767.98px) {
  .stat-card          { padding: .85rem .75rem; gap: .6rem; }
  .stat-icon          { width: 42px; height: 42px; font-size: 1.15rem; }
  .stat-value         { font-size: 1.1rem; }
  .stat-label         { font-size: .72rem; }
  .stat-sub           { font-size: .68rem; }

  /* Gráfico más bajo en tablet */
  .dash-chart-cnt     { height: 190px !important; }

  /* Modal fullscreen en tablet */
  .modal-dialog       { margin: .5rem; max-width: calc(100% - 1rem); }
}

/* ── Mobile (xs/sm) ──────────────────────────────────────── */
@media (max-width: 575.98px) {
  /* Tabla responsive */
  .pc-table { font-size: .78rem; }
  .pc-table td, .pc-table th { padding: .5rem .5rem; }
  .hide-xs { display: none !important; }
  .hide-sm { display: none !important; }

  /* KPI card: layout vertical compacto en xs */
  .dash-kpi-card {
    flex-direction: column;
    align-items: flex-start;
    padding: .7rem .75rem;
    gap: .3rem;
    position: relative;
    overflow: hidden;
  }
  .dash-kpi-card .stat-icon {
    width: 28px; height: 28px; font-size: .85rem;
    border-radius: .35rem;
  }
  .dash-kpi-card .stat-value   { font-size: 1.05rem; font-weight: 800; line-height: 1.1; }
  .dash-kpi-card .stat-label   { font-size: .63rem; margin-bottom: 0; }
  .dash-kpi-card .stat-sub     { display: none; }

  /* Resto de stat-cards (no KPI) */
  .stat-card          { padding: .7rem .6rem; gap: .5rem; }
  .stat-icon          { width: 36px; height: 36px; font-size: 1rem; }
  .stat-value         { font-size: 1rem; }
  .stat-label         { font-size: .68rem; white-space: nowrap;
                        overflow: hidden; text-overflow: ellipsis; }
  .stat-sub           { font-size: .65rem; }

  /* Gráfico más bajo en móvil */
  .dash-chart-cnt     { height: 160px !important; }

  /* Header bienvenida */
  .dash-welcome h2    { font-size: 1.2rem; }
  .dash-welcome p     { font-size: .75rem; }
  .dash-welcome .btn  { font-size: .75rem; padding: .28rem .55rem; }

  /* Plan bola de nieve: ocultar texto largo */
  .plan-sub-text      { display: none; }

  /* Top gasto: ocultar botón en móvil */
  .dash-tg-btn        { display: none !important; }

  /* Top gasto: ajuste de texto */
  .dash-tg-card .dash-tg-monto { font-size: .95rem; }

  /* Tabs panel: letras más pequeñas */
  .dash-tab-nav .nav-link { font-size: .72rem !important;
                            padding: .25rem .35rem !important; }
  .dash-tab-nav .nav-link i { display: none; }

  /* Próximos vencimientos: ocultar cliente en xs */
  .venc-cliente       { display: none !important; }

  /* Alerta vencidas: compactar */
  .dash-alert-venc    { font-size: .78rem !important; }
  .dash-alert-venc .btn { padding: .15rem .4rem !important;
                          font-size: .72rem !important; }
}

/* Botones acción welcome alineados */
@media (max-width: 400px) {
  .dash-kpi-card .stat-value { font-size: .95rem; }
  .dash-kpi-card .stat-label { font-size: .6rem; }
}

/* =============================================================
   MISCELLANEOUS
   ============================================================= */
.text-success-dark { color: #065f46; }
.text-danger-dark  { color: #991b1b; }
.border-radius-lg  { border-radius: var(--pc-radius); }
.cursor-pointer    { cursor: pointer; }
.gap-2 { gap: .5rem; }

/* =============================================================
   PAGE INFO BANNER
   ============================================================= */
.page-banner {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  background: #fff;
  border: 1px solid var(--pc-border);
  border-left: 4px solid var(--pc-primary);
  border-radius: var(--pc-radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--pc-shadow);
  transition: padding .2s ease;
}
.page-banner.banner-green  { border-left-color: var(--pc-success); }
.page-banner.banner-orange { border-left-color: var(--pc-warning); }
.page-banner.banner-purple { border-left-color: #7c3aed; }
.page-banner.banner-teal   { border-left-color: var(--pc-info); }
.page-banner.banner-indigo { border-left-color: #4f46e5; }

/* Collapsed state */
.page-banner.banner-collapsed {
  align-items: center;
  padding: .6rem 1.25rem;
}
.page-banner.banner-collapsed .page-banner-icon {
  width: 28px; height: 28px; font-size: .95rem;
}
.page-banner.banner-collapsed .page-banner-desc,
.page-banner.banner-collapsed .page-banner-tags {
  display: none;
}
.page-banner.banner-collapsed .page-banner-title {
  margin-bottom: 0;
}

.page-banner-icon {
  flex-shrink: 0;
  width: 42px; height: 42px;
  border-radius: .65rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  background: rgba(37,99,235,.1);
  color: var(--pc-primary);
  transition: width .2s, height .2s, font-size .2s;
}
.banner-green  .page-banner-icon { background: rgba(16,185,129,.1); color: var(--pc-success); }
.banner-orange .page-banner-icon { background: rgba(245,158,11,.1);  color: var(--pc-warning); }
.banner-purple .page-banner-icon { background: rgba(124,58,237,.1);  color: #7c3aed; }
.banner-teal   .page-banner-icon { background: rgba(6,182,212,.1);   color: var(--pc-info); }
.banner-indigo .page-banner-icon { background: rgba(79,70,229,.1);   color: #4f46e5; }

.page-banner-body { flex: 1; min-width: 0; }
.page-banner-title {
  font-weight: 600;
  font-size: .9rem;
  color: var(--pc-text);
  margin-bottom: .2rem;
}
.page-banner-desc {
  font-size: .82rem;
  color: var(--pc-muted);
  line-height: 1.5;
  margin-bottom: .55rem;
}
.page-banner-tags {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}
.banner-tag {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .72rem;
  font-weight: 500;
  padding: .18rem .6rem;
  border-radius: 999px;
  background: var(--pc-bg);
  color: var(--pc-muted);
  border: 1px solid var(--pc-border);
}
.banner-toggle {
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--pc-border);
  border-radius: .5rem;
  color: var(--pc-muted);
  cursor: pointer;
  padding: .25rem .45rem;
  line-height: 1;
  transition: background .15s, color .15s;
  align-self: flex-start;
}
.banner-toggle:hover { background: var(--pc-bg); color: var(--pc-text); }
.banner-toggle .bi { transition: transform .2s ease; display: block; }
.page-banner.banner-collapsed .banner-toggle .bi { transform: rotate(180deg); }

@media (max-width: 575.98px) {
  .page-banner:not(.banner-collapsed) { flex-direction: column; gap: .75rem; }
  .page-banner:not(.banner-collapsed) .banner-toggle { align-self: flex-end; }
  .page-banner-icon { width: 36px; height: 36px; font-size: 1rem; }
}

/* =============================================================
   FOOTER
   ============================================================= */
.pc-footer {
  font-size: .75rem;
  color: var(--pc-muted);
  margin-left: var(--pc-sidebar-w);
  border-top: 1px solid var(--pc-border);
  background: var(--pc-card-bg);
  padding-left: 1.75rem;
  padding-right: 1.75rem;
}

@media (max-width: 991.98px) {
  .pc-footer { margin-left: 0; padding-left: 1rem; padding-right: 1rem; }
}

/* Empty state */
.empty-state { text-align: center; padding: 3rem 1rem; }
.empty-state i { font-size: 3rem; color: #cbd5e1; margin-bottom: 1rem; }
.empty-state p { color: var(--pc-muted); }

/* Skeleton loader */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: .4rem;
}
@keyframes skeleton-loading {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Plan de Suscripción ──────────────────────────────────── */

/* Banner de trial (azul oscuro con fondo info) */
.plan-trial-banner {
  background: linear-gradient(135deg, #0ea5e9 0%, #6366f1 100%);
  color: #fff;
  padding: .65rem 1.25rem;
  border-radius: var(--pc-radius);
  font-size: .875rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .25rem;
  box-shadow: 0 2px 8px rgba(99,102,241,.25);
}

/* Banner de plan free (ámbar suave) */
.plan-free-banner {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  padding: .65rem 1.25rem;
  border-radius: var(--pc-radius);
  font-size: .875rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .25rem;
}

/* Badge de plan en el footer del sidebar */
.plan-sidebar-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: .3rem .5rem;
  border-radius: .5rem;
  background: rgba(255,255,255,.07);
  transition: background .15s;
  text-decoration: none;
}
.plan-sidebar-badge:hover { background: rgba(255,255,255,.12); }
