/* ═══════════════════════════════════════════════════════════════════
   VidSync — Tema oscuro glassmorphism
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --bg-primary:      #0f0f14;
  --bg-secondary:    #1a1a24;
  --bg-glass:        rgba(255,255,255,0.05);
  --bg-glass-hover:  rgba(255,255,255,0.08);
  --border-glass:    rgba(255,255,255,0.10);
  --text-primary:    #f0f0f5;
  --text-secondary:  #8888a0;
  --accent:          #6c5ce7;
  --accent-hover:    #7c6ef7;
  --success:         #00c853;
  --danger:          #ff3d57;
  --warning:         #ffab00;
  --card-blur:       20px;
  --card-radius:     13px;
  --sidebar-width:   192px;
  --header-height:   88px;
}

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

html { font-size: 12.8px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Scrollbar ────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-glass); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Tipografía ───────────────────────────────────────────────────── */
h1,h2,h3,h4,h5,h6 { font-weight: 600; line-height: 1.3; }
a { color: var(--accent); text-decoration: none; transition: color .2s ease; }
a:hover { color: var(--accent-hover); }

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

/* ── Sidebar ──────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  transition: transform .3s ease, width .3s ease;
}

.sidebar-logo {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  gap: .75rem;
  min-height: var(--header-height);
}

.sidebar-logo img { height: 32px; }

.sidebar-logo-text {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
  overflow-y: auto;
}

.sidebar-section {
  padding: .25rem 1rem .5rem;
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-top: .5rem;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem 1.5rem;
  color: var(--text-secondary);
  border-radius: 0;
  transition: all .2s ease;
  font-size: .9rem;
  position: relative;
}

.sidebar-nav a:hover {
  color: var(--text-primary);
  background: var(--bg-glass-hover);
}

.sidebar-nav a.active {
  color: var(--accent);
  background: rgba(108,92,231,0.12);
  font-weight: 500;
}

.sidebar-nav a.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.sidebar-nav .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: .8;
}

/* ── Contenido principal ──────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ───────────────────────────────────────────────────────── */
.header {
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-left { display: flex; align-items: center; gap: 1rem; }
.header-center { display: flex; flex-direction: column; align-items: center; }
.header-right { display: flex; align-items: center; gap: 1rem; }

.header-clock {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
}

.header-date {
  font-size: .75rem;
  color: var(--text-secondary);
  text-transform: capitalize;
}

.header-user {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem .75rem;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  cursor: pointer;
  transition: all .2s ease;
}

.header-user:hover { background: var(--bg-glass-hover); }

.header-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.header-username {
  font-size: .85rem;
  color: var(--text-primary);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-menu {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: .4rem;
}

/* ── Page content ─────────────────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 1.75rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--text-primary);
}

.page-title span {
  color: var(--text-secondary);
  font-weight: 400;
  font-size: 1rem;
  margin-left: .5rem;
}

/* ── Cards ────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-glass);
  backdrop-filter: blur(var(--card-blur));
  -webkit-backdrop-filter: blur(var(--card-blur));
  border: 1px solid var(--border-glass);
  border-radius: var(--card-radius);
  padding: 1.5rem;
  transition: all .2s ease;
}

.card:hover {
  background: var(--bg-glass-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

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

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-subtitle {
  font-size: .8rem;
  color: var(--text-secondary);
  margin-top: .25rem;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.stat-label {
  font-size: .8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(108,92,231,0.15);
  color: var(--accent);
  margin-bottom: .5rem;
}

/* ── Grid ─────────────────────────────────────────────────────────── */
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ── Tablas ───────────────────────────────────────────────────────── */
.table-wrapper {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--card-radius);
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-glass);
}

.table-title {
  font-size: 1rem;
  font-weight: 600;
}

.table-container { overflow-x: auto; }

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

thead th {
  padding: .75rem 1rem;
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border-glass);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: background .15s ease;
}

tbody tr:nth-child(odd) { background: rgba(255,255,255,0.02); }
tbody tr:nth-child(even) { background: rgba(255,255,255,0.04); }
tbody tr:hover { background: var(--bg-glass-hover); }

tbody td {
  padding: .75rem 1rem;
  font-size: .875rem;
  color: var(--text-primary);
  vertical-align: middle;
}

/* ── Badges ───────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .6rem;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.badge-success { background: rgba(0,200,83,.15); color: var(--success); }
.badge-danger  { background: rgba(255,61,87,.15);  color: var(--danger); }
.badge-warning { background: rgba(255,171,0,.15);  color: var(--warning); }
.badge-muted   { background: var(--bg-glass); color: var(--text-secondary); }
.badge-accent  { background: rgba(108,92,231,.2); color: var(--accent); }

/* ── Status DVR ───────────────────────────────────────────────────── */
.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-online {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: pulse-green 2s infinite;
}

.status-offline {
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
}

.status-never {
  background: transparent;
  border: 2px solid rgba(255,255,255,0.4);
}

@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 8px var(--success); }
  50%       { box-shadow: 0 0 16px var(--success), 0 0 24px rgba(0,200,83,.3); }
}

.status-row {
  display: flex;
  align-items: center;
  gap: .5rem;
}

