﻿/* ================================================
   MEDIA LIBRARY PAGE — PREP
   ================================================ */
:root {
  --color-primary: #5a189a;
  --color-secondary: #ffc300;
  --color-background: #f4f7f9;
  --color-text: #333333;
  --color-soft-gray: #6b7280;
  --color-error: #dc3545;
  --bg-body: var(--color-background);

  /* Glass variables */
  --bg-glass-panel: rgba(255, 255, 255, 0.55);
  --bg-glass-card: rgba(255, 255, 255, 0.6);
  --bg-input: rgba(255, 255, 255, 0.8);
  --border-glass: rgba(255, 255, 255, 0.7);
  --border-color: rgba(192, 192, 192, 0.5);
  --shadow-glass: 0 8px 32px rgba(90, 24, 154, 0.12), 0 2px 8px rgba(0,0,0,0.06);
  --shadow-card: 0 4px 16px rgba(90, 24, 154, 0.08), 0 1px 4px rgba(0,0,0,0.04);
  --glass-blur: blur(18px) saturate(180%);

  --font-family-sans: 'Poppins', system-ui, -apple-system, sans-serif;
  --border-radius-lg: 16px;
}

body.dark {
  --bg-body: #050505;
  --bg-glass-panel: rgba(15, 10, 25, 0.65);
  --bg-glass-card: rgba(20, 15, 35, 0.6);
  --bg-input: rgba(30, 25, 45, 0.75);
  --color-text: #ffffff;
  --color-soft-gray: #a3a3a3;
  --border-glass: rgba(90, 24, 154, 0.35);
  --border-color: rgba(90, 24, 154, 0.3);
  --color-secondary: #ffd60a;
  --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(90, 24, 154, 0.15);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-family-sans);
  background: var(--bg-body);
  color: var(--color-text);
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
  position: relative;
}

/* Ambient gradient background — matches dashboard */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 15% 10%, rgba(90,24,154,0.28) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 80%, rgba(255,195,0,0.22) 0%, transparent 50%),
    radial-gradient(ellipse at 60% 30%, rgba(79,172,254,0.15) 0%, transparent 45%),
    radial-gradient(ellipse at 30% 70%, rgba(90,24,154,0.12) 0%, transparent 40%);
  pointer-events: none;
  z-index: 0;
}

/* ── Page container ── */
.media-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 16px 110px;
  position: relative;
  z-index: 1;
}

/* ── Header ── */
.media-header {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
  padding: 16px 20px;
  background: var(--bg-glass-panel);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-glass);
  border-radius: 20px;
  box-shadow: var(--shadow-glass);
}

.media-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.media-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-primary);
  display: flex;
  align-items: center;
}

body.dark .media-header h1 { color: var(--color-text); }

/* ── In-header storage bar ── */
.header-storage {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.header-storage-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.header-storage-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

body.dark .header-storage-label { color: var(--color-secondary); }

.header-storage-text {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-soft-gray);
  white-space: nowrap;
}

.header-storage-hint {
  font-size: 0.75rem;
  margin-left: auto;
}

