/* ==========================================================================
   NERTHYS STAFF PANEL — REDISEÑO "APPLE-LIKE"
   Capa de diseño que se carga DESPUÉS de panel.css. No toca IDs ni lógica:
   solo tokens, tipografía, layout (barra lateral), tarjetas, formularios,
   tablas, modales y avisos. Inspirado en macOS / visionOS (modo oscuro).
   ========================================================================== */

:root {
  /* Superficies (escala de grises de sistema) */
  --bg-space: #000000;
  --bg-deep: #0a0a0c;
  --bg-surface: #161618;
  --bg-surface-elevated: #1c1c1f;
  --bg-card: #161618;
  --bg-input: rgba(118, 118, 128, 0.18);

  /* Acento de marca: ámbar suave, usado con moderación */
  --gold-primary: #ffc83d;
  --gold-hover: #ffd466;
  --gold-glow: rgba(255, 200, 61, 0.22);
  --gold-subtle: rgba(255, 200, 61, 0.12);
  --gold-border: rgba(255, 200, 61, 0.28);

  --status-emerald: #30d158;
  --status-amber: #ff9f0a;
  --status-rose: #ff453a;
  --role-admin: #ff453a;
  --role-mod: #bf5af2;
  --role-helper: #64d2ff;

  --text-primary: #f5f5f7;
  --text-secondary: #a1a1a6;
  --text-muted: #8e8e93;
  --text-dim: #636366;

  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-medium: rgba(255, 255, 255, 0.12);
  --border-focus: rgba(255, 200, 61, 0.65);

  --font-display: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', 'Segoe UI', sans-serif;
  --font-ui: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', ui-monospace, 'JetBrains Mono', Menlo, Consolas, monospace;

  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-floating: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.08);
  --shadow-gold-button: 0 2px 10px rgba(255, 200, 61, 0.25);

  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 980px;
  --spring-ease: cubic-bezier(0.32, 0.72, 0, 1);

  --sidebar-w: 264px;
}

/* ---------- Base ---------- */
html, body {
  background: #000;
  font-family: var(--font-ui);
  letter-spacing: -0.011em;
  font-feature-settings: 'cv11', 'ss01';
}

body {
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(255, 200, 61, 0.07), transparent 60%),
    radial-gradient(900px 500px at 0% 110%, rgba(10, 132, 255, 0.07), transparent 60%),
    #000;
  background-attachment: fixed;
}

#cosmic-canvas, .ambient-glow { display: none !important; }

::selection { background: rgba(255, 200, 61, 0.35); }

* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.18) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.28); background-clip: padding-box; border: 2px solid transparent; }
::-webkit-scrollbar-track { background: transparent; }

h1, h2, h3, h4, .section-title, .modal-title, .login-title, .brand-name, .tool-card-title {
  font-family: var(--font-display);
  letter-spacing: -0.022em;
}

/* ---------- Tarjetas ---------- */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.glass-card:hover { border-color: rgba(255, 255, 255, 0.1); }
.card-glare { display: none; }

/* ---------- Botones ---------- */
.btn-primary, .btn-secondary, .btn-table-action, .btn-mini, .btn-danger, .btn-preset-pill {
  font-family: var(--font-ui);
  text-transform: none;
  letter-spacing: -0.01em;
}

.btn-primary {
  padding: 12px 22px;
  border-radius: var(--radius-pill);
  font-size: 0.95rem;
  font-weight: 600;
  transition: transform 0.25s var(--spring-ease), background 0.2s, box-shadow 0.2s, opacity 0.2s;
}

.btn-gold {
  background: var(--gold-primary);
  color: #1a1400;
  box-shadow: none;
}
.btn-gold:hover {
  background: var(--gold-hover);
  transform: scale(1.02);
  box-shadow: 0 6px 22px rgba(255, 200, 61, 0.25);
}
.btn-gold:active { transform: scale(0.98); }

.btn-compact { padding: 8px 16px; font-size: 0.85rem; border-radius: var(--radius-pill); }

