/* ── Reset & base ─────────────────────────────────────────────────────────── */

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

/* Ensure the HTML hidden attribute is never overridden by display: flex/grid rules */
[hidden] { display: none !important; }

:root {
  --bg:          #0b111e;
  --surface:     #111827;
  --surface2:    #1e293b;
  --border:      #1e2d40;
  --text:        #e2e8f0;
  --text-muted:  #64748b;
  --accent:      #38bdf8;
  --danger:      #f87171;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* ── Dashboard ────────────────────────────────────────────────────────────── */

#dashboard {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

.dash-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dash-logo {
  font-size: 20px;
  color: var(--accent);
}

.dash-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
}

.dash-subtitle {
  color: var(--text-muted);
  font-size: 12px;
  border-left: 1px solid var(--border);
  padding-left: 10px;
}

.dash-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.dash-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 6px #4ade80aa;
  animation: pulse 2s ease-in-out infinite;
}

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

/* The boring button — blends in, doesn't invite clicking */
.boring-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: color 0.15s, border-color 0.15s;
}
.boring-btn:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 260px);
  gap: 16px;
  padding: 20px 24px;
}

@media (max-width: 700px) {
  .charts-grid {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(4, 220px);
  }
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
}

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

.chart-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.chart-unit {
  font-size: 11px;
  color: var(--text-muted);
}

.chart-card canvas {
  flex: 1;
  min-height: 0;
}

.dash-footer {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  padding: 12px;
  border-top: 1px solid var(--border);
}

/* ── Password modal ───────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(3px);
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px 32px;
  width: min(380px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
}

.modal-desc {
  font-size: 13px;
  color: var(--text-muted);
}

.pw-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
.pw-input:focus { border-color: var(--accent); }

.pw-error {
  font-size: 12px;
  color: var(--danger);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.btn-primary {
  background: var(--accent);
  color: #0b111e;
  border: none;
  border-radius: 6px;
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.85; }

.btn-secondary {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-secondary:hover { border-color: var(--text-muted); color: var(--text); }

/* ── Gallery ──────────────────────────────────────────────────────────────── */

#gallery {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.gallery-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.gallery-back-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 0;
  transition: color 0.15s;
}
.gallery-back-btn:hover { color: var(--text); }

.gallery-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 16px;
}

@media (max-width: 700px) {
  .gallery-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 400px) {
  .gallery-grid { grid-template-columns: 1fr; }
}

/* Gallery media container */
.gallery-media-container {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--surface2);
  border-radius: 2px;
  cursor: pointer;
  border: 1px solid transparent;
}

.gallery-media-container:focus-visible {
  outline: none;
  border-color: var(--accent);
}

/* Gallery media (images and videos) */
.gallery-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.15s, transform 0.15s;
}
.gallery-media:hover {
  opacity: 0.85;
  transform: scale(1.01);
}

.gallery-media-container.is-video::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.58);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.24);
  pointer-events: none;
}

.gallery-media-container.is-video::before {
  content: '';
  position: absolute;
  left: calc(50% + 3px);
  top: 50%;
  width: 0;
  height: 0;
  transform: translate(-50%, -50%);
  border-top: 11px solid transparent;
  border-bottom: 11px solid transparent;
  border-left: 16px solid rgba(255, 255, 255, 0.92);
  z-index: 1;
  pointer-events: none;
}

/* Video-specific styling in gallery */
.gallery-media[controls] {
  object-fit: contain;
  background: #000;
}

/* Sentinel, end, and loading */
.gallery-sentinel {
  height: 1px;
}

.gallery-end {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 24px;
  letter-spacing: 0.1em;
}

.gallery-loading {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 20px;
}

/* ── Fullscreen overlay ───────────────────────────────────────────────────── */

.fs-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: none;   /* we handle all touch ourselves */
  overflow: hidden;
}

.fs-overlay.is-zoomed {
  cursor: grab;
}

.fs-overlay.is-panning {
  cursor: grabbing;
}

.fs-close {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 201;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.52);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.fs-close:hover,
.fs-close:focus-visible {
  background: rgba(255, 255, 255, 0.16);
  outline: none;
}

/* Fullscreen media container */
.fs-media-container {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Fullscreen media (images and videos) */
.fs-media {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
  transform-origin: center center;
  transition: transform 0.08s ease-out;
  will-change: transform;
}

.fs-overlay.is-panning .fs-media {
  transition: none;
}

/* Video-specific styling in fullscreen */
.fs-media[controls] {
  object-fit: contain;
  background: #000;
  pointer-events: auto;
}