.header-storage-hint a {
  color: #ff6500;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.header-storage-hint a:hover { text-decoration: underline; }

.header-storage-track {
  width: 100%;
  height: 6px;
  background: rgba(90, 24, 154, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

body.dark .header-storage-track {
  background: rgba(255, 255, 255, 0.08);
}

.header-storage-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--color-primary), #9d4edd);
  transition: width 0.6s ease, background 0.4s ease;
  width: 0%;
}

.header-storage-fill.storage-fill-warning {
  background: linear-gradient(90deg, #ff9800, #f44336);
}

.header-storage-fill.storage-fill-critical {
  background: #f44336;
}

body.dark .header-storage-fill {
  background: linear-gradient(90deg, var(--color-secondary), #ff9800);
}

body.dark .header-storage-fill.storage-fill-warning,
body.dark .header-storage-fill.storage-fill-critical {
  background: linear-gradient(90deg, #ff9800, #f44336);
}

/* warning/critical tints on the header border */
.media-header.storage-warning {
  border-color: rgba(255, 152, 0, 0.45);
}

.media-header.storage-critical {
  border-color: rgba(220, 53, 69, 0.45);
}

.media-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  background: rgba(90, 24, 154, 0.1);
  color: var(--color-primary);
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 11px;
  padding: 0 7px;
  margin-left: 8px;
}

body.dark .media-count {
  background: rgba(255, 214, 10, 0.1);
  color: var(--color-secondary);
}

.icon-tool-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border-glass);
  background: var(--bg-glass-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--color-soft-gray);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.icon-tool-btn:hover {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

body.dark .icon-tool-btn:hover {
  background: var(--color-secondary);
  color: #3E1F47;
  border-color: var(--color-secondary);
}

/* ── Toolbar ── */
.media-toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  align-items: center;
  padding: 14px 16px;
  background: var(--bg-glass-panel);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-glass);
  border-radius: 18px;
  box-shadow: var(--shadow-card);
}

.media-search-wrap {
  flex: 1;
  min-width: 180px;
  display: flex;
  align-items: center;
  background: var(--bg-glass-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-glass);
  border-radius: 50px;
  padding: 0 14px;
  height: 44px;
  gap: 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.media-search-wrap:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(90, 24, 154, 0.08);
}

.media-search-wrap i { color: var(--color-soft-gray); font-size: 0.9rem; }

.media-search-wrap input {
  border: none;
  background: transparent;
  flex: 1;
  font-size: 0.9rem;
  color: var(--color-text);
  outline: none;
  font-family: var(--font-family-sans);
}

.media-search-wrap input::placeholder { color: var(--color-soft-gray); }

.media-filter {
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border-glass);
  border-radius: 50px;
  background: var(--bg-glass-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--color-text);
  font-family: var(--font-family-sans);
  font-size: 0.88rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.media-filter:focus { border-color: var(--color-primary); }

.view-toggle-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border-glass);
  background: var(--bg-glass-card);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--color-soft-gray);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.view-toggle-btn:hover {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

body.dark .view-toggle-btn:hover {
  background: var(--color-secondary);
  color: #3E1F47;
}

/* ── Stats bar ── */
.media-stats {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.stat-chip {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  background: rgba(90, 24, 154, 0.08);
  color: var(--color-primary);
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
}

.stat-chip:hover, .stat-chip.active {
  background: var(--color-primary);
  color: white;
}

body.dark .stat-chip {
  background: rgba(255, 214, 10, 0.08);
  color: var(--color-secondary);
}

body.dark .stat-chip:hover, body.dark .stat-chip.active {
  background: var(--color-secondary);
  color: #3E1F47;
}

/* ── Media grid ── */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

@media (max-width: 768px) {
  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
  }
}

/* ── Media card ── */
.media-card {
  background: var(--bg-glass-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.media-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(90, 24, 154, 0.08);
  border-color: rgba(90, 24, 154, 0.25);
}

body.dark .media-card:hover {
  border-color: rgba(255, 214, 10, 0.2);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.media-card-image {
  position: relative;
  width: 100%;
  padding-top: 75%; /* 4:3 aspect ratio */
  background: var(--bg-body);
  overflow: hidden;
}

.media-card-image img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-card-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  opacity: 0;
  transition: opacity 0.2s;
}

.media-card:hover .media-card-overlay {
  opacity: 1;
}

.media-card-action {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: white;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.15s;
}

.media-card-action:hover {
  transform: scale(1.1);
}

.media-card-action--delete {
  background: #dc3545;
  color: white;
}

.media-card-action--delete:hover {
  background: #c82333;
}

.media-card-info {
  padding: 12px;
}

.media-card-name {
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--color-soft-gray);
  flex-wrap: wrap;
}

.media-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 8px;
  background: rgba(90, 24, 154, 0.08);
  color: var(--color-primary);
  font-weight: 600;
  font-size: 0.7rem;
}

body.dark .media-type-badge {
  background: rgba(255, 214, 10, 0.08);
  color: var(--color-secondary);
}

.media-project-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--color-soft-gray);
  margin-top: 4px;
}

/* ── List view ── */
.media-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.media-list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-glass-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.media-list-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(90, 24, 154, 0.08);
  border-color: rgba(90, 24, 154, 0.25);
}

.media-list-thumb {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-body);
}

.media-list-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-list-info {
  flex: 1;
  min-width: 0;
}

.media-list-name {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-list-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.75rem;
  color: var(--color-soft-gray);
  flex-wrap: wrap;
}

.media-list-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.media-action-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-body);
  color: var(--color-soft-gray);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.media-action-btn:hover {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

.media-action-btn--delete {
  color: #dc3545;
  border-color: rgba(220, 53, 69, 0.3);
}

.media-action-btn--delete:hover {
  background: #dc3545;
  color: white;
  border-color: #dc3545;
}

body.dark .media-action-btn:hover {
  background: var(--color-secondary);
  color: #3E1F47;
}

/* ── Empty state ── */
.media-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-soft-gray);
}