.btn-secondary {
  background: rgba(120, 120, 128, 0.24);
  color: var(--text-primary);
  border: none;
  border-radius: var(--radius-pill);
  padding: 11px 20px;
  font-size: 0.92rem;
  font-weight: 600;
  transition: background 0.2s, transform 0.25s var(--spring-ease);
}
.btn-secondary:hover { background: rgba(120, 120, 128, 0.36); }
.btn-secondary:active { transform: scale(0.98); }

.btn-danger, .btn-action-danger {
  background: rgba(255, 69, 58, 0.14) !important;
  color: #ff6961 !important;
  border: none !important;
}
.btn-danger:hover, .btn-action-danger:hover { background: rgba(255, 69, 58, 0.24) !important; }

.btn-table-action, .btn-mini {
  background: rgba(120, 120, 128, 0.22);
  color: var(--text-primary);
  border: none;
  border-radius: var(--radius-pill);
  padding: 6px 13px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s var(--spring-ease);
}
.btn-table-action:hover, .btn-mini:hover { background: rgba(120, 120, 128, 0.38); }
.btn-table-action:active, .btn-mini:active { transform: scale(0.96); }

.btn-icon-logout {
  background: rgba(120, 120, 128, 0.22);
  border: none;
  border-radius: 50%;
  width: 34px; height: 34px;
  color: var(--text-secondary);
}
.btn-icon-logout:hover { background: rgba(255, 69, 58, 0.2); color: #ff6961; }

.btn-text-link { color: var(--gold-primary); }

/* ---------- Formularios ---------- */
.input-group label, .label-row label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0;
  text-transform: none;
}

.apple-input,
.input-wrapper input,
.input-wrapper textarea,
.input-wrapper select,
.select-wrapper select,
.apple-form input[type="text"],
.apple-form input[type="password"],
.apple-form input[type="number"],
.apple-form input[type="url"],
.apple-form textarea,
.apple-form select,
textarea.apple-input {
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-ui);
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.apple-input:hover, .input-wrapper input:hover, .input-wrapper textarea:hover { background: rgba(118, 118, 128, 0.26); }
.apple-input:focus, .input-wrapper input:focus, .input-wrapper textarea:focus,
.input-wrapper select:focus, .select-wrapper select:focus,
.apple-form input:focus, .apple-form textarea:focus, .apple-form select:focus {
  outline: none;
  background: rgba(118, 118, 128, 0.2);
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px rgba(255, 200, 61, 0.16);
}
input::placeholder, textarea::placeholder { color: var(--text-dim); }

.input-hint, .helper-text { color: var(--text-muted); font-size: 0.76rem; }

/* Interruptor tipo iOS */
.switch .slider { background: rgba(120, 120, 128, 0.32); border: none; }
.switch input:checked + .slider { background: var(--status-emerald); border-color: transparent; }

/* ---------- Login ---------- */
.login-card {
  max-width: 420px;
  padding: 44px 38px 34px;
  background: rgba(28, 28, 30, 0.72);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid var(--border-medium);
  border-radius: 28px;
  box-shadow: var(--shadow-floating);
}
.login-brand-logo { filter: drop-shadow(0 8px 28px rgba(255, 200, 61, 0.35)); }
.login-title { font-size: 1.7rem; font-weight: 700; }
.login-subtitle { color: var(--text-secondary); }
.brand-badge {
  background: rgba(120, 120, 128, 0.2);
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  letter-spacing: 0.04em;
  font-weight: 600;
}
.badge-dot { background: var(--status-emerald); box-shadow: 0 0 8px var(--status-emerald); }
.login-footer { color: var(--text-dim); }

/* ==========================================================================
   LAYOUT DEL DASHBOARD: BARRA SUPERIOR + BARRA LATERAL + CONTENIDO
   ========================================================================== */
#view-dashboard:not(.hidden) {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: auto auto 1fr;
  grid-template-areas:
    "top top"
    "banner banner"
    "side main";
  min-height: 100vh;
}

.panel-navbar {
  grid-area: top;
  position: sticky;
  top: 0;
  z-index: 60;
  padding: 10px 24px;
  background: rgba(22, 22, 24, 0.72);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border-bottom: 1px solid var(--border-subtle);
}
.nav-brand-logo { width: 30px; height: 30px; object-fit: contain; }
.brand-name { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }
.brand-tag { color: var(--text-muted); font-weight: 500; letter-spacing: 0; }

