:root {
  --bg-color: #0f172a;
  --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
  --glass-bg: rgba(255, 255, 255, 0.03);
  --glass-border: rgba(255, 255, 255, 0.08);
  --primary: #8b5cf6;
  --primary-hover: #a78bfa;
  --secondary: #3b82f6;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-gradient);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Background Animations */
.background-animation {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  overflow: hidden;
}

.glow-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.4;
  animation: float 20s infinite alternate;
}

.orb-1 {
  width: 400px;
  height: 400px;
  background: var(--primary);
  top: -100px;
  left: -100px;
}

.orb-2 {
  width: 500px;
  height: 500px;
  background: var(--secondary);
  bottom: -150px;
  right: -100px;
  animation-delay: -10s;
}

@keyframes float {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(50px, 50px) scale(1.1); }
  100% { transform: translate(-50px, 100px) scale(0.9); }
}

/* Utility Classes */
.hidden { display: none !important; }
.view { min-height: 100vh; display: flex; flex-direction: column; }

.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

/* Login View */
#login-view {
  justify-content: center;
  align-items: center;
}

.login-card {
  padding: 3rem;
  width: 100%;
  max-width: 400px;
  text-align: center;
  animation: slideUp 0.5s ease-out;
}

.icon-container {
  width: 64px;
  height: 64px;
  background: rgba(139, 92, 246, 0.1);
  border-radius: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0 auto 1.5rem;
  color: var(--primary);
}

.icon-container svg { width: 32px; height: 32px; }

.login-card h2 { margin-bottom: 0.5rem; font-weight: 700; font-size: 1.5rem; }
.login-card p { color: var(--text-muted); margin-bottom: 2rem; font-size: 0.95rem; }

.input-group { margin-bottom: 1.5rem; }
.input-group input {
  width: 100%;
  padding: 1rem 1.25rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  color: white;
  font-size: 1rem;
  transition: all 0.3s ease;
  font-family: inherit;
}
.input-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.1);
}

.btn-primary {
  width: 100%;
  padding: 1rem;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border: none;
  border-radius: 12px;
  color: white;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  font-family: inherit;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(139, 92, 246, 0.3);
}
.btn-primary:active { transform: translateY(0); }

.error-msg {
  color: var(--error);
  margin-top: 1rem;
  font-size: 0.9rem;
  min-height: 20px;
}

/* Dashboard View */
.glass-nav {
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo { display: flex; align-items: center; gap: 0.75rem; }
.logo h1 { font-size: 1.25rem; font-weight: 600; background: linear-gradient(to right, #fff, #94a3b8); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

.header-actions { display: flex; gap: 1rem; align-items: center; }

.btn-secondary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  color: white;
  text-decoration: none;
  font-size: 0.9rem;
  transition: background 0.3s;
}
.btn-secondary:hover { background: rgba(255, 255, 255, 0.1); }
.btn-secondary svg { width: 18px; height: 18px; }

.btn-outline {
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.3s;
}
.btn-outline:hover { color: white; border-color: rgba(255,255,255,0.2); }

.dashboard-content {
  padding: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.status-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  padding: 1.5rem;
  gap: 2rem;
  margin-bottom: 2rem;
}

.stat { display: flex; flex-direction: column; gap: 0.5rem; }
.stat-value { font-size: 2.5rem; font-weight: 700; line-height: 1; }
.stat-label { color: var(--text-muted); font-size: 0.9rem; text-transform: uppercase; letter-spacing: 1px; }

.status-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-top: 10px;
  margin-bottom: 10px;
}
.online { background: var(--success); box-shadow: 0 0 10px var(--success); }

.section-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.pulse-indicator {
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(139, 92, 246, 0); }
  100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0); }
}

.jobs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 1.5rem;
}

.job-card {
  padding: 1.5rem;
  transition: transform 0.3s;
  animation: fadeIn 0.4s ease-out;
  position: relative;
  overflow: hidden;
}

.job-card:hover { transform: translateY(-4px); }

