/* ============================================================
   GUATEISP CRM - Estilos profesionales
   Azul corporativo, fondos claros, interfaz responsive.
   ============================================================ */
:root {
  --gc-blue: #0d5bd7;
  --gc-blue-dark: #0a3f96;
  --gc-blue-soft: #e8f0fe;
  --gc-navy: #0b1f3a;
  --gc-navy-2: #102a4c;
  --gc-bg: #f3f6fb;
  --gc-card: #ffffff;
  --gc-border: #e3e9f2;
  --gc-text: #1d2b3a;
  --gc-muted: #6a7a8c;
  --gc-green: #0f9d58;
  --gc-red: #d93025;
  --gc-amber: #f4a300;
  --sidebar-w: 264px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--gc-bg);
  color: var(--gc-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: .925rem;
}

a { text-decoration: none; }

.app-shell { display: flex; min-height: 100vh; }

/* ---------------- Sidebar ---------------- */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: linear-gradient(180deg, var(--gc-navy) 0%, var(--gc-navy-2) 100%);
  color: #cfd9e8;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1040;
  transition: transform .25s ease;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex; align-items: center; gap: .7rem;
  padding: 1.1rem 1.15rem .9rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.brand-icon {
  width: 40px; height: 40px; border-radius: 11px;
  background: linear-gradient(135deg, #2f80ed, #0d5bd7);
  display: grid; place-items: center; color: #fff; font-size: 1.25rem;
  box-shadow: 0 6px 14px rgba(13,91,215,.4);
}
.brand-text { line-height: 1; }
.brand-text strong { display: block; color: #fff; font-size: 1.05rem; letter-spacing: .5px; }
.brand-text span { color: #7fb0ff; font-size: .72rem; letter-spacing: 3px; }
.btn-close-sidebar { margin-left: auto; background: none; border: 0; color: #9fb2c9; }

.sidebar-context {
  margin: .9rem .85rem .4rem;
  padding: .7rem .75rem;
  background: rgba(255,255,255,.055);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 12px;
  display: flex; align-items: center; gap: .6rem;
  min-width: 0;
}
.ctx-badge {
  font-size: .65rem; text-transform: uppercase; letter-spacing: .8px;
  color: #8fc0ff; background: rgba(47,128,237,.16);
  padding: .18rem .45rem; border-radius: 20px; display: inline-block;
}
.ctx-name { color: #fff; font-weight: 600; font-size: .86rem; line-height: 1.2; }
.ctx-plan { color: #8ea6c2; font-size: .7rem; }
.ctx-text { min-width: 0; }
.ctx-text .ctx-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctx-logo { width: 34px; height: 34px; border-radius: 8px; object-fit: contain; background: #fff; padding: 2px; }
.ctx-avatar {
  width: 34px; height: 34px; border-radius: 9px; flex: 0 0 auto;
  background: rgba(47,128,237,.25); color: #cfe2ff;
  display: grid; place-items: center; font-weight: 700; font-size: .8rem;
}

.sidebar-nav { flex: 1; padding: .35rem .65rem 1rem; }
.nav-section {
  color: #6f86a3; font-size: .65rem; text-transform: uppercase;
  letter-spacing: 1.4px; font-weight: 700;
  padding: 1rem .55rem .35rem;
}
.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: .7rem;
  color: #c3d1e3; padding: .55rem .7rem; border-radius: 9px;
  font-size: .865rem; font-weight: 500; margin-bottom: 1px;
  transition: background .15s, color .15s;
}
.sidebar-nav .nav-link i { font-size: 1.02rem; width: 20px; text-align: center; color: #8aa4c4; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-nav .nav-link.active {
  background: linear-gradient(90deg, rgba(47,128,237,.28), rgba(47,128,237,.1));
  color: #fff;
  box-shadow: inset 3px 0 0 #4f9bff;
}
.sidebar-nav .nav-link.active i { color: #7fb6ff; }

.sidebar-foot {
  padding: .8rem .85rem 1rem;
  border-top: 1px solid rgba(255,255,255,.07);
}
.user-mini { display: flex; align-items: center; gap: .6rem; color: #dbe6f5; padding: .2rem .2rem .1rem; }
.user-mini:hover { color: #fff; }
.user-mini .avatar { width: 36px; height: 36px; }
.user-mini-text { min-width: 0; }
.user-mini .name { font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-mini .role { font-size: .68rem; color: #8ea6c2; }

.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, #4f9bff, #0d5bd7);
  color: #fff; display: inline-grid; place-items: center;
  font-weight: 700; font-size: .78rem; flex: 0 0 auto;
}
.avatar-sm { width: 30px; height: 30px; font-size: .68rem; }

/* ---------------- Main ---------------- */
.main-area {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--gc-border);
  padding: .85rem 1.5rem;
  display: flex; align-items: center; gap: .75rem;
  position: sticky; top: 0; z-index: 1020;
}
.page-heading { flex: 1; min-width: 0; }
.page-heading h1 { font-size: 1.22rem; font-weight: 700; margin: 0; letter-spacing: -.2px; }
.page-heading p { margin: .12rem 0 0; color: var(--gc-muted); font-size: .78rem; }
.topbar-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }
.user-btn { display: flex; align-items: center; gap: .5rem; border: 1px solid var(--gc-border); border-radius: 10px; padding: .3rem .55rem; }

.content { padding: 1.4rem 1.5rem 1.8rem; flex: 1; }
.assist-banner {
  background: #fff4d6; color: #6b4a00; border-bottom: 1px solid #ffe3a3;
  padding: .6rem 1.5rem; display: flex; align-items: center; gap: .6rem; font-size: .83rem;
}
.app-footer {
  border-top: 1px solid var(--gc-border);
  padding: .8rem 1.5rem;
  display: flex; justify-content: space-between; gap: 1rem;
  color: var(--gc-muted); font-size: .72rem; background: #fff;
}

/* ---------------- Tarjetas y métricas ---------------- */
.card {
  border: 1px solid var(--gc-border);
  border-radius: 14px;
  background: var(--gc-card);
  box-shadow: 0 1px 2px rgba(16,42,76,.03);
}
.card-header {
  background: transparent; border-bottom: 1px solid var(--gc-border);
  padding: .9rem 1.1rem; font-weight: 600;
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
}
.card-header .card-title { margin: 0; font-size: .95rem; }
.card-body { padding: 1.1rem; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .9rem; margin-bottom: 1.2rem; }
.stat-card {
  background: #fff; border: 1px solid var(--gc-border); border-radius: 14px;
  padding: .95rem 1rem; display: flex; align-items: flex-start; gap: .8rem;
  position: relative; overflow: hidden;
}
.stat-card::after {
  content: ""; position: absolute; right: -20px; top: -20px;
  width: 80px; height: 80px; border-radius: 50%; background: rgba(13,91,215,.05);
}
.stat-icon {
  width: 42px; height: 42px; border-radius: 11px; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 1.15rem;
  background: var(--gc-blue-soft); color: var(--gc-blue);
}
.stat-icon.green { background: #e6f6ee; color: var(--gc-green); }
.stat-icon.red { background: #fdecea; color: var(--gc-red); }
.stat-icon.amber { background: #fff4e0; color: #b26a00; }
.stat-icon.purple { background: #f0e9fe; color: #6f42c1; }
.stat-label { color: var(--gc-muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .6px; font-weight: 700; }
.stat-value { font-size: 1.35rem; font-weight: 700; line-height: 1.15; margin-top: .15rem; }
.stat-sub { color: var(--gc-muted); font-size: .72rem; margin-top: .2rem; }

/* ---------------- Tablas ---------------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; font-size: .85rem; }
.table > thead th {
  background: #f8fafd; color: #51647a; font-size: .7rem;
  text-transform: uppercase; letter-spacing: .6px; font-weight: 700;
  border-bottom: 1px solid var(--gc-border); padding: .65rem .7rem; white-space: nowrap;
}
.table > tbody td { padding: .68rem .7rem; vertical-align: middle; border-color: #eef2f8; }
.table-hover > tbody > tr:hover > * { background: #f7faff; }
.table-responsive { border-radius: 0 0 14px 14px; }

.badge { font-weight: 600; font-size: .7rem; padding: .35em .6em; border-radius: 6px; }
.badge-soft-success { background: #e6f6ee; color: #0b7a44; }
.badge-soft-warning { background: #fff4d6; color: #8a5a00; }
.badge-soft-danger { background: #fdecea; color: #a61b12; }
.badge-soft-secondary { background: #eef1f5; color: #4d5d70; }
.badge-soft-info { background: #e6f2ff; color: #0a5bb5; }

/* ---------------- Formularios ---------------- */
.form-label { font-weight: 600; font-size: .8rem; color: #34465a; margin-bottom: .3rem; }
.form-control, .form-select {
  border-color: #d7e0ec; border-radius: 9px; padding: .5rem .7rem; font-size: .875rem;
}
.form-control:focus, .form-select:focus {
  border-color: #7fb0ff; box-shadow: 0 0 0 .22rem rgba(13,91,215,.12);
}
.form-text { font-size: .74rem; }
.input-group-text { background: #f5f8fc; border-color: #d7e0ec; color: #5b6c80; }
.required::after { content: " *"; color: var(--gc-red); }
fieldset { border: 1px solid var(--gc-border); border-radius: 12px; padding: 1rem; margin-bottom: 1rem; }
legend { float: none; width: auto; font-size: .85rem; font-weight: 700; padding: 0 .4rem; color: var(--gc-blue-dark); }

.btn { border-radius: 9px; font-weight: 600; font-size: .855rem; padding: .48rem .85rem; }
.btn-primary { background: var(--gc-blue); border-color: var(--gc-blue); }
.btn-primary:hover { background: var(--gc-blue-dark); border-color: var(--gc-blue-dark); }
.btn-sm { padding: .32rem .55rem; font-size: .78rem; }
.btn-icon { width: 32px; height: 32px; padding: 0; display: inline-grid; place-items: center; }

/* ---------------- Login / portal ---------------- */
.auth-wrap {
  min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr;
  background: #fff;
}
.auth-side {
  background: linear-gradient(150deg, #0b1f3a 0%, #0d3f86 55%, #0d5bd7 100%);
  color: #fff; padding: 4rem 4rem; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.auth-side::after {
  content: ""; position: absolute; width: 520px; height: 520px; border-radius: 50%;
  border: 80px solid rgba(255,255,255,.05); right: -220px; bottom: -220px;
}
.auth-side h1 { font-size: 2.5rem; font-weight: 800; line-height: 1.12; letter-spacing: -.8px; }
.auth-side p { color: #b9d2f2; max-width: 460px; }
.auth-features { display: grid; gap: .8rem; margin-top: .5rem; position: relative; z-index: 2; }
.auth-feature { display: flex; gap: .75rem; align-items: flex-start; color: #dbe9fb; font-size: .88rem; }
.auth-feature i { color: #7fb6ff; font-size: 1.1rem; }
.auth-main { display: grid; place-items: center; padding: 2rem; background: #f7f9fd; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .card { border-radius: 18px; box-shadow: 0 18px 50px rgba(16,42,76,.1); }
.auth-brand { display: flex; align-items: center; gap: .7rem; justify-content: center; margin-bottom: 1.6rem; }

/* ---------------- Cobrador móvil ---------------- */
body.rol-cobrador { background: #eef3fa; }
body.rol-cobrador .content { padding: 1rem; max-width: 720px; margin: 0 auto; width: 100%; }
body.rol-cobrador .page-heading h1 { font-size: 1.05rem; }
.cobro-hero {
  background: linear-gradient(135deg, #0d5bd7, #0a3f96); color: #fff;
  border-radius: 18px; padding: 1.2rem; margin-bottom: 1rem;
}
.cobro-hero .total { font-size: 2rem; font-weight: 800; line-height: 1; }
.cobro-hero .label { color: #cfe2ff; font-size: .75rem; text-transform: uppercase; letter-spacing: 1px; }
.cobro-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .7rem; }
.cobro-grid .btn { padding: .9rem .6rem; font-size: .9rem; border-radius: 13px; }
.cliente-card {
  background: #fff; border: 1px solid var(--gc-border); border-radius: 14px;
  padding: .9rem; margin-bottom: .7rem;
}
.cliente-card .nombre { font-weight: 700; }
.cliente-card .saldo { font-size: 1.05rem; font-weight: 800; color: var(--gc-red); }
.btn-cobrar { font-size: 1rem; padding: .9rem; border-radius: 12px; font-weight: 700; }
.total-pagar {
  background: #fff; border: 2px solid var(--gc-blue); border-radius: 14px;
  padding: 1rem; text-align: center;
}
.total-pagar .monto { font-size: 1.2rem; font-weight: 800; color: var(--gc-blue-dark); }

/* ---------------- Varios ---------------- */
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.empty-state { text-align: center; padding: 2.6rem 1rem; color: var(--gc-muted); }
.empty-state i { font-size: 2.4rem; color: #b9c8db; display: block; margin-bottom: .6rem; }
.filters-bar { background: #fff; border: 1px solid var(--gc-border); border-radius: 12px; padding: .8rem; margin-bottom: 1rem; }
.detail-label { color: var(--gc-muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .5px; font-weight: 700; }
.detail-value { font-weight: 600; margin-bottom: .6rem; word-break: break-word; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.text-money { color: var(--gc-blue-dark); font-weight: 700; }
.progress-thin { height: 6px; border-radius: 6px; }
.timeline { position: relative; padding-left: 1.4rem; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--gc-border); }
.timeline-item { position: relative; padding-bottom: .9rem; font-size: .82rem; }
.timeline-item::before { content: ""; position: absolute; left: -1.4rem; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2px solid var(--gc-blue); }
.quick-link { display: flex; align-items: center; gap: .7rem; padding: .7rem .8rem; border-radius: 10px; color: var(--gc-text); border: 1px solid var(--gc-border); background: #fff; }
.quick-link:hover { border-color: #b9d2f7; background: #f8fbff; color: var(--gc-blue-dark); }
.quick-link i { color: var(--gc-blue); font-size: 1.1rem; }
.table-actions { display: flex; gap: .25rem; justify-content: flex-end; }
.section-title { font-size: .82rem; text-transform: uppercase; letter-spacing: .8px; color: var(--gc-muted); font-weight: 700; margin: 1.2rem 0 .6rem; }
.nav-tabs .nav-link { border: 0; color: var(--gc-muted); font-weight: 600; font-size: .85rem; }
.nav-tabs .nav-link.active { color: var(--gc-blue); border-bottom: 2px solid var(--gc-blue); background: transparent; }
.recibo-preview { background: #fff; border: 1px dashed #b9c8db; border-radius: 10px; padding: 1rem; font-family: "Courier New", monospace; font-size: .78rem; white-space: pre-wrap; }
.kv { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem 0; border-bottom: 1px dashed #e6edf7; font-size: .82rem; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--gc-muted); }
.kv .v { font-weight: 600; text-align: right; }

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-area { margin-left: 0; }
  .sidebar-backdrop.di { display: block; }
  .sidebar-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(8,20,38,.45); z-index: 1030;
  }
  .sidebar-backdrop.show { display: block; }
  .content { padding: 1rem; }
  .topbar { padding: .7rem .9rem; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .app-footer { flex-direction: column; gap: .2rem; }
}
@media (max-width: 575.98px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-card { padding: .75rem; }
  .stat-value { font-size: 1.1rem; }
  .page-heading p { display: none; }
  .topbar-actions .btn span.d-none { display: none !important; }
}

/* Impresión de oficina: oculta la interfaz al imprimir */
@media print {
  .sidebar, .topbar, .app-footer, .assist-banner, .no-print, .page-actions { display: none !important; }
  .main-area { margin: 0; }
  .content { padding: 0; }
  body { background: #fff; font-size: 11pt; }
  .card { border: 0; box-shadow: none; }
  a[href]::after { content: none; }
}
