/* ============================================
   GHL Sub-Accounts Portal – Professional Theme
   ============================================ */

:root {
  /* Marca: Partners La Casa de la IA */
  --navy: #502878;             /* Púrpura principal */
  --navy-light: #6b3fa0;       /* Púrpura claro (enlaces, etiquetas) */
  --navy-hover: #432068;       /* Púrpura oscuro (hover) */
  --navy-dark: #111618;        /* Dark slate (sidebar) */
  --gold: #f0d26e;             /* Dorado */
  --gold-light: #f5e08a;       /* Amarillo dorado claro */
  --gold-bg: rgba(240, 210, 110, 0.12);
  --orange: #c85a46;           /* Coral / Terracota (acento) */
  --orange-bg: rgba(200, 90, 70, 0.10);
  --bg: #ffffff;
  --bg-alt: #f0f3f4;
  --surface: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;
  --info: #2563eb;
  --info-bg: #eff6ff;
  --info-border: #bfdbfe;
  --shadow-sm: 0 1px 2px rgba(17, 22, 24, 0.05);
  --shadow: 0 1px 3px rgba(17, 22, 24, 0.08), 0 1px 2px rgba(17, 22, 24, 0.04);
  --shadow-md: 0 4px 6px rgba(17, 22, 24, 0.06), 0 2px 4px rgba(17, 22, 24, 0.04);
  --shadow-lg: 0 10px 15px rgba(17, 22, 24, 0.08), 0 4px 6px rgba(17, 22, 24, 0.04);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --transition: 0.2s ease;
  --sidebar-width: 260px;
  --topbar-height: 64px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--navy-light); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--gold); }

/* ---- Layout ---- */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--navy-dark) 0%, #0d1117 100%);
  color: #fff;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  overflow-y: auto;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: #fff;
}

.sidebar-logo-img {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  object-fit: contain;
  flex-shrink: 0;
  background: rgba(255,255,255,0.05);
}

.sidebar-logo-text {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.sidebar-logo-text small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: rgba(255,255,255,0.5);
  margin-top: 2px;
}

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

.sidebar-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.35);
  padding: 12px 12px 6px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  color: rgba(255,255,255,0.7);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
  margin-bottom: 2px;
}

.sidebar-link:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.sidebar-link.active {
  background: rgba(221, 171, 85, 0.16);
  color: var(--gold-light);
}

.sidebar-link svg,
.sidebar-link .icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-link.active svg,
.sidebar-link.active .icon {
  opacity: 1;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--navy-light);
  border: 2px solid rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--gold);
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
}

/* ---- Main Content ---- */
.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

/* ---- Topbar ---- */
.topbar {
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
}

.topbar-breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: var(--text);
}

/* ---- Page Content ---- */
.page {
  padding: 32px;
}

.page-header {
  margin-bottom: 28px;
}

.page-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--navy);
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-muted);
}

/* ---- Stats Cards ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: box-shadow var(--transition), transform var(--transition);
}

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

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 22px;
}

.stat-icon.gold { background: var(--gold-bg); color: var(--gold); }
.stat-icon.blue { background: var(--info-bg); color: var(--info); }
.stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-icon.red { background: var(--danger-bg); color: var(--danger); }

.stat-content { flex: 1; }

.stat-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

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

.stat-detail {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}

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

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

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-title .count {
  background: var(--bg);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
}

.card-body {
  padding: 24px;
}

.card-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
  background: var(--bg);
}

/* ---- Section Cards (no header separation) ---- */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 24px;
}

.section-card h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---- Forms ---- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group {
  margin-bottom: 0;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

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

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

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: all var(--transition);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(221, 171, 85, 0.18);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-light);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='%236b7280' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 36px;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: var(--navy);
  color: #fff;
}

.btn-primary:hover {
  background: var(--navy-hover);
  color: #fff;
  box-shadow: var(--shadow-md);
}

.btn-gold {
  background: var(--gold);
  color: var(--navy);
}

.btn-gold:hover {
  background: var(--gold-light);
  box-shadow: var(--shadow-md);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover {
  background: #15803d;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
}

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

.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 16px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 8px;
}

.btn-icon.sm {
  width: 32px;
  height: 32px;
}

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---- Tables ---- */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

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

tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

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

