/* ═══════════════════════════════════════════════════════════
   Cartera de Clientes — Custom Styles
   Stack: Bootstrap 5.3 Dark + Custom
   ═══════════════════════════════════════════════════════════ */

:root {
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 0px;
  --topbar-height: 56px;
  --bg-main: #0f1117;
  --bg-card: #1a1d2e;
  --bg-sidebar: #13152a;
  --bg-hover: #1e2238;
  --border-color: rgba(255,255,255,0.08);
  --text-muted: #8b92a5;
  --accent: #0d6efd;
}

/* ── Reset / Base ─────────────────────────────────────────── */
* { box-sizing: border-box; }

body {
  background-color: var(--bg-main);
  color: #e2e5f0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 0.9rem;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.25s ease;
  z-index: 100;
  flex-shrink: 0;
}

.sidebar-brand {
  color: #fff !important;
}

.sidebar .nav-link {
  color: var(--text-muted);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s;
  white-space: nowrap;
}

.sidebar .nav-link:hover {
  background: var(--bg-hover);
  color: #fff;
}

.sidebar .nav-link.active {
  background: rgba(13, 110, 253, 0.15);
  color: var(--accent);
  border-left: 3px solid var(--accent);
}

.sidebar-section {
  padding: 0.5rem 0.75rem 0.25rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
  list-style: none;
  margin-top: 0.5rem;
}

/* Avatar círculo en sidebar */
.avatar-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0d6efd, #6f42c1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
  color: #fff;
  flex-shrink: 0;
}

.avatar-circle-sm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0d6efd, #6f42c1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.7rem;
  color: #fff;
  flex-shrink: 0;
}

.badge-role { font-size: 0.65rem; }

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
  min-height: 100vh;
  background: var(--bg-main);
  min-width: 0;
}

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  height: var(--topbar-height);
  position: sticky;
  top: 0;
  z-index: 90;
}

/* ── Page Header ──────────────────────────────────────────── */
.page-header {
  padding: 1.5rem 0 1rem;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0;
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color) !important;
  border-radius: 12px;
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 1.25rem;
}

.shadow-sm {
  box-shadow: 0 2px 12px rgba(0,0,0,0.3) !important;
}

/* ── KPI Cards ────────────────────────────────────────────── */
.kpi-card {
  transition: transform 0.15s, box-shadow 0.15s;
  background: var(--bg-card) !important;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4) !important;
}

.kpi-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  color: #fff;
}

.kpi-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.kpi-sub {
  font-size: 0.72rem;
  margin-top: 2px;
}

/* ── Tables ───────────────────────────────────────────────── */
.table {
  color: #e2e5f0;
  --bs-table-bg: transparent;
  --bs-table-hover-bg: var(--bg-hover);
  --bs-table-striped-bg: transparent;
}

.table-header th {
  background: rgba(255,255,255,0.03);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-color) !important;
  padding: 0.75rem 1rem;
}

.table td {
  padding: 0.75rem 1rem;
  vertical-align: middle;
  border-color: var(--border-color);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

/* ── Forms ────────────────────────────────────────────────── */
.form-control, .form-select {
  background-color: rgba(255,255,255,0.05);
  border: 1px solid var(--border-color);
  color: #e2e5f0;
  border-radius: 8px;
}

.form-control:focus, .form-select:focus {
  background-color: rgba(255,255,255,0.08);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 0.2rem rgba(13,110,253,0.2);
}

.form-control::placeholder {
  color: var(--text-muted);
}

.form-label { color: #c5cae9; }

.input-group-text {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.875rem;
}

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

.btn-outline-secondary {
  border-color: var(--border-color);
  color: var(--text-muted);
}

.btn-outline-secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-color);
  color: #fff;
}

/* ── Timeline ─────────────────────────────────────────────── */
.timeline {
  position: relative;
  padding-left: 2.5rem;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 0.85rem;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border-color);
}

.timeline-item {
  position: relative;
  margin-bottom: 1rem;
}

.timeline-icon {
  position: absolute;
  left: -2.5rem;
  top: 0.5rem;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: #fff;
}

.timeline-content {}

/* ── Login ────────────────────────────────────────────────── */
.login-wrapper {
  background: var(--bg-main);
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border-color) !important;
  border-radius: 16px;
}

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
  border-radius: 10px;
  border: none;
  font-size: 0.875rem;
}

.alert-success { background: rgba(25,135,84,0.15); color: #75c89e; border-left: 3px solid #198754; }
.alert-danger  { background: rgba(220,53,69,0.15); color: #f07a84; border-left: 3px solid #dc3545; }
.alert-warning { background: rgba(255,193,7,0.15); color: #ffc850; border-left: 3px solid #ffc107; }
.alert-info    { background: rgba(13,202,240,0.15); color: #6edff6; border-left: 3px solid #0dcaf0; }

/* ── Badges ───────────────────────────────────────────────── */
.badge { font-weight: 500; font-size: 0.72rem; }

/* ── List Groups ──────────────────────────────────────────── */
.list-group-item {
  background: transparent;
  border-color: var(--border-color);
  color: #e2e5f0;
}

.list-group-item:hover { background: var(--bg-hover); }

/* ── Nav Tabs ─────────────────────────────────────────────── */
.nav-tabs {
  border-bottom: 1px solid var(--border-color);
}

.nav-tabs .nav-link {
  color: var(--text-muted);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 0.5rem 1rem;
}

.nav-tabs .nav-link:hover { color: #fff; border-bottom-color: rgba(255,255,255,0.2); }

.nav-tabs .nav-link.active {
  background: transparent;
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Select2 dark ─────────────────────────────────────────── */
.select2-container--bootstrap-5 .select2-selection {
  background-color: rgba(255,255,255,0.05) !important;
  border-color: var(--border-color) !important;
  color: #e2e5f0 !important;
}

.select2-dropdown {
  background: var(--bg-card) !important;
  border-color: var(--border-color) !important;
}

.select2-results__option {
  color: #e2e5f0 !important;
}

.select2-results__option--highlighted {
  background-color: var(--accent) !important;
}

/* ── Flatpickr dark ───────────────────────────────────────── */
.flatpickr-calendar {
  background: var(--bg-card);
  border-color: var(--border-color);
  color: #e2e5f0;
}

/* ── Dropdown ─────────────────────────────────────────────── */
.dropdown-menu-dark {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
}

/* ── DataTables dark ──────────────────────────────────────── */
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
}

.dataTables_length select,
.dataTables_filter input {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-color);
  color: #e2e5f0;
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.3); }

/* ── Responsive: mobile sidebar ──────────────────────────── */
@media (max-width: 767px) {
  .sidebar {
    position: fixed;
    left: -var(--sidebar-width);
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 1050;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    width: 100%;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1040;
  }

  .sidebar-overlay.active { display: block; }

  .page-title { font-size: 1.1rem; }
}

/* ── Animations ───────────────────────────────────────────── */
.card, .kpi-card {
  animation: fadeInUp 0.25s ease both;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