.media-empty i {
  font-size: 3rem;
  opacity: 0.3;
  margin-bottom: 16px;
  display: block;
}

.media-empty p {
  font-size: 0.95rem;
  margin-bottom: 20px;
}

.media-empty button {
  background: var(--color-primary);
  color: white;
  border: none;
  padding: 11px 22px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-family-sans);
  font-size: 0.9rem;
  transition: background 0.2s;
}

.media-empty button:hover { background: #4a148c; }

body.dark .media-empty button {
  background: var(--color-secondary);
  color: #3E1F47;
}

/* ── Loading ── */
.media-loading {
  text-align: center;
  padding: 40px;
  color: var(--color-soft-gray);
  font-size: 0.9rem;
}

/* ── Modal ── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.open { display: flex; }

.media-modal {
  background: var(--bg-glass-panel);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modal-in 0.22s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.media-modal--view {
  max-width: 700px;
}

.media-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border-color);
}

.media-modal-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-primary);
}

body.dark .media-modal-header h2 { color: var(--color-secondary); }

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-soft-gray);
  font-size: 1rem;
  transition: background 0.15s;
}

.modal-close:hover { background: rgba(0,0,0,0.06); }

.media-modal-body { padding: 20px 22px; }

/* ── Upload tabs ── */
.upload-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  background: var(--bg-body);
  border-radius: 12px;
  padding: 4px;
}

.upload-tab {
  flex: 1;
  padding: 9px 14px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--color-soft-gray);
  font-family: var(--font-family-sans);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background 0.15s, color 0.15s;
}

.upload-tab.active {
  background: var(--bg-glass-panel);
  color: var(--color-primary);
  box-shadow: 0 2px 8px rgba(90,24,154,0.1);
}

body.dark .upload-tab.active {
  color: var(--color-secondary);
  box-shadow: none;
}

.upload-tab:not(.active):hover {
  color: var(--color-text);
  background: rgba(0,0,0,0.03);
}

/* ── Embed input hint ── */
.embed-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--color-soft-gray);
  margin-top: 6px;
}

/* ── Embed live preview inside upload modal ── */
.embed-preview {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: 10px;
  overflow: hidden;
  margin-top: 10px;
  background: #000;
}

.embed-preview iframe,
.embed-preview video,
.embed-preview img {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  object-fit: cover;
}

/* ── Embed card thumbnail ── */
.media-card-embed {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #1a0533 0%, #2d0a4e 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: white;
}

.media-card-embed .embed-play-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.media-card-embed .embed-domain {
  font-size: 0.7rem;
  opacity: 0.7;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* YouTube-branded thumbnail background */
.media-card-embed.embed-youtube {
  background: linear-gradient(135deg, #1a0000 0%, #3d0000 100%);
}

.media-card-embed.embed-vimeo {
  background: linear-gradient(135deg, #001a1f 0%, #003d4d 100%);
}

/* ── Embed view inside view modal ── */
.view-embed-container {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: 0;
  overflow: hidden;
  background: #000;
}

.view-embed-container iframe,
.view-embed-container video {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

/* Fullscreen embed */
.view-image-container:fullscreen .view-embed-container,
.view-image-container:-webkit-full-screen .view-embed-container {
  width: 100vw;
  height: 100vh;
  aspect-ratio: unset;
  border-radius: 0;
}

/* ── List view embed thumbnail ── */
.media-list-thumb.embed-thumb {
  background: linear-gradient(135deg, #1a0533 0%, #2d0a4e 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.1rem;
}

/* ── Upload zone ── */
.upload-zone {
  border: 2px dashed var(--border-color);
  border-radius: 14px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--color-primary);
  background: rgba(90, 24, 154, 0.04);
}

.upload-zone i {
  font-size: 2.5rem;
  color: var(--color-primary);
  margin-bottom: 12px;
  display: block;
}

body.dark .upload-zone i { color: var(--color-secondary); }

.upload-zone p {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 6px;
}

.upload-hint {
  font-size: 0.78rem;
  color: var(--color-soft-gray);
}

/* Form fields */
.field-group {
  margin-bottom: 14px;
}

.field-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 6px;
}

.field-group input,
.field-group select,
.field-group textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-input);
  color: var(--color-text);
  font-family: var(--font-family-sans);
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(90, 24, 154, 0.1);
}

.field-group textarea { resize: vertical; min-height: 72px; }

/* Upload progress */
.upload-progress {
  margin-top: 16px;
}

.upload-progress-bar {
  height: 8px;
  background: rgba(90, 24, 154, 0.1);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 8px;
}

.upload-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
  border-radius: 8px;
  transition: width 0.3s ease;
  width: 0%;
}

