/* ===================================================
   PORTAL CENTRO MULCHÉN — CRM v1.0
   Design System: Dark Mode Premium
   =================================================== */

:root {
  /* Color Palette */
  --bg-primary:    #0d0f1a;
  --bg-secondary:  #141623;
  --bg-card:       #1a1d2e;
  --bg-card-hover: #1f2338;
  --bg-sidebar:    #10121f;
  --sidebar-width: 260px;

  /* Accent Colors */
  --accent:        #6c63ff;
  --accent-light:  #8b85ff;
  --accent-dark:   #4f48c4;
  --accent-glow:   rgba(108, 99, 255, 0.15);

  --teal:          #00d4aa;
  --teal-dark:     #00a886;
  --gold:          #f5a623;
  --rose:          #ff5f7e;
  --blue:          #3b82f6;
  --emerald:       #10b981;

  /* Text */
  --text-primary:  #e8eaf0;
  --text-secondary:#9ba3c7;
  --text-muted:    #5c6484;

  /* Borders */
  --border:        rgba(255,255,255,0.07);
  --border-light:  rgba(255,255,255,0.12);

  /* Status Colors */
  --status-success: #10b981;
  --status-warning: #f59e0b;
  --status-danger:  #ef4444;
  --status-info:    #3b82f6;

  /* Spacing */
  --radius:        12px;
  --radius-sm:     8px;
  --radius-lg:     16px;

  /* Shadows */
  --shadow-sm:  0 2px 8px rgba(0,0,0,0.3);
  --shadow-md:  0 4px 20px rgba(0,0,0,0.4);
  --shadow-lg:  0 8px 40px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 30px rgba(108, 99, 255, 0.2);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
}

/* ─── SIDEBAR ─────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  overflow-y: auto;
  z-index: 1000;
  transition: transform 0.3s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
}

.brand-icon {
  font-size: 28px;
  width: 44px; height: 44px;
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  display: block;
  line-height: 1.2;
}

.brand-sub {
  font-size: 11px;
  color: var(--accent-light);
  display: block;
  font-weight: 500;
  letter-spacing: 0.5px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 16px 8px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.2s ease;
  margin-bottom: 2px;
}

.nav-link i { font-size: 16px; width: 20px; text-align: center; }

.nav-link:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  transform: translateX(3px);
}

.nav-link.active {
  background: var(--accent-glow);
  color: var(--accent-light);
  border: 1px solid rgba(108,99,255,0.25);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--teal));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: white;
  flex-shrink: 0;
}

.user-details { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--text-muted); display: block; }

.btn-logout {
  color: var(--text-muted);
  font-size: 18px;
  text-decoration: none;
  padding: 6px;
  border-radius: 6px;
  transition: all 0.2s;
  flex-shrink: 0;
}
.btn-logout:hover { color: var(--rose); background: rgba(255,95,126,0.1); }

/* ─── MAIN WRAPPER ────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ─── TOPBAR ──────────────────────────────────────── */
.topbar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0; z-index: 100;
}

.sidebar-toggle {
  background: none; border: none;
  color: var(--text-secondary);
  font-size: 22px;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: none;
  transition: color 0.2s;
}
.sidebar-toggle:hover { color: var(--text-primary); }

