@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --primary: #0088ff;
  --primary-dk: #005fbb;
  --success: #28a745;
  --danger: #e53e3e;
  --warning: #f6c90e;
  --info: #00d4ff;
  --bg: #08090f;
  --bg2: #0f111a;
  --card: #13162080;
  --card-solid: #13162099;
  --border: rgba(255, 255, 255, 0.07);
  --text: #dde1f0;
  --text-dim: #6b7494;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --glow: 0 0 20px rgba(0, 136, 255, 0.18);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(0, 136, 255, 0.12), transparent),
    radial-gradient(ellipse 60% 40% at 90% 110%, rgba(0, 212, 255, 0.06), transparent);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ===== LAYOUT ===== */
.dashboard {
  padding: 1.5rem 2rem 3rem;
  max-width: 1500px;
  margin: 0 auto;
}

/* ===== HEADER ===== */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
  flex-wrap: wrap;
}

.title-group {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.title-icon {
  font-size: 2.5rem;
  filter: drop-shadow(0 0 12px rgba(0, 136, 255, 0.5));
}

.title-group h1 {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
  letter-spacing: -0.5px;
}

.version-tag {
  font-size: 0.7rem;
  background: rgba(0, 136, 255, 0.2);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 20px;
  vertical-align: middle;
  font-weight: 600;
  letter-spacing: 1px;
}

.subtitle {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4rem;
}

/* LIVE INDICATOR */
.live-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid currentColor;
}

.live-on {
  color: var(--success);
  background: rgba(40, 167, 69, 0.12);
  border-color: rgba(40, 167, 69, 0.3);
}

.live-off {
  color: var(--danger);
  background: rgba(229, 62, 62, 0.12);
  border-color: rgba(229, 62, 62, 0.3);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.live-on .live-dot {
  animation: livePulse 1.2s infinite;
}

.live-off .live-dot {
  animation: none;
}

@keyframes livePulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.3;
    transform: scale(0.8);
  }
}

.server-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 0.75rem;
  color: var(--text-dim);
  gap: 2px;
}

.server-host {
  font-weight: 600;
  color: var(--text);
}

.update-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
}

/* ===== TOAST ===== */
.toast-notification {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  padding: 0.9rem 1.5rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  z-index: 9999;
  max-width: 400px;
  backdrop-filter: blur(12px);
  animation: slideInRight 0.3s ease-out;
  box-shadow: var(--shadow);
}

.toast-ok {
  background: rgba(40, 167, 69, 0.9);
  color: #fff;
  border-left: 4px solid #1a7d35;
}

.toast-error {
  background: rgba(229, 62, 62, 0.9);
  color: #fff;
  border-left: 4px solid #9b1c1c;
}

