/* ==========================================================================
   ViswaNVR Dark-Themed Unified Stylesheet (Tailwind Complement)
   ========================================================================== */

:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --bg-hover: #334155;
  --border-color: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --primary-glow: rgba(56, 189, 248, 0.25);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

/* Base resets & scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #0b1120;
}
::-webkit-scrollbar-thumb {
  background: #27354a;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #38bdf8;
}

/* ==========================================================================
   Camera Cards & Grid Standard 16:9
   ========================================================================== */
.camera-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.camera-card:hover {
  border-color: #0284c7;
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.25);
}

.camera-card-header {
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.7);
  border-bottom: 1px solid #334155;
  z-index: 10;
}

.camera-info {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.camera-info .cam-name {
  font-weight: 600;
  font-size: 13px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Standardized 16:9 Video Box (Identical for all cameras) */
.camera-view-box {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-canvas, .camera-video, .camera-img {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  object-fit: fill !important;
  display: block;
}

.camera-overlay {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  gap: 6px;
  z-index: 5;
  pointer-events: none;
}

.rec-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(239, 68, 68, 0.9);
  color: #fff;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  animation: pulse 1.5s infinite;
}

.rec-dot {
  width: 5px;
  height: 5px;
  background: #fff;
  border-radius: 50%;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.camera-card-footer {
  padding: 7px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.5);
  border-top: 1px solid #334155;
  font-size: 11px;
}

/* ==========================================================================
   Badges
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-rec {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.badge-online {
  background: rgba(14, 165, 233, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(14, 165, 233, 0.4);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

/* ==========================================================================
   Timeline 24 Jam & Zoom
   ========================================================================== */
.timeline-track {
  position: relative;
  user-select: none;
  touch-action: none;
}

.timeline-track.grabbing {
  cursor: grabbing !important;
}

.timeline-hours-markers {
  position: relative;
  width: 100%;
}

.timeline-hour-mark {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.timeline-hour-mark.mark-start {
  transform: translateX(0);
}

.timeline-hour-mark.mark-end {
  transform: translateX(-100%);
}

.timeline-segment-block {
  position: absolute;
  top: 3px;
  bottom: 3px;
  background: #0284c7;
  border-radius: 3px;
  transition: background 0.15s;
}

.timeline-segment-block:hover {
  background: #38bdf8;
}

.timeline-cursor {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #ef4444;
  z-index: 10;
  pointer-events: none;
}

.timeline-cursor::after {
  content: "";
  position: absolute;
  top: 0;
  left: -4px;
  width: 10px;
  height: 6px;
  background: #ef4444;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.timeline-tooltip {
  display: none;
  position: absolute;
  background: #000;
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-family: ui-monospace, monospace;
  pointer-events: none;
  transform: translateX(-50%);
  bottom: -22px;
  border: 1px solid #334155;
  z-index: 20;
}

/* Recording list items */
.recording-item {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s;
  cursor: pointer;
}

.recording-item:hover {
  background: rgba(30, 41, 59, 0.9);
  border-color: #0284c7;
}

.recording-item.active {
  background: rgba(14, 165, 233, 0.15);
  border-color: #38bdf8;
}

/* ==========================================================================
   Single Live View & Stream Quality Switchers
   ========================================================================== */
.quality-switch {
  display: inline-flex;
  align-items: center;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}

.quality-switch button {
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  color: #94a3b8;
  background: transparent;
  transition: all 0.15s ease;
}

.quality-switch button:hover {
  color: #fff;
}

.quality-switch button.active {
  background: #0284c7;
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.single-live-container {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
}

.single-live-container:fullscreen {
  border-radius: 0;
  border: none;
  background: #000;
  width: 100vw;
  height: 100vh;
}

.single-video-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.single-live-container:fullscreen .single-video-stage {
  height: 100vh;
  aspect-ratio: unset;
}

.single-video-stage .camera-canvas,
.single-video-stage .camera-video {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  object-fit: fill !important;
}

/* Custom Calendar Popover */
.bg-dark-850 {
  background-color: #172033;
}
.border-dark-750 {
  border-color: #243044;
}
.calendar-day-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 32px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  color: #cbd5e1;
  background: transparent;
  transition: all 0.15s ease;
  position: relative;
  cursor: pointer;
}
.calendar-day-btn:hover {
  background: #334155;
  color: #fff;
}
.calendar-day-btn.selected {
  background: #0ea5e9 !important;
  color: #fff !important;
  font-weight: 700;
  box-shadow: 0 0 10px rgba(14, 165, 233, 0.4);
}
.calendar-day-btn.today {
  border: 1px solid #38bdf8;
}
.calendar-day-btn.other-month {
  color: #475569;
  cursor: default;
}
.calendar-day-btn.other-month:hover {
  background: transparent;
}
.calendar-day-dot {
  width: 5px;
  height: 5px;
  border-radius: 9999px;
  background-color: #22d3ee;
  box-shadow: 0 0 6px #06b6d4;
  margin-top: 1px;
}
.calendar-day-btn.selected .calendar-day-dot {
  background-color: #fff;
  box-shadow: 0 0 6px #fff;
}

/* Calendar Date Input Styling */
input[type="date"]::-webkit-calendar-picker-indicator {
  display: none !important;
  -webkit-appearance: none;
}

/* ==========================================================================
   Mobile-Friendly Compact Adjustments
   ========================================================================== */
@media (max-width: 768px) {
  /* Minimal header spacing */
  .app-header {
    padding: 6px 10px !important;
  }
  
  /* Segment tabs tight pill button */
  .nav-btn {
    padding: 6px 10px !important;
    font-size: 11px !important;
  }

  /* Keep video box 16:9 on phone screen */
  .camera-view-box {
    aspect-ratio: 16 / 9;
  }
}