.db-live-indicator {
  background: rgba(120, 120, 128, 0.16);
  border: none;
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
  font-size: 0.72rem;
}

.preview-selector-wrap {
  background: rgba(120, 120, 128, 0.16);
  border: none;
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
}
.preview-selector-wrap select { background: transparent; color: var(--text-primary); border: none; }

.user-chip {
  background: rgba(120, 120, 128, 0.16);
  border: none;
  border-radius: var(--radius-pill);
  padding: 4px 14px 4px 4px;
  transition: background 0.2s;
}
.user-chip:hover { background: rgba(120, 120, 128, 0.28); }
.user-name { font-weight: 600; font-size: 0.85rem; }

.preview-mode-bar {
  grid-area: banner;
  background: rgba(255, 159, 10, 0.12);
  border-bottom: 1px solid rgba(255, 159, 10, 0.25);
  color: #ffb340;
}

/* ---- Barra lateral (antes pestañas horizontales) ---- */
.panel-tabs-bar {
  grid-area: side;
  position: sticky;
  top: 58px;
  align-self: start;
  height: calc(100vh - 58px);
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 4px;
  margin: 0;
  padding: 20px 14px 28px;
  border: none;
  border-right: 1px solid var(--border-subtle);
  border-radius: 0;
  background: rgba(10, 10, 12, 0.6);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  box-shadow: none;
  overflow-x: hidden;
  overflow-y: auto;
}

