/* ============================================================
   Design: Dark media-gallery aesthetic
   Palette: near-black bg, electric violet accent, warm white text
   Type: 'Inter' utility + 'DM Sans' for headings
   Signature: masonry grid with hover-slide caption reveal
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Inter:wght@300;400;500&display=swap');

/* ---------- reset & tokens ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0d0d0f;
  --surface:     #18181c;
  --surface2:    #222228;
  --border:      #2e2e38;
  --accent:      #7c5cfc;
  --accent-glow: rgba(124, 92, 252, 0.35);
  --accent2:     #c084fc;
  --text:        #f0eeff;
  --text-muted:  #8b8a9e;
  --text-dim:    #55546a;
  --danger:      #f43f5e;
  --success:     #22d3a5;
  --radius:      10px;
  --radius-lg:   16px;
  --nav-h:       60px;
  --font-head:   'DM Sans', sans-serif;
  --font-body:   'Inter', sans-serif;
  --shadow:      0 4px 24px rgba(0,0,0,0.5);
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent2); }

img, video { display: block; max-width: 100%; }

/* ---------- scrollbar ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ---------- navbar ---------- */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: rgba(13, 13, 15, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  z-index: 100;
}

.navbar-brand {
  font-family: var(--font-head);
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.5px;
}

.navbar-brand .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.navbar-spacer { flex: 1; }

.navbar-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: #6a4aef;
  box-shadow: 0 0 20px var(--accent-glow);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--surface2);
  color: var(--text);
  border-color: var(--border);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(244, 63, 94, 0.3);
}
.btn-danger:hover {
  background: rgba(244, 63, 94, 0.1);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 7px;
}

.btn-icon {
  padding: 7px;
  border-radius: 8px;
}

/* ---------- layout ---------- */
.page-wrap {
  margin-top: var(--nav-h);
  padding: 28px 24px;
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.page-header .spacer { flex: 1; }

/* ---------- masonry gallery ---------- */
.gallery {
  columns: 5 220px;
  column-gap: 12px;
}

.gallery-item {
  break-inside: avoid;
  margin-bottom: 12px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  background: var(--surface);
  cursor: pointer;
  border: 1px solid var(--border);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.gallery-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.6), 0 0 0 1px var(--accent);
}

.gallery-item img,
.gallery-item video {
  width: 100%;
  height: auto;
  display: block;
}

.gallery-item-caption {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 28px 12px 12px;
  background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, transparent 100%);
  transform: translateY(100%);
  transition: transform 0.22s ease;
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.gallery-item:hover .gallery-item-caption {
  transform: translateY(0);
}

.gallery-item-title {
  flex: 1;
  font-size: 12px;
  font-weight: 500;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gallery-item-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* ---------- lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.lightbox.open {
  opacity: 1;
  pointer-events: all;
}

.lightbox-inner {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lightbox-inner img,
.lightbox-inner video {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: var(--radius-lg);
}

.lightbox-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px;
}

.lightbox-title {
  font-family: var(--font-head);
  font-size: 15px;
  font-weight: 600;
  flex: 1;
}

.lightbox-close {
  position: fixed;
  top: 20px; right: 20px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 50%;
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  transition: background 0.15s;
}

.lightbox-close:hover { background: var(--surface); }

/* ---------- folder cards ---------- */
.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}

.folder-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.15s ease;
}

.folder-card:hover {
  background: var(--surface2);
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.folder-card.active {
  background: rgba(124, 92, 252, 0.12);
  border-color: var(--accent);
}

.folder-icon {
  font-size: 22px;
  flex-shrink: 0;
}

.folder-info { min-width: 0; }

.folder-name {
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.folder-count {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.folder-card-actions {
  margin-left: auto;
  flex-shrink: 0;
  display: none;
}

.folder-card:hover .folder-card-actions { display: flex; }

/* ---------- section label ---------- */
.section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ---------- forms & modals ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow);
}

.modal h2 {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
}

.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-control {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.form-control:focus { border-color: var(--accent); }
.form-control::placeholder { color: var(--text-dim); }

select.form-control option { background: var(--surface); }

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ---------- upload drop zone ---------- */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(124, 92, 252, 0.05);
}

.drop-zone-icon { font-size: 40px; margin-bottom: 12px; }

.drop-zone-text {
  font-family: var(--font-head);
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}

.drop-zone-sub { font-size: 12px; color: var(--text-muted); }

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

/* ---------- upload preview grid ---------- */
.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.preview-item {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  aspect-ratio: 1;
  border: 1px solid var(--border);
}

.preview-item img,
.preview-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview-remove {
  position: absolute;
  top: 4px; right: 4px;
  background: rgba(0,0,0,0.7);
  border: none;
  color: #fff;
  border-radius: 50%;
  width: 20px; height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}

.preview-progress {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: var(--border);
}

.preview-progress-bar {
  height: 100%;
  background: var(--accent);
  transition: width 0.2s;
}

/* ---------- toast ---------- */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow);
  animation: slideIn 0.2s ease;
  max-width: 320px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--accent); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ---------- pagination ---------- */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 36px;
}

.pagination .page-btn {
  min-width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.pagination .page-btn:hover,
.pagination .page-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------- empty state ---------- */
.empty-state {
  text-align: center;
  padding: 80px 20px;
}

.empty-state-icon { font-size: 48px; margin-bottom: 16px; }

.empty-state h3 {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.empty-state p { font-size: 14px; color: var(--text-muted); }

/* ---------- search bar ---------- */
.search-wrap {
  position: relative;
  flex: 1;
  max-width: 340px;
}

.search-wrap input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px 8px 36px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.search-wrap input:focus { border-color: var(--accent); }
.search-wrap input::placeholder { color: var(--text-dim); }

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
}

/* ---------- login page ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.login-logo {
  font-family: var(--font-head);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.login-logo .dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 14px var(--accent);
}

/* ---------- upload page ---------- */
.upload-wrap {
  max-width: 700px;
  margin: 0 auto;
}

.upload-fields {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 20px;
}

/* ---------- spinner ---------- */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- badge ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 500;
}

.badge-purple { background: rgba(124,92,252,0.2); color: var(--accent2); }
.badge-green  { background: rgba(34,211,165,0.15); color: var(--success); }

/* ---------- copy url button ---------- */
.copy-url-input {
  display: flex;
  gap: 8px;
  align-items: center;
}

.copy-url-input input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 10px;
  color: var(--text-muted);
  font-size: 12px;
  font-family: monospace;
  outline: none;
}

/* ---------- responsive ---------- */
@media (max-width: 768px) {
  .page-wrap { padding: 20px 14px; }
  .gallery { columns: 2 160px; }
  .folder-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .navbar { padding: 0 14px; }
  .login-card { padding: 28px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
