/* ============================================================
   CASA HOGAR NUEVO AMANECER — THEME GLOBAL
   Modo claro / oscuro unificado para todo el sistema
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800;900&family=Inter:wght@300;400;500;600&display=swap');
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css');

/* ---- VARIABLES MODO CLARO ---- */
:root {
  --bg:           #f4f6fb;
  --bg2:          #edf0f7;
  --surface:      #ffffff;
  --surface2:     #f8f9fc;
  --border:       #e5e9f2;
  --border2:      #d1d9e8;
  --text:         #111827;
  --text-2:       #374151;
  --text-muted:   #6b7280;
  --text-dim:     #9ca3af;
  --accent:       #2563eb;
  --accent-light: #eff6ff;
  --accent-hover: #1d4ed8;
  --success:      #16a34a;
  --success-bg:   #f0fdf4;
  --danger:       #dc2626;
  --danger-bg:    #fef2f2;
  --warning:      #d97706;
  --warning-bg:   #fffbeb;
  --purple:       #7c3aed;
  --purple-bg:    #f5f3ff;
  --sidebar-bg:   #ffffff;
  --sidebar-border: #e5e9f2;
  --sidebar-icon: #6b7280;
  --sidebar-active-bg: #eff6ff;
  --sidebar-active-icon: #2563eb;
  --modal-overlay: rgba(17,24,39,0.5);
  --card-shadow:  0 1px 4px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
  --card-shadow-hover: 0 4px 12px rgba(0,0,0,0.1), 0 12px 32px rgba(0,0,0,0.06);
  --radius-sm:    10px;
  --radius-md:    14px;
  --radius-lg:    20px;
  --radius-xl:    28px;
  --transition:   0.2s ease;
  --font-display: 'Outfit', sans-serif;
  --font-body:    'Inter', sans-serif;
}

/* ---- VARIABLES MODO OSCURO ---- */
[data-theme="dark"] {
  --bg:           #0f1117;
  --bg2:          #161b27;
  --surface:      #1a1f2e;
  --surface2:     #212736;
  --border:       rgba(255,255,255,0.08);
  --border2:      rgba(255,255,255,0.14);
  --text:         #f1f5f9;
  --text-2:       #cbd5e1;
  --text-muted:   #94a3b8;
  --text-dim:     #64748b;
  --accent:       #3b82f6;
  --accent-light: rgba(59,130,246,0.12);
  --accent-hover: #60a5fa;
  --success:      #4ade80;
  --success-bg:   rgba(74,222,128,0.1);
  --danger:       #f87171;
  --danger-bg:    rgba(248,113,113,0.1);
  --warning:      #fbbf24;
  --warning-bg:   rgba(251,191,36,0.1);
  --purple:       #a78bfa;
  --purple-bg:    rgba(167,139,250,0.1);
  --sidebar-bg:   #13161f;
  --sidebar-border: rgba(255,255,255,0.06);
  --sidebar-icon: #64748b;
  --sidebar-active-bg: rgba(59,130,246,0.15);
  --sidebar-active-icon: #60a5fa;
  --modal-overlay: rgba(0,0,0,0.7);
  --card-shadow:  0 1px 4px rgba(0,0,0,0.3), 0 4px 16px rgba(0,0,0,0.2);
  --card-shadow-hover: 0 4px 12px rgba(0,0,0,0.4), 0 12px 32px rgba(0,0,0,0.3);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  transition: background var(--transition), color var(--transition);
  line-height: 1.6;
}

/* ---- LAYOUT ---- */
.app-shell { display: flex; min-height: 100vh; width: 100%; }

.main-content {
  margin-left: 72px;
  flex: 1;
  padding: 32px 28px 60px;
  max-width: 1100px;
  transition: margin var(--transition);
}

/* ---- TOPBAR (sol/luna + título) ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}

.topbar-left { flex: 1; }

.page-eyebrow {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.page-title {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
  letter-spacing: -0.03em;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 400;
}

/* ---- BOTÓN TEMA ---- */
.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border2);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all var(--transition);
  flex-shrink: 0;
  box-shadow: var(--card-shadow);
}

.theme-toggle:hover {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent);
}

/* ---- CARDS ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--card-shadow);
  transition: box-shadow var(--transition), border-color var(--transition);
  overflow: hidden;
}

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

.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.card-header-title i { color: var(--accent); }

.card-body { padding: 24px; }

/* ---- BOTONES ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.18s ease;
  white-space: nowrap;
  line-height: 1;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Primary — Google/YouTube style */
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 3px rgba(37,99,235,0.25);
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  color: #fff;
  box-shadow: 0 4px 14px rgba(37,99,235,0.35);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

/* Secondary */
.btn-secondary {
  background: var(--surface2);
  color: var(--text-2);
  border: 1px solid var(--border2);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--accent-light);
  color: var(--accent);
  border-color: var(--accent);
}

/* Danger */
.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(220,38,38,0.2);
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger);
  color: #fff;
}

/* Success */
.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover:not(:disabled) {
  opacity: .88;
  transform: translateY(-1px);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface2);
  color: var(--text);
}

/* Sizes */
.btn-sm  { font-size: 12px; padding: 7px 14px; }
.btn-lg  { font-size: 15px; padding: 13px 28px; border-radius: var(--radius-md); }
.btn-full { width: 100%; }

/* Icon-only */
.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: all var(--transition);
}
.btn-icon:hover { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }

/* ---- FORMULARIOS ---- */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}

.form-label .req { color: var(--danger); margin-left: 2px; }

