/* ── Variables ── */
:root {
  --accent:        #deacf8;
  --accent-hover:  #e8c4fa;
  --accent-gold:   #ffc400;
  --bg:            #141414;
  --surface:       rgba(0,0,0,0.25);
  --surface-dark:  rgba(0,0,0,0.5);
  --border:        rgba(255,255,255,0.1);
  --border-accent: rgba(222,172,248,0.3);
  --text:          #e2e8f0;
  --text-muted:    #a0aec0;
  --success:       #22c55e;
  --error:         #ef4444;
  --warning:       #ffc107;
  --radius-lg:     16px;
  --radius-md:     12px;
  --radius-sm:     8px;
  --font:          'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition:    all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Fondo animado ── */
.bg-animated {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: var(--bg);
}
.bg-circle {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  mix-blend-mode: screen;
  opacity: 0.6;
  animation: floatCircle 20s infinite ease-in-out;
}
.bg-circle-1 {
  width: 500px; height: 500px;
  top: -100px; left: -100px;
  background: radial-gradient(circle, rgba(42,151,255,0.7), transparent);
  animation-duration: 22s;
}
.bg-circle-2 {
  width: 400px; height: 400px;
  top: 40%; right: -80px;
  background: radial-gradient(circle, rgba(189,0,255,0.7), transparent);
  animation-duration: 18s;
  animation-delay: -7s;
}
.bg-circle-3 {
  width: 350px; height: 350px;
  bottom: -80px; left: 40%;
  background: radial-gradient(circle, rgba(222,172,248,0.5), transparent);
  animation-duration: 25s;
  animation-delay: -13s;
}
@keyframes floatCircle {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%       { transform: translate(40px, -30px) scale(1.05); }
  66%       { transform: translate(-20px, 20px) scale(0.97); }
}

/* ── Navbar ── */
.navbar-tts {
  position: sticky;
  top: 0;
  z-index: 1050;
  background: rgba(0,0,0,0.85) !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 0;
}
.navbar-brand-tts {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent) !important;
  text-decoration: none;
  letter-spacing: -0.01em;
  transition: var(--transition);
}
.navbar-brand-tts:hover { color: var(--accent-hover) !important; }

.nav-link-tts {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
}
.nav-link-tts:hover {
  color: var(--text);
  background: rgba(255,255,255,0.07);
}
.nav-logout:hover { color: var(--error); }

.nav-user-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 0.4rem 0.85rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 50px;
}

/* Mobile nav */
@media (max-width: 991px) {
  .navbar-tts .navbar-collapse {
    padding: 0.75rem 0;
    border-top: 1px solid var(--border);
    margin-top: 0.75rem;
  }
  .navbar-tts .navbar-nav { gap: 0.25rem; }
  .nav-link-tts {
    display: flex;
    padding: 0.65rem 1rem;
    border-radius: var(--radius-sm);
  }
  .nav-user-badge { border-radius: var(--radius-sm); }
  .navbar-toggler { color: var(--text-muted); }
  .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28160,174,192,1%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
  }
}

/* ── Main ── */
.main-content {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
@media (min-width: 768px)  { .main-content { padding: 1.75rem 2rem; } }
@media (min-width: 1200px) { .main-content { padding: 2rem 3rem; } }

/* ── Glass Card ── */
.card-glass {
  background: rgba(0,0,0,0.25);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  transition: var(--transition);
}
.card-glass:hover {
  border-color: rgba(255,255,255,0.15);
  box-shadow: 0 12px 40px rgba(0,0,0,0.3);
}

/* ── Títulos ── */
.page-title    { font-size: 1.3rem; font-weight: 700; letter-spacing: -0.02em; }
.page-subtitle { color: var(--text-muted); font-size: 0.875rem; margin-top: 0.1rem; }
@media (min-width: 768px) { .page-title { font-size: 1.6rem; } }
.card-title    { font-size: 0.95rem; font-weight: 600; color: var(--text); }
.section-label { font-size: 0.8rem; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }

/* ── Forms ── */
label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 0.3rem;
  display: block;
}
.field { display: flex; flex-direction: column; }

input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 0.65rem 1rem;
  transition: var(--transition);
  outline: none;
  backdrop-filter: blur(10px);
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  background: rgba(255,255,255,0.08);
  box-shadow: 0 0 0 3px rgba(222,172,248,0.15);
}
input::placeholder, textarea::placeholder { color: rgba(255,255,255,0.35); }
textarea { resize: vertical; }