/* ── Formularios ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }

.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: .4rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.form-control {
  width: 100%;
  padding: .65rem 1rem;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: .9rem;
  transition: all .2s ease;
  outline: none;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(108,92,231,0.25);
  background: var(--bg-glass-hover);
}

.form-control::placeholder { color: var(--text-secondary); }

select.form-control option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

/* ── Botones ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  border-radius: 10px;
  font-size: .875rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all .2s ease;
  text-decoration: none;
  white-space: nowrap;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  color: #fff;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(108,92,231,0.4);
  color: #fff;
}

.btn-secondary {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  color: var(--text-primary);
}

.btn-secondary:hover { background: var(--bg-glass-hover); color: var(--text-primary); }

.btn-danger {
  background: rgba(255,61,87,.15);
  border: 1px solid rgba(255,61,87,.3);
  color: var(--danger);
}

.btn-danger:hover { background: rgba(255,61,87,.25); }

.btn-success {
  background: rgba(0,200,83,.15);
  border: 1px solid rgba(0,200,83,.3);
  color: var(--success);
}

.btn-sm { padding: .35rem .7rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }

/* ── Alertas ──────────────────────────────────────────────────────── */
.alert {
  padding: .85rem 1.1rem;
  border-radius: 10px;
  font-size: .875rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: .6rem;
}

.alert-danger  { background: rgba(255,61,87,.12);  border: 1px solid rgba(255,61,87,.25);  color: #ff8097; }
.alert-success { background: rgba(0,200,83,.12);   border: 1px solid rgba(0,200,83,.25);   color: #4dda8e; }
.alert-warning { background: rgba(255,171,0,.12);  border: 1px solid rgba(255,171,0,.25);  color: #ffc53d; }

/* ── Barra de progreso ────────────────────────────────────────────── */
.progress {
  width: 100%;
  height: 8px;
  background: var(--bg-glass);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border-glass);
}

.progress-bar {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  transition: width .4s ease;
}

.progress-bar.danger { background: linear-gradient(90deg, var(--danger), #ff6b7a); }
.progress-bar.warning { background: linear-gradient(90deg, var(--warning), #ffd04d); }

/* ── Color picker ─────────────────────────────────────────────────── */
.color-input-row {
  display: flex;
  align-items: center;
  gap: .75rem;
}

input[type="color"] {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  background: none;
  cursor: pointer;
  padding: 2px;
}

/* ── Login ────────────────────────────────────────────────────────── */
.login-bg {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
}

.login-bg::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(108,92,231,.15) 0%, transparent 70%);
  top: -200px; left: -200px;
  pointer-events: none;
}

.login-bg::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(108,92,231,.1) 0%, transparent 70%);
  bottom: -100px; right: -100px;
  pointer-events: none;
}

.login-card {
  width: 100%;
  max-width: 420px;
  margin: 1rem;
  background: var(--bg-glass);
  backdrop-filter: blur(var(--card-blur));
  -webkit-backdrop-filter: blur(var(--card-blur));
  border: 1px solid var(--border-glass);
  border-radius: 24px;
  padding: 2.5rem;
  position: relative;
  z-index: 1;
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo img { height: 44px; }

.login-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: .4rem;
}

.login-subtitle {
  font-size: .85rem;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 2rem;
}

/* ── Reproductor HLS ──────────────────────────────────────────────── */
.player-wrapper {
  background: #000;
  border: 1px solid var(--border-glass);
  border-radius: var(--card-radius);
  overflow: hidden;
  aspect-ratio: 16/9;
  position: relative;
}

.player-wrapper video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .75rem 1rem;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: 0 0 var(--card-radius) var(--card-radius);
  flex-wrap: wrap;
}

/* ── Calendario ───────────────────────────────────────────────────── */
.calendar-wrapper {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--card-radius);
  padding: 1rem;
}

/* ── Dropdown user menu ───────────────────────────────────────────── */
.user-menu {
  position: relative;
}

.user-menu-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  min-width: 160px;
  padding: .5rem 0;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
  z-index: 200;
}

.user-menu.open .user-menu-dropdown { display: block; }

.user-menu-dropdown a {
  display: block;
  padding: .55rem 1rem;
  color: var(--text-secondary);
  font-size: .85rem;
  transition: all .15s ease;
}

.user-menu-dropdown a:hover { background: var(--bg-glass); color: var(--text-primary); }

/* ── Sidebar overlay mobile ───────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 99;
}

/* ── Utilidades ───────────────────────────────────────────────────── */
.text-muted   { color: var(--text-secondary); }
.text-accent  { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-sm      { font-size: .8rem; }
.text-xs      { font-size: .7rem; }
.fw-bold      { font-weight: 700; }
.d-flex       { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1  { gap: .25rem; }
.gap-2  { gap: .5rem; }
.gap-3  { gap: .75rem; }
.gap-4  { gap: 1rem; }
.mb-1   { margin-bottom: .25rem; }
.mb-2   { margin-bottom: .5rem; }
.mb-3   { margin-bottom: .75rem; }
.mb-4   { margin-bottom: 1rem; }
.mb-6   { margin-bottom: 1.5rem; }
.mt-4   { margin-top: 1rem; }
.w-100  { width: 100%; }
.flex-1 { flex: 1; }
.divider {
  border: none;
  border-top: 1px solid var(--border-glass);
  margin: 1rem 0;
}

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }

  .sidebar {
    transform: translateX(-192px);
    width: 192px;
  }

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

  .sidebar-overlay.open { display: block; }

  .main-content { margin-left: 0; }

  .btn-menu { display: flex; }

  .header-center { display: none; }

  .grid-4,
  .grid-3,
  .grid-2 { grid-template-columns: 1fr; }

  .page-content { padding: 1rem; }

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

  .table-container { overflow-x: auto; }

  thead th, tbody td { padding: .5rem .75rem; }
}

/* ── Tabla de consumo ────────────────────────────────────────────────────────── */
.consumption-table td.num,
.consumption-table th.num {
  text-align: right;
}

.consumption-table td.num input[type="number"] {
  text-align: right;
  font-family: 'Courier New', monospace;
  font-variant-numeric: tabular-nums;
}