.job-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1rem; }
.job-title { font-weight: 600; font-size: 1.1rem; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 80%; }
.job-badge {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 20px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-video { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.badge-audio { background: rgba(139, 92, 246, 0.15); color: #a78bfa; }

.job-url { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 1.5rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; text-decoration: none; }
.job-url:hover { text-decoration: underline; }

.progress-container { margin-bottom: 0.75rem; }
.progress-header { display: flex; justify-content: space-between; font-size: 0.85rem; margin-bottom: 0.5rem; }
.progress-status { color: var(--text-muted); font-weight: 500; text-transform: capitalize; }
.progress-percent { font-weight: 600; color: white; }

.progress-bar-bg {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 3px;
  transition: width 0.3s ease;
  width: 0%;
}

.job-card.status-error .progress-bar-fill { background: var(--error); }
.job-card.status-completed .progress-bar-fill { background: var(--success); }
.job-card.status-compressing .progress-bar-fill { animation: indeterminate 1.5s infinite linear; background: linear-gradient(90deg, transparent, var(--secondary), transparent); width: 100%; }

@keyframes indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.job-footer {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--glass-border);
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

.error-text { color: #fca5a5; font-size: 0.85rem; margin-top: 0.5rem; }

.job-filename {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Fila de velocidad y ETA */
.job-stats {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.6rem;
  flex-wrap: wrap;
}

.stat-speed,
.stat-eta {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  letter-spacing: 0.3px;
}

.stat-speed {
  background: rgba(139, 92, 246, 0.15);
  color: #a78bfa;
}

.stat-eta {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
  text-align: center;
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 1rem; opacity: 0.5; }

/* UI Elements */
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }

/* Sections Audio / Video */
.type-section { margin-bottom: 2rem; }

.type-heading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding-left: 0.5rem;
}

.type-heading h3 { font-weight: 600; font-size: 1.1rem; color: #e2e8f0; }

.type-count {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* History Section */
.history-section {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--glass-border);
}

.history-empty, .history-loading { color: var(--text-muted); text-align: center; padding: 2rem; }

details.history-date-group {
  margin-bottom: 1rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  overflow: hidden;
}

details.history-date-group > summary {
  padding: 1rem 1.5rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
  font-weight: 600;
  transition: background 0.3s;
}
details.history-date-group > summary:hover { background: rgba(255, 255, 255, 0.05); }

.date-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 3px 8px;
  border-radius: 10px;
}

.history-date-content {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

details.history-type-group { margin-bottom: 1rem; }
details.history-type-group:last-child { margin-bottom: 0; }

details.history-type-group > summary {
  padding: 0.75rem 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 500;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  transition: background 0.2s;
}
details.history-type-group > summary:hover { background: rgba(255, 255, 255, 0.05); }

.type-count-badge {
  margin-left: auto;
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 8px;
  color: var(--text-muted);
}

.history-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
  padding: 1rem 0;
  padding-left: 1rem;
}

/* Responsive grid para history-items en mobiles */
@media (max-width: 768px) {
  .history-items {
    grid-template-columns: 1fr;
    padding-left: 0;
  }
  .history-date-content { padding: 1rem 0.5rem; }
}

.history-item {
  padding: 1.25rem;
  border-radius: 12px;
  background: var(--glass-bg);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.history-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-alias { font-weight: 600; color: white; }
.history-time { font-size: 0.8rem; color: var(--text-muted); }

.history-filename {
  font-size: 0.85rem;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-url {
  font-size: 0.8rem;
  color: var(--secondary);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-url:hover { text-decoration: underline; }

.history-actions {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--glass-border);
}

.btn-download {
  display: inline-block;
  font-size: 0.85rem;
  color: #10b981;
  text-decoration: none;
  background: rgba(16, 185, 129, 0.1);
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  transition: background 0.2s;
  font-weight: 500;
}
.btn-download:hover { background: rgba(16, 185, 129, 0.2); }

/* Esconder la flecha por defecto de details y anadir la nuestra */
details > summary::-webkit-details-marker { display: none; }
details > summary { list-style: none; }

details > summary::after {
  content: "▼";
  font-size: 0.8rem;
  margin-left: 0.5rem;
  color: var(--text-muted);
  transition: transform 0.2s;
}
details[open] > summary::after { transform: rotate(180deg); }

@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }



/* Tabs */
.dashboard-tabs {
  display: flex;
  gap: 1rem;
  padding: 0 2rem;
  margin-top: 1.5rem;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 500;
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.3s;
}
.tab-btn:hover { color: white; }
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content { animation: fadeIn 0.4s ease-out; }

/* File Explorer */
.explorer-container {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 400px;
}

.explorer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--glass-border);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
}

.breadcrumb .crumb { color: var(--text-muted); }
.breadcrumb .crumb.link { color: var(--primary); cursor: pointer; }
.breadcrumb .crumb.link:hover { text-decoration: underline; }
.breadcrumb .crumb.active { color: white; font-weight: 500; }
.breadcrumb .separator { color: var(--glass-border); }

.explorer-list-header {
  display: grid;
  grid-template-columns: 3fr 1fr 1fr 36px;
  padding: 0.75rem 1.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.02);
  font-weight: 600;
}

.explorer-list {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.explorer-row {
  display: grid;
  grid-template-columns: 3fr 1fr 1fr 36px;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.02);
  align-items: center;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 0.9rem;
}

.explorer-row:hover { background: rgba(255, 255, 255, 0.05); }

.explorer-row .col-name { display: flex; align-items: center; gap: 0.75rem; color: #e2e8f0; }
.explorer-row .col-name .icon { font-size: 1.25rem; }
.explorer-row .col-size { color: var(--text-muted); }
.explorer-row .col-date { color: var(--text-muted); font-size: 0.85rem; }

.explorer-row.folder .col-name { font-weight: 500; }
.explorer-row.link-parent .col-name { font-style: italic; }

/* ── Botón eliminar en el explorador ─────────────────────────────────────── */
.col-actions { display: flex; align-items: center; justify-content: flex-end; }

.btn-file-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid rgba(239, 68, 68, 0.3);
  background: transparent;
  color: var(--error);
  cursor: pointer;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.2s, background 0.15s;
  flex-shrink: 0;
}

.explorer-row:hover .btn-file-delete { opacity: 1; }
.btn-file-delete:hover { background: rgba(239, 68, 68, 0.15); }

/* ── Modal de confirmación ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease-out;
}

.modal-box {
  width: min(420px, 92vw);
  padding: 2rem;
  border-radius: 16px;
  border: 1px solid rgba(239, 68, 68, 0.2);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-title { font-size: 1.1rem; font-weight: 600; color: var(--error); }

.modal-msg {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.5;
  word-break: break-all;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

/* ── Botón rojo de peligro ────────────────────────────────────────────────── */
.btn-danger {
  padding: 0.6rem 1.25rem;
  border-radius: 8px;
  border: none;
  background: var(--error);
  color: white;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.btn-danger:hover  { background: #dc2626; }
.btn-danger:active { transform: scale(0.97); }
.btn-danger:disabled { opacity: 0.5; cursor: not-allowed; }