.upload-progress-text {
  font-size: 0.82rem;
  color: var(--color-soft-gray);
  text-align: center;
}

/* View modal */
.view-image-container {
  position: relative;
  width: 100%;
  max-height: 400px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-body);
  margin-bottom: 20px;
}

.view-image-container img {
  width: 100%;
  height: auto;
  display: block;
}

/* Fullscreen button inside view modal */
.view-fullscreen-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
  z-index: 10;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.view-fullscreen-btn:hover {
  background: var(--color-primary);
  transform: scale(1.1);
}

body.dark .view-fullscreen-btn:hover {
  background: var(--color-secondary);
  color: #3E1F47;
}

/* Fullscreen state — image fills the screen */
.view-image-container:fullscreen,
.view-image-container:-webkit-full-screen,
.view-image-container:-ms-fullscreen {
  max-height: none;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  padding: 0;
}

.view-image-container:fullscreen img,
.view-image-container:-webkit-full-screen img,
.view-image-container:-ms-fullscreen img {
  width: auto;
  max-width: 100vw;
  max-height: 100vh;
  height: auto;
  object-fit: contain;
}

.view-image-container:fullscreen .view-fullscreen-btn,
.view-image-container:-webkit-full-screen .view-fullscreen-btn,
.view-image-container:-ms-fullscreen .view-fullscreen-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  background: rgba(0, 0, 0, 0.7);
}

/* Fullscreen expand button on grid cards */
.media-card-action--fullscreen {
  background: rgba(255, 255, 255, 0.95);
  color: #333;
}

.view-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

@media (max-width: 480px) {
  .view-details { grid-template-columns: 1fr; }
}

.view-detail-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-body);
  border-radius: 10px;
  font-size: 0.85rem;
  min-width: 0;
}

.view-detail-row i {
  width: 16px;
  color: var(--color-primary);
  flex-shrink: 0;
  font-size: 0.85rem;
}

body.dark .view-detail-row i { color: var(--color-secondary); }

.view-detail-row span {
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.view-notes {
  padding: 12px 14px;
  background: var(--bg-body);
  border-radius: 10px;
  font-size: 0.85rem;
  color: var(--color-soft-gray);
  line-height: 1.6;
  margin-bottom: 20px;
}

/* Modal footer */
.media-modal-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--border-color);
  align-items: center;
}

.view-modal-footer {
  justify-content: space-between;
}

.view-footer-right {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.btn-save, .btn-download {
  flex: 1;
  padding: 12px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: var(--font-family-sans);
  transition: background 0.2s, transform 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
}

.btn-save:hover, .btn-download:hover { 
  background: #4a148c; 
  transform: translateY(-1px); 
}

.btn-save:disabled { 
  opacity: 0.6; 
  cursor: not-allowed; 
  transform: none; 
}

body.dark .btn-save, body.dark .btn-download { 
  background: var(--color-secondary); 
  color: #3E1F47; 
}

body.dark .btn-save:hover, body.dark .btn-download:hover { 
  background: #ffdb4d; 
}

.btn-cancel {
  padding: 12px 18px;
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: var(--font-family-sans);
  transition: background 0.15s;
}

.btn-cancel:hover { background: rgba(0,0,0,0.04); }

.btn-delete {
  padding: 12px 14px;
  background: transparent;
  color: var(--color-error);
  border: 1px solid rgba(220, 53, 69, 0.3);
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: var(--font-family-sans);
  transition: background 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-delete:hover { background: rgba(220, 53, 69, 0.08); }

/* ── Toast ── */
.media-toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translate(-50%, 20px);
  background: #333;
  color: white;
  padding: 10px 22px;
  border-radius: 30px;
  font-size: 0.88rem;
  opacity: 0;
  transition: 0.35s;
  z-index: 3000;
  pointer-events: none;
  white-space: nowrap;
}

.media-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ── Confirmation Modal ── */
.confirm-modal {
  background: var(--bg-glass-panel);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  width: 100%;
  max-width: 420px;
  padding: 32px 28px 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modal-in 0.22s ease;
  text-align: center;
}

.confirm-modal-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(220, 53, 69, 0.1);
  color: #dc3545;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin: 0 auto 20px;
}