select option { background: #1a1a2e; color: var(--text); }

.form-grid   { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.form-grid-3 { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 600px)  { .form-grid   { grid-template-columns: 1fr 1fr; } }
@media (min-width: 600px)  { .form-grid-3 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 900px)  { .form-grid-3 { grid-template-columns: 1fr 1fr 1fr; } }

/* ── Sliders ── */
.sliders-grid  { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 600px) { .sliders-grid { grid-template-columns: 1fr 1fr; } }
.slider-field  { display: flex; flex-direction: column; gap: 0.3rem; }
.slider-label  { display: flex; justify-content: space-between; align-items: center; }
.slider-val    { color: var(--accent); font-weight: 600; font-size: 0.85rem; }
.slider-hint   { color: var(--text-muted); font-size: 0.72rem; }

input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255,255,255,0.1);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  border: none;
  padding: 0;
  outline: none;
  backdrop-filter: none;
  box-shadow: none;
}
input[type="range"]:focus { box-shadow: none; border-color: transparent; background: rgba(255,255,255,0.1); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(222,172,248,0.5);
  transition: var(--transition);
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 14px rgba(222,172,248,0.7);
}

/* ── Checkbox ── */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.875rem;
  user-select: none;
}
.checkbox-row input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  padding: 0;
  border-radius: 4px;
}

/* ── Char counter ── */
.char-counter { font-size: 0.78rem; color: var(--text-muted); text-align: right; }
.char-counter.warn  { color: var(--warning); }
.char-counter.limit { color: var(--error); }

/* ── Botones ── */
.btn-tts-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  border: none;
  color: #1a0533;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 4px 15px rgba(222,172,248,0.25);
}
.btn-tts-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(222,172,248,0.4);
  background: linear-gradient(135deg, var(--accent-hover), var(--accent-gold));
  color: #1a0533;
}
.btn-tts-primary:active:not(:disabled) { transform: translateY(0); }
.btn-tts-primary:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-tts-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn-tts-secondary:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.25);
  color: var(--text);
  transform: translateY(-1px);
}

.btn-tts-danger {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(239,68,68,0.15);
  border: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5;
  font-family: var(--font);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}
.btn-tts-danger:hover {
  background: rgba(239,68,68,0.3);
  border-color: rgba(239,68,68,0.5);
}

.btn-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(222,172,248,0.08);
  border: 1px solid var(--border-accent);
  color: var(--accent);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 1.1rem;
  border-radius: 50px;
  cursor: pointer;
  transition: var(--transition);
}
.btn-toggle:hover {
  background: rgba(222,172,248,0.15);
  border-color: var(--accent);
}
.btn-toggle.open {
  background: rgba(222,172,248,0.15);
  border-color: var(--accent);
}

/* ── Alertas ── */
.alert-tts {
  border-radius: var(--radius-sm);
  padding: 0.8rem 1rem;
  font-size: 0.875rem;
  backdrop-filter: blur(10px);
}
.alert-tts.error   { background: rgba(239,68,68,0.1);  border: 1px solid rgba(239,68,68,0.3);  color: #fca5a5; }
.alert-tts.success { background: rgba(34,197,94,0.1);  border: 1px solid rgba(34,197,94,0.3);  color: #86efac; }

/* ── Badges de rol ── */
.badge-rol {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.badge-admin    { background: rgba(139,92,246,0.2); color: #c4b5fd; border: 1px solid rgba(139,92,246,0.3); }
.badge-creator  { background: rgba(59,130,246,0.2); color: #93c5fd; border: 1px solid rgba(59,130,246,0.3); }
.badge-listener { background: rgba(34,197,94,0.2);  color: #86efac; border: 1px solid rgba(34,197,94,0.3); }

/* ── Tabla ── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); }
.tts-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; color: var(--text); }
.tts-table thead th {
  background: rgba(255,255,255,0.06);
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.tts-table tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.tts-table tbody tr:last-child td { border-bottom: none; }
.tts-table tbody tr:hover td { background: rgba(222,172,248,0.04); }
.text-truncate-cell { max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Audio ── */
audio {
  width: 100%;
  border-radius: var(--radius-sm);
  filter: invert(0.9) hue-rotate(200deg) brightness(0.85);
}
.audio-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; }

/* ── Galería ── */
.gallery-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
@media (min-width: 560px)  { .gallery-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 900px)  { .gallery-grid { grid-template-columns: 1fr 1fr 1fr; } }
@media (min-width: 1200px) { .gallery-grid { grid-template-columns: repeat(4, 1fr); } }

/* ── Login ── */
.login-wrap { max-width: 420px; margin: 2rem auto; padding: 0 1rem; }

/* ── Mobile: botones full width en acciones principales ── */
@media (max-width: 480px) {
  .btn-tts-primary,
  .btn-tts-secondary { width: 100%; justify-content: center; }
  .audio-actions { flex-direction: column; }
  .card-glass { padding: 1rem; }
  .page-title { font-size: 1.15rem; }
}

/* ── Divider ── */
.config-divider {
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
  margin-top: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: rgba(255,255,255,0.05); border-radius: 3px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.4); }

/* ── Spinner ── */
.spinner,
.tts-spinner {
  display: inline-block;
  width: 1rem; height: 1rem;
  border: 2px solid rgba(26,5,51,0.3);
  border-top-color: #1a0533;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utilidades ── */
.text-accent  { color: var(--accent); }
.text-muted-tts { color: var(--text-muted); }
.flex-end     { align-self: flex-end; }
.gap-1        { gap: 0.5rem; }
.d-flex-center { display: flex; align-items: center; }