.form-control, .form-select {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  outline: none;
  appearance: none;
}

.form-control::placeholder { color: var(--text-dim); }
.form-select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; cursor: pointer; }

.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
  background: var(--surface);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}

/* ---- BADGES ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .03em;
}

.badge-green  { background: var(--success-bg);  color: var(--success);  }
.badge-red    { background: var(--danger-bg);   color: var(--danger);   }
.badge-blue   { background: var(--accent-light); color: var(--accent);  }
.badge-purple { background: var(--purple-bg);   color: var(--purple);   }
.badge-yellow { background: var(--warning-bg);  color: var(--warning);  }
.badge-gray   { background: var(--surface2);    color: var(--text-muted); border: 1px solid var(--border); }

/* ---- TABLA ---- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.table thead {
  background: var(--surface2);
}

.table th {
  padding: 11px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  vertical-align: middle;
}

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

.table tbody tr {
  transition: background var(--transition);
}

.table tbody tr:hover { background: var(--surface2); }

/* ---- MODALES ---- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--modal-overlay);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal-overlay.open { display: flex; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 460px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  animation: modalIn .22s cubic-bezier(.34,1.56,.64,1);
  overflow: hidden;
}

.modal-box-lg { max-width: 700px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(.93) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--surface2);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all var(--transition);
}

.modal-close:hover { background: var(--danger-bg); color: var(--danger); }

.modal-body { padding: 20px 24px; }

.modal-footer {
  padding: 16px 24px 20px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  border-top: 1px solid var(--border);
}

/* ---- TOAST ---- */
.toast-container {
  position: fixed;
  top: 20px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(0,0,0,0.18);
  transform: translateX(120%);
  transition: transform .35s cubic-bezier(.34,1.56,.64,1);
  min-width: 240px;
  max-width: 360px;
  border: 1px solid transparent;
}

.toast.show { transform: translateX(0); }

.toast-success { background: var(--success-bg); color: var(--success); border-color: rgba(22,163,74,0.2); }
.toast-error   { background: var(--danger-bg);  color: var(--danger);  border-color: rgba(220,38,38,0.2); }
.toast-info    { background: var(--accent-light); color: var(--accent); border-color: rgba(37,99,235,0.2); }

/* ---- STAT CARDS ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--card-shadow);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--card-shadow-hover);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin-bottom: 14px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  margin-bottom: 4px;
}

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

/* ---- CHIPS ---- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-light);
  border: 1px solid rgba(37,99,235,0.18);
  color: var(--accent);
  border-radius: 8px;
  padding: 5px 10px 5px 12px;
  font-size: 12px;
  font-weight: 500;
  animation: chipIn .18s ease;
}

@keyframes chipIn {
  from { opacity: 0; transform: scale(.85); }
  to   { opacity: 1; transform: scale(1); }
}

.chip-remove {
  width: 16px;
  height: 16px;
  background: rgba(220,38,38,0.12);
  border-radius: 4px;
  border: none;
  cursor: pointer;
  color: var(--danger);
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}

.chip-remove:hover { background: var(--danger); color: #fff; }

/* ---- BREADCRUMB ---- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.breadcrumb a:hover { text-decoration: underline; }

.breadcrumb-sep { color: var(--border2); }

/* ---- ALERTS ---- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 20px;
  border: 1px solid transparent;
}

.alert-success { background: var(--success-bg); color: var(--success); border-color: rgba(22,163,74,.2); }
.alert-danger   { background: var(--danger-bg);  color: var(--danger);  border-color: rgba(220,38,38,.2); }
.alert-info     { background: var(--accent-light); color: var(--accent); border-color: rgba(37,99,235,.2); }
.alert-warning  { background: var(--warning-bg); color: var(--warning); border-color: rgba(217,119,6,.2); }

/* ---- LOADING SPINNER ---- */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- SECTION DIVIDER ---- */
.section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

/* ---- SKELETON LOADER ---- */
.skeleton {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--border) 50%, var(--surface2) 75%);
  background-size: 400% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0%   { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ---- DROPDOWN (para búsqueda) ---- */
.dropdown-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  z-index: 200;
  max-height: 220px;
  overflow-y: auto;
  display: none;
}

.dropdown-results.open { display: block; }

.dropdown-option {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background var(--transition);
}

.dropdown-option:last-child { border-bottom: none; }
.dropdown-option:hover { background: var(--accent-light); color: var(--accent); }

.dropdown-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--purple) 100%);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: .4;
  display: block;
}

.empty-state p {
  font-size: 14px;
  margin-bottom: 16px;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
  .main-content { padding: 20px 16px 40px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .table th, .table td { padding: 10px 12px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ---- UTILIDADES ---- */
.text-accent  { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-muted   { color: var(--text-muted); }
.text-sm      { font-size: 12px; }
.text-xs      { font-size: 11px; }
.fw-600       { font-weight: 600; }
.fw-700       { font-weight: 700; }
.fw-800       { font-weight: 800; }
.d-flex       { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8   { margin-top: 8px; }
.mt-16  { margin-top: 16px; }
.mt-24  { margin-top: 24px; }
.mb-16  { margin-bottom: 16px; }
.mb-24  { margin-bottom: 24px; }
.w-full { width: 100%; }
.relative { position: relative; }

/* ---- PRINT ---- */
@media print {
  .sidebar, .topbar, .theme-toggle, .no-print, .btn { display: none !important; }
  body { background: white !important; }
  .main-content { margin: 0 !important; padding: 0 !important; max-width: 100% !important; }
}