body.dark .confirm-modal-icon {
  background: rgba(220, 53, 69, 0.2);
}

.confirm-modal-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 12px;
}

.confirm-modal-message {
  font-size: 0.9rem;
  color: var(--color-soft-gray);
  line-height: 1.6;
  margin-bottom: 28px;
}

.confirm-modal-message strong {
  color: var(--color-text);
  font-weight: 600;
}

.confirm-modal-actions {
  display: flex;
  gap: 10px;
}

.btn-confirm-cancel {
  flex: 1;
  padding: 12px;
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: var(--font-family-sans);
  transition: background 0.15s;
}

.btn-confirm-cancel:hover {
  background: rgba(0, 0, 0, 0.04);
}

body.dark .btn-confirm-cancel:hover {
  background: rgba(255, 255, 255, 0.05);
}

.btn-confirm-delete {
  flex: 1;
  padding: 12px;
  background: #dc3545;
  color: white;
  border: none;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  font-family: var(--font-family-sans);
  transition: background 0.2s, transform 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-confirm-delete:hover {
  background: #c82333;
  transform: translateY(-1px);
}

.btn-confirm-delete:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ── Bottom nav ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: #fff;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-around;
  padding: 8px 0;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  z-index: 1000;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}

.bottom-nav .nav-item {
  font-size: 1em;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: color 0.3s ease;
  padding: 4px 0;
  color: #8a8a8a;
  flex: 1;
  justify-content: center;
  min-width: 0;
}

.bottom-nav .nav-item span {
  font-size: 0.65em;
  margin-top: 2px;
  font-weight: 500;
}

.bottom-nav .nav-item i {
  font-size: 18px;
  margin-bottom: 2px;
}

.bottom-nav .nav-item.active {
  color: var(--color-primary);
}

body.dark .bottom-nav {
  background: var(--bg-glass-panel);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.5);
}

body.dark .bottom-nav .nav-item {
  color: var(--color-soft-gray);
}

body.dark .bottom-nav .nav-item.active {
  color: var(--color-secondary);
}

@media (min-width: 1024px) {
  .bottom-nav {
    top: 0;
    left: 0;
    bottom: auto;
    width: 250px;
    height: 100vh;
    flex-direction: column;
    justify-content: flex-start;
    padding-top: 120px;
    gap: 25px;
    border-top: none;
    border-right: 1px solid var(--border-color);
    box-shadow: none;
  }

  .bottom-nav .nav-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    padding: 15px 30px;
    font-size: 1em;
    gap: 12px;
    flex: none;
    min-width: auto;
  }

  .bottom-nav .nav-item span {
    margin-top: 0;
    font-size: 1rem;
    font-weight: 600;
  }

  .bottom-nav .nav-item i {
    margin-bottom: 0;
    font-size: 1.2em;
    width: 24px;
    text-align: center;
  }

  .bottom-nav .nav-item:hover {
    background: rgba(0,0,0,0.05);
    border-right: 3px solid var(--color-secondary);
  }

  body.dark .bottom-nav .nav-item:hover {
    background: rgba(255,255,255,0.05);
  }

  .media-page {
    margin-left: 290px;
    padding: 40px;
    padding-bottom: 40px;
  }
}

/* ── Media highlight (from storyboard "View in Library" link) ── */
.media-highlighted {
  outline: 3px solid var(--color-primary, #5a189a);
  outline-offset: 3px;
  border-radius: 10px;
  animation: mediaHighlightPulse 0.6s ease-in-out 3;
}

@keyframes mediaHighlightPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(90, 24, 154, 0.4); }
  50%       { box-shadow: 0 0 0 10px rgba(90, 24, 154, 0); }
}

/* ── Media-linked badge on storyboard panels ── */
.meta-pill.media-linked-badge {
  background: rgba(90, 24, 154, 0.12);
  color: var(--color-primary, #5a189a);
  border: 1px solid rgba(90, 24, 154, 0.25);
}

body.dark .meta-pill.media-linked-badge {
  background: rgba(180, 100, 255, 0.15);
  color: #c084fc;
  border-color: rgba(180, 100, 255, 0.3);
}
