/* CA-IHPBA - Estilos Globales */

/* Tabla con scroll interno */
.table-scroll {
  max-height: calc(100vh - 290px);
  overflow-y: auto;
}
.table-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8f9fa;
}

/* Columnas ordenables */
th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
th.sortable:hover { background: #e2e6ea; }
th.sortable::after { content: ' ⇅'; opacity: 0.4; font-size: 11px; }
th.sortable.asc::after { content: ' ↑'; opacity: 1; }
th.sortable.desc::after { content: ' ↓'; opacity: 1; }

:root {
  --primary: #3498db;
  --primary-dark: #2980b9;
  --secondary: #2c3e50;
  --secondary-light: #34495e;
  --success: #27ae60;
  --warning: #f39c12;
  --danger: #e74c3c;
  --bg: #f5f7fa;
  --sidebar-w: 260px;
  --sidebar-w-collapsed: 70px;
  --header-h: 64px;
  --shadow: 0 2px 8px rgba(0,0,0,.10);
  --shadow-lg: 0 4px 16px rgba(0,0,0,.15);
  --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg);
  color: var(--secondary);
  font-size: 14px;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ── LAYOUT ───────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ──────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #1e2a3a 0%, #2c3e50 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 1050;
  transition: width .3s ease;
  box-shadow: 2px 0 10px rgba(0,0,0,.2);
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-w-collapsed); }
.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .sidebar-user-name { display: none; }

.sidebar-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: .75rem;
  min-height: var(--header-h);
}

.sidebar-brand-icon {
  font-size: 1.6rem;
  color: var(--primary);
  min-width: 28px;
}

.sidebar-brand-text {
  font-size: 1.1rem;
  font-weight: 700;
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  padding: .75rem 0;
  overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }

.sidebar-nav .nav-item {
  display: flex;
  align-items: center;
  gap: .875rem;
  padding: .75rem 1.5rem;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  transition: all .2s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-size: .9rem;
  white-space: nowrap;
  border-left: 3px solid transparent;
}

.sidebar-nav .nav-item i { font-size: 1.15rem; min-width: 22px; }

.sidebar-nav .nav-item:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}

.sidebar-nav .nav-item.active {
  background: rgba(52,152,219,.18);
  color: #fff;
  border-left-color: var(--primary);
}

.nav-label { white-space: nowrap; }

.sidebar-footer {
  padding: .75rem 0;
  border-top: 1px solid rgba(255,255,255,.08);
}

.sidebar-footer .nav-item {
  display: flex;
  align-items: center;
  gap: .875rem;
  padding: .75rem 1.5rem;
  color: #e74c3c;
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-size: .9rem;
  white-space: nowrap;
  border-left: 3px solid transparent;
  transition: all .2s;
}

.sidebar-footer .nav-item i { font-size: 1.15rem; min-width: 22px; }

.sidebar-footer .nav-item:hover {
  background: rgba(231,76,60,.1);
  color: #e74c3c;
}

/* ── MAIN WRAPPER ─────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  /* min-width 0: sin esto el item flex no puede achicarse por debajo del ancho
     mínimo de su contenido (tablas anchas) y toda la página desborda a lo ancho */
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left .3s ease;
}

.main-wrapper.collapsed { margin-left: var(--sidebar-w-collapsed); }

/* ── TOPBAR ───────────────────────────────────── */
.topbar {
  background: #fff;
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  box-shadow: 0 2px 4px rgba(0,0,0,.06);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-toggle {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--secondary);
  cursor: pointer;
  padding: .4rem;
  border-radius: 6px;
  transition: background .2s;
}

.topbar-toggle:hover { background: #f0f2f5; }

.topbar-title { flex: 1; }
.topbar-title h1 { font-size: 1.35rem; font-weight: 600; color: var(--secondary); margin: 0; }
.topbar-title p { font-size: .8rem; color: #7f8c8d; margin: 0; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: #f8f9fa;
  border-radius: 20px;
  padding: .4rem 1rem;
  color: var(--secondary);
  font-size: .875rem;
  font-weight: 500;
}

.topbar-user i { font-size: 1.3rem; }

/* ── PAGE CONTENT ─────────────────────────────── */
.page-content {
  padding: 1rem 1.5rem;
  flex: 1;
}

.page-header {
  margin-bottom: 1rem;
}

.page-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--secondary);
  margin: 0 0 .2rem;
}

.page-header p {
  color: #7f8c8d;
  font-size: .875rem;
  margin: 0;
}