.topbar-breadcrumb {
  flex: 1;
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.breadcrumb-sep { color: var(--text-muted); }
.breadcrumb-item:last-child { color: var(--text-primary); font-weight: 500; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

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

/* ─── PAGE HEADER ─────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-title { font-size: 26px; font-weight: 800; line-height: 1.2; }
.page-title .emoji { margin-right: 10px; }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.header-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ─── CARDS ───────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: all 0.3s ease;
}

.card:hover { border-color: var(--border-light); box-shadow: var(--shadow-md); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── STAT CARDS ──────────────────────────────────── */
.stats-grid {
  display: flex;
  gap: 16px;
  margin-bottom: 28px;
  width: 100%;
}

.stats-grid > * {
  flex: 1;
  min-width: 0;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 3px;
  background: var(--stat-color, var(--accent));
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-light);
}

.stat-icon {
  width: 44px; height: 44px;
  background: var(--icon-bg, var(--accent-glow));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ─── GRID LAYOUTS ────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

/* ─── TABLES ──────────────────────────────────────── */
.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  background: rgba(255,255,255,0.03);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13.5px;
}

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

tbody tr {
  transition: background 0.15s ease;
}
tbody tr:hover td {
  background: rgba(255,255,255,0.03);
  color: var(--text-primary);
}

.td-strong { font-weight: 600; color: var(--text-primary) !important; }

/* ─── BADGES / STATUS ─────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success { background: rgba(16,185,129,0.15); color: var(--emerald); border: 1px solid rgba(16,185,129,0.3); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--gold); border: 1px solid rgba(245,158,11,0.3); }
.badge-danger  { background: rgba(239,68,68,0.15);  color: var(--rose); border: 1px solid rgba(239,68,68,0.3); }
.badge-info    { background: rgba(59,130,246,0.15);  color: var(--blue); border: 1px solid rgba(59,130,246,0.3); }
.badge-accent  { background: var(--accent-glow); color: var(--accent-light); border: 1px solid rgba(108,99,255,0.3); }
.badge-muted   { background: rgba(255,255,255,0.06); color: var(--text-muted); border: 1px solid var(--border); }
.badge-teal    { background: rgba(0,212,170,0.12); color: var(--teal); border: 1px solid rgba(0,212,170,0.3); }

/* ─── BUTTONS ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 4px 14px rgba(108,99,255,0.3);
}
.btn-primary:hover {
  background: var(--accent-light);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(108,99,255,0.4);
  color: white;
}

.btn-success {
  background: var(--emerald);
  color: white;
}
.btn-success:hover { background: #059669; color: white; transform: translateY(-1px); }

.btn-danger {
  background: rgba(239,68,68,0.15);
  color: var(--rose);
  border: 1px solid rgba(239,68,68,0.3);
}
.btn-danger:hover { background: var(--rose); color: white; }

.btn-ghost {
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: rgba(255,255,255,0.1); color: var(--text-primary); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-xs { padding: 4px 8px; font-size: 11.5px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { padding: 7px; width: 34px; height: 34px; justify-content: center; }

/* ─── FORMS ───────────────────────────────────────── */
.form-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 20px;
}

.form-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-light);
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full-width { grid-column: 1 / -1; }

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-control, .form-select {
  background: var(--bg-primary) !important;
  border: 1px solid var(--border-light) !important;
  border-radius: var(--radius-sm) !important;
  color: var(--text-primary) !important;
  padding: 10px 14px !important;
  font-size: 14px !important;
  font-family: inherit !important;
  width: 100%;
  transition: all 0.2s ease;
}

.form-control:focus, .form-select:focus {
  outline: none !important;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(108,99,255,0.15) !important;
}

.form-control::placeholder { color: var(--text-muted) !important; }
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check-input { width: 16px; height: 16px; accent-color: var(--accent); }
.form-check-label { font-size: 13.5px; color: var(--text-secondary); font-weight: 400; text-transform: none; letter-spacing: 0; }

.helptext { font-size: 11px; color: var(--text-muted); }
.errorlist { list-style: none; color: var(--rose); font-size: 12px; margin-top: 4px; }

/* ─── ALERTS ──────────────────────────────────────── */
.alerts-container { padding: 0 28px; padding-top: 16px; }

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid;
  animation: slideIn 0.3s ease;
}

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