.tabs-group { display: flex; flex-direction: column; gap: 2px; }
.tabs-group-label {
  padding: 14px 12px 6px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.tabs-group:first-child .tabs-group-label { padding-top: 2px; }
.tabs-group-divider { display: none; }

.panel-tab-btn {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.panel-tab-btn > svg { flex-shrink: 0; opacity: 0.85; }
.panel-tab-btn > span:not(.tab-badge):not(.tab-perm-badge):not(.tab-free-badge) { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.panel-tab-btn:hover { background: rgba(120, 120, 128, 0.18); color: var(--text-primary); }
.panel-tab-btn.active {
  background: rgba(255, 200, 61, 0.14);
  color: var(--gold-primary);
  box-shadow: none;
  border: none;
}
.panel-tab-btn.active svg { opacity: 1; }

.tab-badge, .tab-perm-badge, .tab-free-badge {
  margin-left: auto;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: rgba(120, 120, 128, 0.24);
  border: none;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}
.panel-tab-btn.active .tab-badge { background: rgba(255, 200, 61, 0.25); color: var(--gold-primary); }

/* ---- Contenido ---- */
.panel-content {
  grid-area: main;
  min-width: 0;
  max-width: 1180px;
  margin: 0;
  padding: 32px 40px 72px;
  gap: 28px;
}

.stats-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.stat-card { padding: 20px 22px; background: var(--bg-card); gap: 16px; }
.stat-icon-wrap { width: 44px; height: 44px; border-radius: 12px; border: none !important; }
.gold-wrap { background: rgba(255, 200, 61, 0.15); color: var(--gold-primary); }
.emerald-wrap { background: rgba(48, 209, 88, 0.15); color: var(--status-emerald); }
.purple-wrap { background: rgba(191, 90, 242, 0.15); color: #d28bff; }
.cyan-wrap { background: rgba(100, 210, 255, 0.15); color: #64d2ff; border: none !important; }
.red-wrap { background: rgba(255, 69, 58, 0.15); color: #ff6961; border: none !important; }
.stat-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; }
.stat-number { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.03em; }

.section-title { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.03em; }
.section-desc { color: var(--text-muted); font-size: 0.9rem; }

.tab-pane { animation: tabFadeIn 0.35s var(--spring-ease) both; }

/* ---------- Tablas ---------- */
.table-card, .table-section .glass-card { padding: 0; overflow: hidden; }
.apple-table { border-collapse: separate; border-spacing: 0; width: 100%; }
.apple-table thead, .apple-table thead th {
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border-subtle);
}
.apple-table th, .apple-table td { padding: 14px 18px; }
.apple-table tbody tr { border-bottom: 1px solid var(--border-subtle); transition: background 0.15s; }
.apple-table tbody tr:last-child { border-bottom: none; }
.apple-table tbody tr:hover { background: rgba(255, 255, 255, 0.03); }

.news-thumb-img { border-radius: 8px; object-fit: cover; }

/* ---------- Píldoras / badges de rol y estado ---------- */
.pill-badge, .user-role-badge, .security-badge, .status-indicator-badge, .tag-label,
.pill-gold, .pill-red, .pill-purple, .badge-mini, .badge-dev, .so-badge-mini {
  border-radius: var(--radius-pill);
  font-family: var(--font-ui);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

/* ---------- Avisos ---------- */
.alert-box {
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.85rem;
}
.alert-box.error { background: rgba(255, 69, 58, 0.14); color: #ff8a82; }
.alert-box.success { background: rgba(48, 209, 88, 0.14); color: #6ee08a; }

/* ---------- Modales (estilo hoja de macOS) ---------- */
.modal-overlay {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
}
.modal-card {
  background: rgba(36, 36, 38, 0.92);
  border: 1px solid var(--border-medium);
  border-radius: 24px;
  box-shadow: var(--shadow-floating);
  padding: 28px 28px 24px;
}
.modal-title { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.02em; }
.modal-subtitle { color: var(--text-muted); }
.btn-close-modal {
  background: rgba(120, 120, 128, 0.28);
  border: none;
  border-radius: 50%;
  color: var(--text-secondary);
}
.btn-close-modal:hover { background: rgba(120, 120, 128, 0.45); color: var(--text-primary); }
.modal-badge-icon { border-radius: 12px; }

/* ---------- Herramientas / tarjetas internas ---------- */
.tool-card, .form-card, .preview-card, .canned-card, .discord-preview-card, .active-broadcast-status-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.tool-badge-icon { border-radius: 12px; }

.support-subnav-bar {
  background: rgba(118, 118, 128, 0.18);
  border: none;
  border-radius: 12px;
  padding: 3px;
}
.support-subnav-btn {
  border-radius: 9px;
  border: none;
  font-family: var(--font-ui);
  font-weight: 600;
  color: var(--text-secondary);
}
.support-subnav-btn.active {
  background: rgba(99, 99, 102, 0.7);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.image-upload-dropzone {
  border: 1.5px dashed rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-md);
  background: rgba(118, 118, 128, 0.1);
  transition: background 0.2s, border-color 0.2s;
}
.image-upload-dropzone:hover, .image-upload-dropzone.dragover {
  border-color: var(--gold-primary);
  background: rgba(255, 200, 61, 0.07);
}
.image-preview-box { border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--border-subtle); }

.editor-toolbar { background: rgba(118, 118, 128, 0.14); border: none; border-radius: 10px; }
.editor-toolbar-btn { border-radius: 8px; border: none; background: transparent; color: var(--text-secondary); }
.editor-toolbar-btn:hover { background: rgba(120, 120, 128, 0.3); color: var(--text-primary); }

/* ---------- Toasts ---------- */
.toast {
  background: rgba(44, 44, 46, 0.9);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid var(--border-medium);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
}

.permission-locked-card {
  background: rgba(255, 69, 58, 0.06);
  border: 1px solid rgba(255, 69, 58, 0.2);
  border-radius: var(--radius-lg);
}

/* ==========================================================================
   RESPONSIVE: la barra lateral pasa a barra horizontal tipo "segmented"
   ========================================================================== */
@media (max-width: 980px) {
  #view-dashboard:not(.hidden) {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "top" "banner" "side" "main";
  }
  .panel-tabs-bar {
    position: sticky;
    top: 58px;
    z-index: 40;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    overflow-x: auto;
    overflow-y: hidden;
    background: rgba(10, 10, 12, 0.85);
  }
  .tabs-group { flex-direction: row; align-items: center; gap: 4px; }
  .tabs-group-label { display: none; }
  .panel-tab-btn { width: auto; padding: 8px 14px; border-radius: var(--radius-pill); }
  .tab-perm-badge { display: none; }
  .panel-content { padding: 22px 16px 60px; }
  .panel-navbar { padding: 8px 14px; }
  .db-live-indicator { display: none; }
}