/* ── CARDS ────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: none;
  margin-bottom: .75rem;
}

.card:hover { box-shadow: var(--shadow-lg); }

.card-header {
  background: #fff;
  border-bottom: 1px solid #e9ecef;
  padding: .625rem 1rem;
  font-weight: 600;
  color: var(--secondary);
  border-radius: var(--radius) var(--radius) 0 0 !important;
}

.card-header-blue {
  background: linear-gradient(90deg, #3498db, #2980b9);
  color: #fff;
  border-bottom: none;
}

.card-header-green {
  background: linear-gradient(90deg, #27ae60, #219a52);
  color: #fff;
  border-bottom: none;
}

.card-body { padding: .875rem 1rem; }

/* ── MINI STAT (resumen cuotas socio) ─────────── */
.mini-stat {
  background: #fff;
  border-radius: var(--radius);
  padding: .6rem .875rem;
  box-shadow: var(--shadow);
  border-left: 3px solid var(--primary);
  text-align: center;
}
.mini-stat.green  { border-left-color: var(--success); }
.mini-stat.orange { border-left-color: var(--warning); }
.mini-stat.red    { border-left-color: var(--danger); }
.mini-stat.dark   { border-left-color: var(--secondary); }
.mini-stat-label {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: #7f8c8d;
  font-weight: 600;
  white-space: nowrap;
}
.mini-stat-value {
  font-size: clamp(.8rem, 1.8vw, 1.2rem);
  font-weight: 700;
  color: var(--secondary);
  line-height: 1.3;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* ── STAT CARDS ───────────────────────────────── */
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-card.green  { border-left-color: var(--success); }
.stat-card.orange { border-left-color: var(--warning); }
.stat-card.red    { border-left-color: var(--danger); }
.stat-card.blue   { border-left-color: var(--primary); }
.stat-card.dark   { border-left-color: var(--secondary); }

.stat-icon {
  font-size: 2rem;
  opacity: .7;
  flex-shrink: 0;
}

.stat-icon.green  { color: var(--success); }
.stat-icon.orange { color: var(--warning); }
.stat-icon.red    { color: var(--danger); }
.stat-icon.blue   { color: var(--primary); }
.stat-icon.dark   { color: var(--secondary); }

.stat-value {
  font-size: clamp(1rem, 2.5vw, 1.75rem);
  font-weight: 700;
  color: var(--secondary);
  line-height: 1.2;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.stat-label {
  font-size: .75rem;
  color: #7f8c8d;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-top: .2rem;
}

/* ── TABLES ───────────────────────────────────── */
.table { background: #fff; }

.table thead th {
  background: #f8f9fa;
  border-bottom: 2px solid #e9ecef;
  color: var(--secondary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: .72rem;
  letter-spacing: .5px;
  padding: .5rem .875rem;
  white-space: nowrap;
}

.table tbody td { padding: .5rem .875rem; vertical-align: middle; }
.table tbody tr:hover { background: #f8f9fa; }

/* ── BUTTONS ──────────────────────────────────── */
.btn { border-radius: 6px; font-weight: 500; transition: all .2s; }

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(52,152,219,.3);
}

/* ── FORMS ────────────────────────────────────── */
.form-control, .form-select {
  border-radius: 6px;
  border: 1px solid #dde1e7;
  padding: .55rem .875rem;
  transition: all .2s;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 .2rem rgba(52,152,219,.2);
}

.form-label { font-weight: 500; color: var(--secondary); margin-bottom: .4rem; font-size: .875rem; }

.form-section-title {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #7f8c8d;
  border-bottom: 1px solid #e9ecef;
  padding-bottom: .5rem;
  margin-bottom: 1rem;
  margin-top: .5rem;
}

/* ── BADGES ───────────────────────────────────── */
.badge {
  padding: .3rem .65rem;
  font-weight: 500;
  border-radius: 10px;
  font-size: .75rem;
}

/* ── FIELD DISPLAY (detalle) ──────────────────── */
.field-group { margin-bottom: .5rem; }
.field-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .5px; color: #95a5a6; font-weight: 600; }
.field-value { font-size: .9rem; color: var(--secondary); font-weight: 500; }

/* ── SCROLLBAR ────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #bdc3c7; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #95a5a6; }

/* ── RESPONSIVE ───────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: var(--sidebar-w-collapsed); }
  .sidebar .nav-label, .sidebar .sidebar-brand-text { display: none; }
  .main-wrapper { margin-left: var(--sidebar-w-collapsed); }
}
