:root {
  --app-bg: #0b0d12;
  --app-surface: #131722;
  --app-surface-2: #1a2030;
  --app-border: #262e40;
  --app-text: #e7ebf3;
  --app-muted: #99a3b8;
  --app-accent: #7c5cff;
  --app-accent-2: #00c2ff;
  --app-danger: #ff5d73;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--app-text);
  background:
    radial-gradient(1000px 500px at 10% -10%, rgba(124, 92, 255, 0.18), transparent 60%),
    radial-gradient(800px 400px at 100% 0%, rgba(0, 194, 255, 0.10), transparent 55%),
    var(--app-bg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.app-navbar {
  background: rgba(11, 13, 18, 0.88);
  backdrop-filter: blur(12px);
}

.brand-icon {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: #fff;
  font-size: 1.9rem;
  background: linear-gradient(135deg, var(--app-accent), var(--app-accent-2));
  box-shadow: 0 12px 40px rgba(124, 92, 255, 0.35);
}

.brand-icon-sm {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 1rem;
  box-shadow: 0 6px 20px rgba(124, 92, 255, 0.25);
}

.login-page {
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.login-wrapper { width: min(440px, 100%); }

.login-card {
  background: linear-gradient(180deg, rgba(26, 32, 48, 0.96), rgba(17, 21, 31, 0.98));
  border: 1px solid var(--app-border) !important;
  border-radius: 22px;
}

.login-card .form-control,
.login-card .input-group-text {
  background: #0f131d;
  border-color: var(--app-border);
  color: var(--app-text);
}

.dashboard-page { padding-bottom: 2rem; }

.stat-card,
.filter-card,
.system-panel,
.clip-card {
  background: linear-gradient(180deg, rgba(26, 32, 48, 0.85), rgba(17, 21, 31, 0.92));
  border: 1px solid var(--app-border);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.stat-card .card-body { padding: 1rem 1.15rem; }

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  color: var(--app-accent-2);
  background: rgba(0, 194, 255, 0.10);
  flex: 0 0 auto;
}

.stat-value { font-size: 1.45rem; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--app-muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }

.filter-card .form-control,
.filter-card .form-select,
.filter-card .input-group-text {
  background: #0f131d;
  border-color: var(--app-border);
  color: var(--app-text);
}

.clip-card {
  overflow: hidden;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.clip-card:hover {
  transform: translateY(-2px);
  border-color: rgba(124, 92, 255, 0.55);
}

.clip-preview {
  position: relative;
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  background:
    radial-gradient(300px 160px at 50% 0%, rgba(124, 92, 255, 0.28), transparent 70%),
    linear-gradient(135deg, #151a27, #0c0f17);
  border-bottom: 1px solid var(--app-border);
}

.clip-preview .bi-camera-video {
  font-size: 2.4rem;
  color: rgba(231, 235, 243, 0.28);
}

.clip-preview .btn-play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 1.4rem;
  padding: 0;
  box-shadow: 0 8px 26px rgba(124, 92, 255, 0.45);
}

.clip-card .duration-badge {
  position: absolute;
  right: 0.6rem;
  bottom: 0.6rem;
  background: rgba(0, 0, 0, 0.72);
}

.clip-card .card-body { padding: 0.9rem 1rem 1rem; }

.clip-title {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.25;
  margin: 0 0 0.55rem;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  min-height: 2.4em;
}

.clip-date { font-size: 0.82rem; color: var(--app-muted); }

.clip-video {
  max-height: 70vh;
  background: #000;
}

.player-details {
  border-top: 1px solid var(--app-border);
  background: var(--app-surface);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--app-border);
  color: var(--app-muted);
  font-weight: 500;
}

.status-badge .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #6c757d;
}

.status-badge.is-online { color: #8ef0c0; border-color: rgba(25, 200, 120, 0.35); }
.status-badge.is-online .status-dot { background: #19c878; box-shadow: 0 0 10px #19c878; }
.status-badge.is-offline { color: #ff9aa8; border-color: rgba(255, 93, 115, 0.35); }
.status-badge.is-offline .status-dot { background: var(--app-danger); }

.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  border: 1px dashed var(--app-border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.015);
}

.empty-state .bi { font-size: 3rem; color: var(--app-muted); }

.pagination .page-link {
  background: var(--app-surface);
  border-color: var(--app-border);
  color: var(--app-text);
}

.pagination .page-item.active .page-link {
  background: var(--app-accent);
  border-color: var(--app-accent);
}

.toast { border: 1px solid var(--app-border); }

@media (max-width: 575.98px) {
  .stat-card .card-body { padding: 0.8rem; gap: 0.65rem !important; }
  .stat-icon { width: 36px; height: 36px; font-size: 1rem; }
  .stat-value { font-size: 1.15rem; }
  .stat-label { font-size: 0.68rem; }
}

/* Editor de timeline */
.trim-stage {
  position: relative;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
}

.trim-video {
  max-height: 46vh;
  background: #000;
  display: block;
}

.trim-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--app-text);
  background: rgba(0, 0, 0, 0.68);
  font-size: 0.9rem;
  gap: 0.25rem;
}

.timeline-track {
  position: relative;
  height: 46px;
  border-radius: 10px;
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,0.05) 0 1px, transparent 1px 10%),
    linear-gradient(180deg, #1a2030, #0f131d);
  border: 1px solid var(--app-border);
  cursor: pointer;
  touch-action: none;
  user-select: none;
}

.timeline-selection {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(124, 92, 255, 0.32);
  border-left: 2px solid rgba(124, 92, 255, 0.9);
  border-right: 2px solid rgba(124, 92, 255, 0.9);
  pointer-events: none;
}

.timeline-playhead {
  position: absolute;
  top: -5px;
  bottom: -5px;
  width: 2px;
  margin-left: -1px;
  background: #fff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
  left: 0;
  pointer-events: none;
  z-index: 3;
}

.timeline-handle {
  position: absolute;
  top: 50%;
  width: 18px;
  height: 38px;
  padding: 0;
  transform: translate(-50%, -50%);
  border-radius: 7px;
  border: 2px solid #fff;
  background: var(--app-accent);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  cursor: ew-resize;
  z-index: 4;
}

.timeline-handle:focus-visible {
  outline: 2px solid var(--app-accent-2);
  outline-offset: 2px;
}

#trim-start-handle { left: 0; }
#trim-end-handle { left: 100%; }

@media (max-width: 575.98px) {
  .timeline-track { height: 38px; }
  .timeline-handle { width: 16px; height: 32px; }
}
