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

:root {
  --bg-primary: #0e1014;
  --bg-secondary: #161923;
  --bg-card: #1b1f29;
  --bg-card-hover: #242a37;
  --border: #2a2f3b;
  --accent: #7c5cff;
  --accent-hover: #8f72ff;
  --accent-soft: rgba(124, 92, 255, 0.15);
  --success: #22c55e;
  --success-hover: #3ddc75;
  --danger: #ef4444;
  --danger-hover: #f45f5f;
  --text-primary: #f4f5f8;
  --text-secondary: #9aa1b0;
  --text-muted: #6b7280;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
  min-height: 100vh;
}

button, input {
  font-family: inherit;
}

/* ---------- Login page ---------- */

.login-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  overflow: hidden;
  position: relative;
}

.bg-glow {
  position: fixed;
  width: 60vw;
  height: 60vw;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.25;
  pointer-events: none;
  z-index: 0;
}
.bg-glow-1 { background: #7c5cff; top: -20%; left: -15%; }
.bg-glow-2 { background: #22c55e; bottom: -25%; right: -15%; opacity: 0.15; }

.login-card {
  position: relative;
  z-index: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 44px 40px;
  width: min(380px, 90vw);
  text-align: center;
}

.login-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 800;
}

.login-sub {
  margin: 0 0 28px;
  color: var(--text-secondary);
  font-size: 14px;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#password {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s;
  text-align: center;
}
#password:focus { border-color: var(--accent); }

#login-btn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}
#login-btn:hover { background: var(--accent-hover); }
#login-btn:active { transform: scale(0.98); }
#login-btn:disabled { opacity: 0.6; cursor: default; }

.login-error {
  margin: 16px 0 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
}

.login-credit {
  position: relative;
  z-index: 1;
  margin-top: 22px;
  font-size: 12px;
  color: var(--text-muted);
}
.login-credit a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.15s;
}
.login-credit a:hover { color: var(--accent); }

/* ---------- App shell ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 22px;
  min-width: 0;
}

.logo {
  font-weight: 800;
  font-size: 17px;
  white-space: nowrap;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  white-space: nowrap;
}

.breadcrumbs a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.breadcrumbs a:hover { background: var(--bg-card); color: var(--text-primary); }
.breadcrumbs .crumb-sep { color: var(--text-muted); }
.breadcrumbs .crumb-current { color: var(--text-primary); font-weight: 600; padding: 4px 8px; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, color 0.15s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost { background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-card-hover); }

.btn-icon {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { background: var(--danger); color: white; border-color: var(--danger); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: var(--danger-hover); }

/* ---------- Content grid ---------- */

.content {
  padding: 28px;
  max-width: 1400px;
  margin: 0 auto;
}

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

.item-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  user-select: none;
}
.item-card:hover { background: var(--bg-card-hover); border-color: #363c4a; }
.item-card:active { transform: scale(0.98); }

.item-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 10px;
  font-size: 40px;
}

.item-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.item-name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
}

.item-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--danger);
  color: white;
  border: none;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  cursor: pointer;
  z-index: 2;
}
.item-card:hover .item-delete { display: flex; }
.item-delete:hover { background: var(--danger-hover); }

.item-share {
  position: absolute;
  top: 8px;
  right: 40px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border: 1px solid var(--border);
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: pointer;
  z-index: 2;
}
.item-card:hover .item-share { display: flex; }
.item-share:hover { background: var(--accent); border-color: var(--accent); }

.readonly-badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 999px;
}

.empty-state {
  text-align: center;
  padding: 90px 20px;
  color: var(--text-secondary);
}
.empty-icon { font-size: 48px; margin-bottom: 14px; opacity: 0.7; }
.empty-sub { color: var(--text-muted); font-size: 13px; }

/* ---------- Drag & drop overlay ---------- */

.dropzone {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(14, 16, 20, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
}
.dropzone[hidden] { display: none; }
.dropzone-inner {
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  padding: 60px 90px;
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
}

/* ---------- Modal ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  width: min(380px, 100%);
  text-align: center;
}

.modal-card h2 {
  margin: 0 0 16px;
  font-size: 17px;
  font-weight: 800;
}

.modal-card input[type="text"] {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 14px;
  outline: none;
  margin-bottom: 18px;
  text-align: center;
}
.modal-card input[type="text"]:focus { border-color: var(--accent); }

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.modal-actions .btn { flex: 1; padding: 11px 14px; }

/* ---------- Lightbox (file preview) ---------- */

.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(5, 6, 10, 0.92);
  display: flex;
  flex-direction: column;
}

.lightbox-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  color: var(--text-primary);
}
.lightbox-name { font-weight: 700; font-size: 14px; }
.lightbox-actions { display: flex; gap: 10px; }

.lightbox-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 0 70px 24px;
  min-height: 0;
}

.lightbox-body img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
}

.lightbox-generic {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  color: var(--text-secondary);
}
.lightbox-generic .icon { font-size: 72px; }

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: white;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-nav:hover { background: rgba(255, 255, 255, 0.18); }
.lightbox-nav.prev { left: 14px; }
.lightbox-nav.next { right: 14px; }

/* ---------- Toasts / upload progress ---------- */

.toast-root {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 300px;
}

.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  font-size: 12px;
}

.toast-title {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  color: var(--text-primary);
  font-weight: 600;
  gap: 8px;
}
.toast-title span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toast-bar-bg {
  height: 5px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}
.toast-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.15s;
}
.toast.error .toast-bar-fill { background: var(--danger); }
.toast.done .toast-bar-fill { background: var(--success); }

@media (max-width: 640px) {
  .topbar { padding: 12px 16px; }
  .content { padding: 16px; }
  .lightbox-body { padding: 0 16px 16px; }
  .lightbox-nav { display: none; }
}