tbody tr:hover {
  background: var(--bg);
}

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

.table-name {
  font-weight: 600;
  color: var(--navy);
}

.table-email {
  color: var(--text-muted);
  font-size: 13px;
}

.table-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.table-empty svg {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  opacity: 0.3;
}

.table-empty p {
  margin-bottom: 4px;
}

.table-empty small {
  font-size: 13px;
  color: var(--text-light);
}

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-gold { background: var(--gold-bg); color: #8a6a1f; border: 1px solid rgba(221, 171, 85, 0.25); }
.badge-orange { background: var(--orange-bg); color: var(--orange); border: 1px solid rgba(210, 132, 69, 0.28); }
.badge-blue { background: var(--info-bg); color: var(--info); border: 1px solid var(--info-border); }
.badge-green { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.badge-red { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }
.badge-gray { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

/* ---- Alerts ---- */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  line-height: 1.5;
}

.alert svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}

.alert-ok { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.alert-error { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); }
.alert-info { background: var(--info-bg); color: var(--info); border: 1px solid var(--info-border); }

.alert code {
  background: rgba(0,0,0,0.08);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 22, 24, 0.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px) scale(0.98);
  transition: transform 0.25s ease;
}

.modal-overlay.active .modal {
  transform: translateY(0) scale(1);
}

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

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition);
}

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

.modal-body {
  padding: 24px;
}

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

/* ---- Confirmación destructiva en modal ---- */
.confirm-word {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.confirm-hint {
  display: none;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--danger);
}

.confirm-hint.show {
  display: block;
}

.btn[disabled],
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: none;
}

/* ---- Back Link ---- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 20px;
  text-decoration: none;
  transition: color var(--transition);
}

.back-link:hover {
  color: var(--navy);
}

/* ---- Action Row (inline edit/delete) ---- */
.action-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---- Quota Bar ---- */
.quota-bar {
  height: 6px;
  background: var(--bg-alt);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 8px;
}

.quota-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.quota-bar-fill.low { background: var(--success); }
.quota-bar-fill.medium { background: var(--warning); }
.quota-bar-fill.high { background: var(--danger); }

/* ---- Login Page ---- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f3f4;
  background-image: 
    radial-gradient(ellipse at 18% 45%, rgba(80, 40, 120, 0.08) 0%, transparent 55%),
    radial-gradient(ellipse at 82% 20%, rgba(200, 90, 70, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 65% 90%, rgba(240, 210, 110, 0.06) 0%, transparent 45%);
  padding: 24px;
}

.auth-box {
  background: var(--surface);
  padding: 40px 36px;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  text-align: center;
  margin-bottom: 32px;
}

.auth-logo-icon {
  width: 80px;
  height: 80px;
  background: var(--navy-dark);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.auth-logo-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 16px;
}

.auth-box h1 {
  font-size: 22px;
  font-weight: 800;
  color: var(--navy);
  text-align: center;
  margin: 0 0 4px;
}

.auth-box .auth-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 28px;
}

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

/* ---- Utilities ---- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-gold { color: var(--gold); }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.gap-sm { gap: 8px; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center { display: flex; align-items: center; }
.hidden { display: none !important; }

/* ---- Responsive ---- */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

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

  .main {
    margin-left: 0;
  }

  .mobile-menu-btn {
    display: block;
  }

  .page {
    padding: 24px 16px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 0 16px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .page-title {
    font-size: 20px;
  }

  .card-header {
    padding: 16px 18px;
  }

  .card-body {
    padding: 18px;
  }

  .modal {
    max-width: 100%;
    margin: 16px;
  }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-light);
}

/* ---- Print ---- */
@media print {
  .sidebar, .topbar, .btn, .mobile-menu-btn { display: none !important; }
  .main { margin-left: 0 !important; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

/* ---- Upload Area ---- */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg);
}

.upload-area:hover {
  border-color: var(--gold);
  background: var(--gold-bg);
}

.upload-area.dragover {
  border-color: var(--gold);
  background: var(--gold-bg);
  transform: scale(1.01);
}

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.upload-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.upload-preview img {
  max-width: 100%;
  height: auto;
}

/* ---- Responsive Upload ---- */
@media (max-width: 640px) {
  .upload-area {
    padding: 24px 16px;
  }
}