@keyframes slideInRight {
  from {
    transform: translateX(120%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ===== CONN ERROR ===== */
.conn-error-banner {
  background: linear-gradient(135deg, rgba(229, 62, 62, 0.2), rgba(229, 62, 62, 0.08));
  border: 1px solid rgba(229, 62, 62, 0.4);
  color: #fc8181;
  padding: 1rem 1.5rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
  text-align: center;
  animation: fadeIn 0.4s ease;
}

/* ===== STATS GRID ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--card);
  backdrop-filter: blur(10px);
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  border-top: 3px solid transparent;
  transition: transform 0.2s, box-shadow 0.2s;
}

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

.stat-primary {
  border-top-color: var(--primary);
}

.stat-warning {
  border-top-color: var(--warning);
}

.stat-danger {
  border-top-color: var(--danger);
}

.stat-success {
  border-top-color: var(--success);
}

.stat-icon {
  font-size: 2rem;
  line-height: 1;
}

.stat-info h3 {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 2.2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stat-pulse {
  animation: pulse 1.5s infinite;
  color: var(--danger);
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

/* ===== CONTROL BAR ===== */
.control-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.25rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.control-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
}

.unit-selector {
  flex: 1;
  min-width: 200px;
  background: #0f111a;
  color: var(--text);
  border: 1px solid rgba(0, 136, 255, 0.3);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-family: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.unit-selector:focus {
  border-color: var(--primary);
}

.btn-refresh {
  padding: 0.5rem 1rem;
  background: rgba(0, 136, 255, 0.15);
  color: var(--primary);
  border: 1px solid rgba(0, 136, 255, 0.3);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-refresh:hover {
  background: rgba(0, 136, 255, 0.3);
  transform: scale(1.03);
}

.poll-counter {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
}

/* ===== CONTENT GRID ===== */
.content-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

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

/* ===== SECTION CARD ===== */
.section-card {
  background: var(--card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  font-size: 1rem;
  font-weight: 700;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.badge-count {
  font-size: 0.72rem;
  background: rgba(0, 136, 255, 0.15);
  color: var(--primary);
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
  border: 1px solid rgba(0, 136, 255, 0.25);
}

/* ===== TABLA ===== */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  color: var(--text-dim);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 0.85rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 0.875rem;
}

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

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.row-grabando td {
  background: rgba(0, 136, 255, 0.05);
}

.id-badge {
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 7px;
  border-radius: 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  color: var(--text-dim);
}

.modalidad-tag {
  background: rgba(0, 212, 255, 0.1);
  color: var(--info);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
}

.unidad-text {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-dim);
}

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.badge-pendiente {
  background: rgba(246, 201, 14, 0.15);
  color: var(--warning);
  border: 1px solid rgba(246, 201, 14, 0.3);
}

.badge-preparando {
  background: rgba(0, 212, 255, 0.15);
  color: var(--info);
  border: 1px solid rgba(0, 212, 255, 0.3);
}

.badge-esperando {
  background: rgba(155, 89, 182, 0.15);
  color: #c77dff;
  border: 1px solid rgba(155, 89, 182, 0.3);
}

.badge-grabando {
  background: rgba(229, 62, 62, 0.15);
  color: #fc8181;
  border: 1px solid rgba(229, 62, 62, 0.3);
  animation: pulse 1.8s infinite;
}

.badge-finalizado {
  background: rgba(40, 167, 69, 0.15);
  color: var(--success);
  border: 1px solid rgba(40, 167, 69, 0.3);
}

.badge-error {
  background: rgba(229, 62, 62, 0.15);
  color: var(--danger);
  border: 1px solid rgba(229, 62, 62, 0.3);
}

/* ===== BUTTONS ===== */
.btn {
  padding: 0.45rem 1rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.82rem;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dk);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 136, 255, 0.4);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-warning {
  background: rgba(246, 201, 14, 0.2);
  color: var(--warning);
  border: 1px solid rgba(246, 201, 14, 0.4);
}

.btn-warning:hover:not(:disabled) {
  background: rgba(246, 201, 14, 0.35);
}

.btn-secondary {
  background: rgba(155, 89, 182, 0.2);
  color: #c77dff;
  border: 1px solid rgba(155, 89, 182, 0.4);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(155, 89, 182, 0.35);
  transform: translateY(-1px);
}

/* ===== SPINNER ===== */
.spinner,
.spinner-sm {
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  display: inline-block;
  animation: spin 0.7s linear infinite;
}

.spinner {
  width: 14px;
  height: 14px;
}

.spinner-sm {
  width: 11px;
  height: 11px;
}

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

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-dim);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.empty-state p {
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.empty-state small {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.empty-state code {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
}

/* ===== RIGHT PANEL ===== */
.right-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ===== DRIVES LIST ===== */
.drives-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.drive-card {
  background: #0a0c14;
  border: 1px solid var(--border);
  border-left: 4px solid var(--text-dim);
  border-radius: var(--radius-sm);
  padding: 1rem;
  transition: all 0.2s;
}

.drive-ready {
  border-left-color: var(--success);
}

.drive-data {
  border-left-color: var(--warning);
}

.drive-rw {
  border-left-color: #7c3aed;
  background: linear-gradient(135deg, #0a0c14, #12083a20);
}

.drive-empty {
  border-left-color: #333;
}

.drive-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.drive-letter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 700;
}

.drive-icon {
  font-size: 1.3rem;
}

.drive-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-green {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.dot-yellow {
  background: var(--warning);
  box-shadow: 0 0 8px var(--warning);
}

.dot-gray {
  background: #444;
}

.drive-type {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-bottom: 0.25rem;
}

.drive-cap {
  font-size: 0.7rem;
  color: #4a5560;
  margin-bottom: 0.75rem;
  font-family: 'JetBrains Mono', monospace;
}

/* ===== EJECT BUTTON ===== */
.btn-eject {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  background: linear-gradient(135deg, #1a1f2e, #252c3f);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  transition: all 0.2s;
}

.btn-eject:hover:not(:disabled) {
  background: linear-gradient(135deg, #ff6b00, #ff9d00);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 16px rgba(255, 107, 0, 0.4);
  transform: translateY(-1px);
}

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

.btn-eject-loading {
  background: rgba(255, 107, 0, 0.15);
  color: #ff9d00;
  border-color: rgba(255, 107, 0, 0.3);
}

/* ===== MONITOR GRID ===== */
.monitor-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: #08090f;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
}

.monitor-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.monitor-row:last-child {
  border-bottom: none;
}

.mon-label {
  color: var(--text-dim);
}

.mon-value {
  font-family: 'JetBrains Mono', monospace;
  color: var(--text);
  font-size: 0.72rem;
}

.mon-ok {
  color: var(--success);
}

.mon-err {
  color: var(--danger);
}

.mon-url {
  font-size: 0.65rem;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== ANIMACIONES ===== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== MODAL CONFIGURACION ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  animation: fadeIn 0.2s ease-out;
}

.modal-content {
  background: var(--bg2);
  width: 90%;
  max-width: 550px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  overflow: hidden;
}

.modal-header {
  padding: 1.5rem;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
  transition: color 0.2s;
}

.btn-close:hover {
  color: var(--text);
}

.modal-body {
  padding: 1.5rem;
  max-height: 70vh;
  overflow-y: auto;
}

.config-section {
  margin-bottom: 2rem;
}

.config-section h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 1rem;
  border-left: 3px solid var(--primary);
  padding-left: 0.75rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.form-input,
.form-select {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  padding: 0.75rem;
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus,
.form-select:focus {
  border-color: var(--primary);
}

.toggle-group {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.toggle-info h4 {
  font-size: 0.9rem;
  margin-bottom: 2px;
}

.toggle-info p {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.btn-config {
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s;
}

.btn-config:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.modal-footer {
  padding: 1.25rem 1.5rem;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

/* Switch UI */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #333;
  transition: .4s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked+.slider {
  background-color: var(--primary);
}

input:checked+.slider:before {
  transform: translateX(20px);
}