/* Security Camera Gallery – dark mode */

:root {
  --bg: #0d0d0d;
  --bg-elevated: #1a1a1a;
  --bg-card: #242424;
  --bg-page: #0d0d0d; /* text on accent (e.g. active button) */
  --text: #e5e5e5;
  --text-muted: #a3a3a3;
  --accent: #22c55e;
  --accent-hover: #16a34a;
  --border: #333;
  --overlay: rgba(0, 0, 0, 0.85);
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  --transition: 0.2s ease;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

/* Header */
.header {
  margin-bottom: 1.5rem;
}

.header__title {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

/* Breadcrumb */
.breadcrumb {
  margin-bottom: 1.5rem;
}

.breadcrumb__list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.9rem;
}

.breadcrumb__item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.breadcrumb__item:not(:last-child)::after {
  content: '›';
  color: var(--text-muted);
  font-weight: 300;
}

.breadcrumb__link {
  color: var(--accent);
  text-decoration: none;
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}

.breadcrumb__link:hover {
  background: var(--bg-elevated);
  color: var(--accent-hover);
}

.breadcrumb__current {
  color: var(--text-muted);
  padding: 0.2rem 0.4rem;
}

.station-stats {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
  padding: 0.5rem 0;
}

/* Main */
.main {
  position: relative;
  min-height: 200px;
}

/* Folders */
.folders {
  margin-bottom: 2rem;
}

.folders__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
}

.folder-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
  min-height: 120px;
}

.folder-card__lock {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.folder-card:hover {
  border-color: var(--accent);
  background: var(--bg-elevated);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.folder-card__icon {
  width: 48px;
  height: 48px;
  color: var(--accent);
  flex-shrink: 0;
}

.folder-card__name {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 500;
  text-align: center;
  word-break: break-all;
}

.folder-card__stats {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.3;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Gallery */
.gallery {
  position: relative;
}

.gallery__toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.gallery__toolbar[hidden] {
  display: none;
}

.gallery__view-label {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.gallery__view-toggle {
  display: flex;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}

.gallery__view-btn {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
}

.gallery__view-btn:hover {
  color: var(--text);
  background: var(--bg-card);
}

.gallery__view-btn.active {
  color: var(--bg-page);
  background: var(--accent);
}

.gallery__pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.25rem;
  padding: 0.5rem 0;
}

.gallery__pagination[hidden] {
  display: none;
}

.gallery__page-btn {
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  font-family: inherit;
  font-weight: 500;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}

.gallery__page-btn:hover:not(:disabled) {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--bg-elevated);
}

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

.gallery__page-info {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.gallery__page-sep {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0.25rem;
}

.gallery__page-nums {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.gallery__page-num {
  padding: 0;
  margin: 0;
  font-size: inherit;
  font-family: inherit;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: none;
}

.gallery__page-num:hover {
  text-decoration: underline;
}

.gallery__page-num--current {
  color: var(--text);
  font-weight: 600;
  cursor: default;
}

.gallery__page-arrow {
  padding: 0 0.25rem;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
}

.gallery__page-arrow:hover:not(:disabled) {
  color: var(--accent-hover);
}

.gallery__page-arrow:disabled {
  color: var(--text-muted);
  opacity: 0.6;
  cursor: not-allowed;
}

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

.gallery__grid--list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.gallery__grid--list .gallery-item {
  flex-direction: row;
}

.gallery__grid--list .gallery-item__media {
  width: 140px;
  min-width: 140px;
  flex-shrink: 0;
  aspect-ratio: 16 / 10;
}

.gallery__grid--list .gallery-item__meta {
  flex: 1;
  min-width: 0;
  justify-content: center;
}

.gallery-item {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color var(--transition);
}

.gallery-item:hover {
  border-color: var(--accent);
}

.gallery-item__media {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--bg-elevated);
}

.gallery-item__thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-item__video-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
}

.gallery-item__video-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gallery-item__play-overlay {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  color: var(--accent);
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.5));
  flex-shrink: 0;
  pointer-events: none;
}

.gallery-item__play {
  width: 56px;
  height: 56px;
  color: var(--accent);
  flex-shrink: 0;
}

.gallery-item__meta {
  padding: 0.25rem 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
}

.gallery-item__label {
  font-size: 0.8rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gallery-item__datetime {
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gallery-item__size,
.gallery-item__size-duration {
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Empty */
.empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty__text {
  margin: 0;
  font-size: 1rem;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--overlay);
  padding: 2rem;
}

.lightbox[hidden] {
  display: none;
}

/* Station password modal card */
.station-password-card {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 400px;
  width: 100%;
  z-index: 1001;
}

.station-password-title {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}

.station-password-hint {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.station-password-error {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  background: rgba(185, 28, 28, 0.15);
  border: 1px solid rgba(185, 28, 28, 0.4);
  border-radius: var(--radius-sm);
  color: #fca5a5;
  font-size: 0.9rem;
  line-height: 1.4;
}

.station-password-error[hidden] {
  display: none;
}

.station-password-label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.station-password-card input[type="password"] {
  width: 100%;
  padding: 0.6rem;
  margin-bottom: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
}

.station-password-actions {
  display: flex;
  gap: 0.75rem;
}

.station-password-btn {
  padding: 0.6rem 1.25rem;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition);
}

.station-password-btn:hover {
  background: var(--accent-hover);
}

.station-password-btn.secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}

.station-password-btn.secondary:hover {
  background: var(--border);
}

.lightbox__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 48px;
  height: 48px;
  padding: 0;
  border: none;
  background: var(--bg-card);
  color: var(--text);
  font-size: 2rem;
  line-height: 1;
  border-radius: 50%;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  z-index: 1002;
}

.lightbox__close:hover {
  background: var(--accent);
  color: var(--bg);
}

.lightbox__prev,
.lightbox__next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 56px;
  height: 56px;
  padding: 0;
  border: none;
  background: var(--bg-card);
  color: var(--text);
  font-size: 2.5rem;
  line-height: 1;
  border-radius: 50%;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  z-index: 1002;
}

.lightbox__prev {
  left: 1rem;
}

.lightbox__next {
  right: 1rem;
}

.lightbox__prev:hover,
.lightbox__next:hover {
  background: var(--accent);
  color: var(--bg);
}

.lightbox__content {
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
}

.lightbox__content img {
  max-width: 100%;
  max-height: 85vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.lightbox__content video {
  max-width: 100%;
  max-height: 85vh;
  width: auto;
  border-radius: var(--radius-sm);
}

.lightbox__caption {
  margin-top: 1rem;
  padding: 0.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  max-width: 90vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Responsive */
@media (max-width: 640px) {
  .app {
    padding: 1rem 0.75rem 2rem;
  }

  .folders__grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }

  .gallery__grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
  }

  .lightbox__prev,
  .lightbox__next {
    width: 44px;
    height: 44px;
    font-size: 1.75rem;
  }

  .lightbox__prev {
    left: 0.5rem;
  }

  .lightbox__next {
    right: 0.5rem;
  }
}