.alert-success { background: rgba(16,185,129,0.1); border-color: rgba(16,185,129,0.3); color: #6ee7b7; }
.alert-error, .alert-danger { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.3); color: #fca5a5; }
.alert-warning { background: rgba(245,158,11,0.1); border-color: rgba(245,158,11,0.3); color: #fcd34d; }
.alert-info    { background: rgba(59,130,246,0.1); border-color: rgba(59,130,246,0.3); color: #93c5fd; }

.alert-close { background: none; border: none; cursor: pointer; font-size: 18px; color: inherit; opacity: 0.7; padding: 0; }
.alert-close:hover { opacity: 1; }

/* ─── FILTERS BAR ─────────────────────────────────── */
.filters-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 20px;
}

.filter-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-form .form-control, .filter-form .form-select {
  min-width: 120px !important;
  max-width: 180px !important;
  padding: 8px 12px !important;
  font-size: 13px !important;
}

/* ─── PROGRESS ────────────────────────────────────── */
.progress-bar-wrap {
  background: rgba(255,255,255,0.07);
  border-radius: 20px;
  height: 8px;
  overflow: hidden;
  margin-top: 6px;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 20px;
  background: linear-gradient(90deg, var(--accent), var(--teal));
  transition: width 0.6s ease;
}

/* ─── DETAIL SECTIONS ─────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.detail-item { display: flex; flex-direction: column; gap: 3px; }
.detail-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.detail-value { font-size: 14px; color: var(--text-primary); font-weight: 500; }

/* ─── EMPTY STATE ─────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 { font-size: 18px; font-weight: 600; margin-bottom: 8px; color: var(--text-secondary); }
.empty-state p { font-size: 14px; }

/* ─── RESPONSIVE ──────────────────────────────────── */
@media (max-width: 1024px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .main-wrapper { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
  .stats-grid { display: grid; grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .stats-grid { display: grid; grid-template-columns: 1fr; }
  .page-title { font-size: 20px; }
}

/* ─── LOGIN PAGE ──────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

.login-bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
}

.login-bg-orb-1 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(108,99,255,0.2), transparent);
  top: -100px; left: -100px;
  animation: orb1 8s ease-in-out infinite;
}

.login-bg-orb-2 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(0,212,170,0.15), transparent);
  bottom: -100px; right: -100px;
  animation: orb2 10s ease-in-out infinite;
}

@keyframes orb1 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(30px, 30px) scale(1.1); } }
@keyframes orb2 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-20px, -20px) scale(1.05); } }

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 24px;
  padding: 48px;
  width: 100%;
  max-width: 420px;
  position: relative;
  z-index: 10;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.login-logo {
  text-align: center;
  margin-bottom: 36px;
}

.login-logo .logo-icon {
  font-size: 48px;
  width: 80px; height: 80px;
  background: var(--accent-glow);
  border: 1px solid var(--accent);
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  animation: pulse-border 3s ease-in-out infinite;
}

@keyframes pulse-border {
  0%,100% { box-shadow: 0 0 0 0 rgba(108,99,255,0); border-color: var(--accent); }
  50% { box-shadow: 0 0 20px 4px rgba(108,99,255,0.3); border-color: var(--accent-light); }
}

.login-title { font-size: 24px; font-weight: 800; }
.login-sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.login-form { display: flex; flex-direction: column; gap: 16px; }

.login-form .input-group {
  position: relative;
}
.login-form .input-icon {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
  pointer-events: none;
}
.login-form .form-control {
  padding-left: 40px !important;
}

.login-btn {
  width: 100%;
  justify-content: center;
  padding: 13px !important;
  font-size: 15px !important;
  border-radius: 10px !important;
  margin-top: 8px;
}

.login-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ─── LOCAL STATUS CARDS ──────────────────────────── */
.locales-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.local-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-decoration: none;
  color: inherit;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

.local-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--local-color, var(--accent));
}

.local-card:hover {
  border-color: var(--border-light);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  color: inherit;
}

.local-card-header { display: flex; align-items: center; justify-content: space-between; }
.local-num { font-size: 22px; font-weight: 800; }
.local-tipo { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.8px; }
.local-name { font-size: 15px; font-weight: 600; }
.local-info { display: flex; gap: 16px; }
.local-info-item { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-muted); }

/* ─── MONEY COLORS ────────────────────────────────── */
.text-success { color: var(--emerald) !important; }
.text-danger  { color: var(--rose) !important; }
.text-warning { color: var(--gold) !important; }
.text-muted   { color: var(--text-muted) !important; }
.text-accent  { color: var(--accent-light) !important; }
.money { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ─── MISC ────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.section-gap { margin-bottom: 28px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: 8px; }
.w-100 { width: 100%; }
.text-center { text-align: center; }
.text-right { text-align: right; }
