/* =============================================
   VaultGram v1.00 — OS/2 Warp 3.0 Inspired Theme
   Purple titlebars, teal accents, gray backgrounds
   ============================================= */

:root {
  --desktop-bg: #1a5a50;
  --win-bg: #c3c3c3;
  --titlebar-1: #6600aa;
  --titlebar-2: #330077;
  --titlebar-text: #ffffff;
  --teal: #008888;
  --teal-dark: #005555;
  --teal-light: #00bbbb;
  --link: #006677;
  --link-hover: #009999;
  --hi: #ffffff;
  --sh: #808080;
  --dsh: #404040;
  --text: #000000;
  --input-bg: #ffffff;

  /* 3D border helpers */
  --border-raised: var(--hi) var(--hi) var(--sh) var(--sh);
  --border-raised-outer: var(--hi) var(--hi) var(--dsh) var(--dsh);
  --border-sunken: var(--sh) var(--sh) var(--hi) var(--hi);
  --border-sunken-inner: var(--dsh) var(--dsh) var(--hi) var(--hi);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
img { max-width: 100%; display: block; }

/* ── Body / Desktop ── */
body {
  font-family: "Helv", "Arial", sans-serif;
  font-size: 13px;
  background-color: var(--desktop-bg);
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 3px,
      rgba(0,0,0,0.06) 3px,
      rgba(0,0,0,0.06) 4px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 3px,
      rgba(0,0,0,0.06) 3px,
      rgba(0,0,0,0.06) 4px
    );
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 16px;
}

.desktop {
  width: 100%;
  max-width: 1200px;
}

/* ── Window ── */
.window {
  background: var(--win-bg);
  border-style: solid;
  border-width: 2px;
  border-color: var(--hi) var(--dsh) var(--dsh) var(--hi);
  outline: 2px solid var(--sh);
  outline-offset: -4px;
  box-shadow: 3px 3px 8px rgba(0,0,0,0.5);
  min-height: 400px;
}

/* ── Titlebar ── */
.window-titlebar {
  background: linear-gradient(to right, var(--titlebar-1), var(--titlebar-2));
  color: var(--titlebar-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  user-select: none;
  min-height: 26px;
}

.titlebar-left {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  overflow: hidden;
}

.window-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  background: var(--teal-light);
  border: 1px solid rgba(255,255,255,0.4);
  flex-shrink: 0;
}

.titlebar-site {
  font-weight: bold;
  font-size: 13px;
  white-space: nowrap;
}

.titlebar-sep {
  opacity: 0.7;
}

.titlebar-page {
  font-size: 12px;
  opacity: 0.9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.window-controls {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}

.win-btn {
  width: 18px;
  height: 18px;
  background: var(--win-bg);
  border-style: solid;
  border-width: 1px;
  border-color: var(--hi) var(--sh) var(--sh) var(--hi);
  color: var(--text);
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  outline: none;
}

.win-btn:active {
  border-color: var(--sh) var(--hi) var(--hi) var(--sh);
}

.win-btn-close {
  background: #cc0000;
  color: #fff;
}

/* ── Navbar ── */
.window-navbar {
  background: var(--win-bg);
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px 6px;
  border-bottom: 2px solid var(--sh);
  border-top: 1px solid var(--hi);
  flex-wrap: wrap;
}

.nav-btn {
  display: inline-block;
  padding: 2px 10px;
  background: var(--win-bg);
  color: var(--text);
  text-decoration: none;
  border-style: solid;
  border-width: 1px;
  border-color: var(--hi) var(--sh) var(--sh) var(--hi);
  font-size: 12px;
  cursor: pointer;
  outline: none;
}

.nav-btn:hover {
  background: #d0d0d0;
}

.nav-btn:active {
  border-color: var(--sh) var(--hi) var(--hi) var(--sh);
}

.nav-spacer {
  flex: 1;
}

.nav-user {
  color: var(--teal-dark);
  font-size: 11px;
  padding: 0 6px;
}

/* ── Content Area ── */
.window-content {
  padding: 16px;
}

/* ── Window states: Minimize / Maximize ── */
.window-minimized .window-navbar,
.window-minimized .window-content,
.window-minimized .window-statusbar { display: none !important; }

.window-maximized {
  position: fixed !important;
  top: 0 !important; left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  margin: 0 !important;
  z-index: 500 !important;
  border: none !important;
  box-shadow: none !important;
  overflow-y: auto !important;
  border-radius: 0 !important;
}

/* ── Status Bar ── */
.window-statusbar {
  background: var(--win-bg);
  border-top: 2px solid var(--sh);
  padding: 3px 8px;
  font-size: 11px;
  display: flex;
  justify-content: space-between;
  color: var(--dsh);
}

/* ── Buttons ── */
.btn {
  display: inline-block;
  padding: 4px 14px;
  background: var(--win-bg);
  color: var(--text);
  border-style: solid;
  border-width: 2px;
  border-color: var(--hi) var(--sh) var(--sh) var(--hi);
  outline: 1px solid var(--dsh);
  outline-offset: -3px;
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  user-select: none;
}

.btn:hover {
  background: #d2d2d2;
}

.btn:active {
  border-color: var(--sh) var(--hi) var(--hi) var(--sh);
  padding: 5px 13px 3px 15px;
}

.btn-primary {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal-light) var(--teal-dark) var(--teal-dark) var(--teal-light);
}

.btn-primary:hover {
  background: var(--teal-dark);
}

.btn-danger {
  background: #aa2222;
  color: #fff;
  border-color: #dd4444 #661111 #661111 #dd4444;
}

.btn-danger:hover {
  background: #881111;
}

.btn-sm {
  padding: 2px 8px;
  font-size: 11px;
}

/* ── Links ── */
a {
  color: var(--link);
  text-decoration: underline;
}

a:hover {
  color: var(--link-hover);
}

/* ── Inputs / Forms ── */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="url"],
textarea,
select {
  background: var(--input-bg);
  color: var(--text);
  border-style: solid;
  border-width: 2px;
  border-color: var(--sh) var(--hi) var(--hi) var(--sh);
  outline: 1px solid var(--dsh);
  outline-offset: -3px;
  padding: 3px 6px;
  font-family: inherit;
  font-size: 12px;
  width: 100%;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
  outline: 2px solid var(--teal);
  outline-offset: -3px;
}

textarea {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  margin-bottom: 10px;
}

.form-row label {
  display: block;
  font-weight: bold;
  margin-bottom: 3px;
  font-size: 12px;
}

.form-row small {
  display: block;
  margin-top: 2px;
  color: var(--sh);
  font-size: 11px;
}

/* ── Panel ── */
.panel {
  border-style: solid;
  border-width: 2px;
  border-color: var(--sh) var(--hi) var(--hi) var(--sh);
  background: var(--win-bg);
  margin-bottom: 14px;
}

.panel-title {
  background: var(--teal);
  color: #fff;
  padding: 4px 8px;
  font-weight: bold;
  font-size: 12px;
  border-bottom: 1px solid var(--teal-dark);
}

.panel-body {
  padding: 10px;
}

/* ── Gallery Grid ── */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.gallery-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-style: solid;
  border-width: 2px;
  border-color: var(--sh) var(--hi) var(--hi) var(--sh);
  cursor: pointer;
  background: #888;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.gallery-item img.loaded {
  opacity: 1;
}

.gallery-item:hover .img-overlay {
  opacity: 1;
}

.img-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
  color: #fff;
  padding: 20px 6px 5px;
  font-size: 10px;
  opacity: 0;
  transition: opacity 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.img-select {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 2;
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--teal);
}

.gallery-item.selected {
  outline: 3px solid var(--teal-light);
  outline-offset: -3px;
}

/* ── Per-image delete button (admin only) ── */
.delete-img-form {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 3;
  margin: 0;
  padding: 0;
}

.btn-delete-img {
  width: 22px;
  height: 22px;
  background: rgba(160, 0, 0, 0.88);
  color: #fff;
  border: 2px solid;
  border-color: #ff6666 #660000 #660000 #ff6666;
  cursor: pointer;
  font-size: 12px;
  font-weight: bold;
  line-height: 1;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
}

/* Show on hover */
.gallery-item:hover .btn-delete-img {
  display: flex;
}

/* In admin-gallery: always show delete buttons */
.admin-gallery .btn-delete-img {
  display: flex;
}

.btn-delete-img:hover {
  background: rgba(200, 0, 0, 1);
}

.btn-delete-img:active {
  border-color: #660000 #ff6666 #ff6666 #660000;
}

/* ── Lightbox ── */
#lightbox {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}

#lightbox.active {
  display: flex;
}

.lightbox-window {
  background: var(--win-bg);
  border-style: solid;
  border-width: 2px;
  border-color: var(--hi) var(--dsh) var(--dsh) var(--hi);
  outline: 1px solid var(--sh);
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  min-width: 320px;
}

.lightbox-titlebar {
  background: linear-gradient(to right, var(--titlebar-1), var(--titlebar-2));
  color: var(--titlebar-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px;
  user-select: none;
  flex-shrink: 0;
}

.lightbox-title {
  font-size: 12px;
  font-weight: bold;
}

.lightbox-close {
  background: #cc0000;
  color: #fff;
  border: 1px solid #ff4444;
  width: 20px;
  height: 20px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}

.lightbox-body {
  position: relative;
  background: #1a1a1a;
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

#lightbox-img {
  max-width: 85vw;
  max-height: calc(90vh - 80px);
  object-fit: contain;
  display: block;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  width: 36px;
  height: 60px;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  z-index: 2;
}

.lightbox-nav:hover {
  background: rgba(0,136,136,0.7);
}

.lightbox-nav.prev { left: 4px; }
.lightbox-nav.next { right: 4px; }

.lightbox-statusbar {
  border-top: 2px solid var(--sh);
  background: var(--win-bg);
  padding: 3px 8px;
  font-size: 11px;
  display: flex;
  justify-content: space-between;
  flex-shrink: 0;
}

/* ── Upload Zone ── */
.upload-zone {
  border: 2px dashed var(--sh);
  padding: 40px 20px;
  background: #fff;
  cursor: pointer;
  text-align: center;
  color: var(--dsh);
  transition: border-color 0.2s, background 0.2s;
  margin: 8px 0;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--teal);
  background: #e0f5f5;
  color: var(--teal-dark);
}

.upload-zone-icon {
  font-size: 40px;
  margin-bottom: 8px;
  color: var(--teal);
}

/* ── Progress Bar ── */
.progress-bar-outer {
  border-style: solid;
  border-width: 2px;
  border-color: var(--sh) var(--hi) var(--hi) var(--sh);
  height: 22px;
  background: var(--win-bg);
  overflow: hidden;
  position: relative;
  margin: 4px 0;
}

.progress-bar-inner {
  height: 100%;
  background: var(--teal);
  transition: width 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 11px;
  font-weight: bold;
  min-width: 2px;
}

/* ── File Queue ── */
#file-queue {
  border-style: solid;
  border-width: 2px;
  border-color: var(--sh) var(--hi) var(--hi) var(--sh);
  background: var(--input-bg);
  max-height: 240px;
  overflow-y: auto;
  margin: 6px 0;
  padding: 2px;
}

.file-queue-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-bottom: 1px solid #ddd;
  font-size: 11px;
}

.file-queue-item:last-child {
  border-bottom: none;
}

.file-queue-item .fqi-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fqi-status {
  font-size: 13px;
}

.fqi-status.done    { color: #008800; }
.fqi-status.error   { color: #cc0000; }
.fqi-status.pending { color: var(--sh); }
.fqi-status.active  { color: var(--teal); }

.file-queue-item .fqi-progress {
  width: 80px;
}

/* ── Channel Grid ── */
.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.channel-card {
  display: block;
  background: var(--win-bg);
  border-style: solid;
  border-width: 2px;
  border-color: var(--hi) var(--sh) var(--sh) var(--hi);
  text-decoration: none;
  color: var(--text);
  transition: box-shadow 0.15s;
}

.channel-card:hover {
  box-shadow: 3px 3px 8px rgba(0,0,0,0.35);
  border-color: var(--teal) var(--teal-dark) var(--teal-dark) var(--teal);
  color: var(--text);
  text-decoration: none;
}

.channel-card-thumb {
  height: 140px;
  background: #444;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.channel-card-thumb .no-thumb {
  color: #888;
  font-size: 11px;
}

.channel-card-info {
  padding: 8px 10px;
  border-top: 1px solid var(--sh);
}

.channel-card-name {
  font-weight: bold;
  font-size: 13px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-card-meta {
  font-size: 11px;
  color: var(--dsh);
}

/* ── Tables ── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 12px;
}

.data-table th {
  background: var(--teal);
  color: #fff;
  padding: 5px 8px;
  text-align: left;
  border: 1px solid var(--teal-dark);
  white-space: nowrap;
}

.data-table td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--sh);
  vertical-align: middle;
}

.data-table tr:hover td {
  background: #d8f0f0;
}

/* ── Alerts / Flash Messages ── */
.alert-error,
.alert-success,
.alert-info {
  padding: 8px 12px;
  margin-bottom: 10px;
  border-style: solid;
  border-width: 1px;
  font-size: 12px;
}

.alert-error {
  background: #ffe8e8;
  border-color: #cc0000;
  color: #880000;
}

.alert-success {
  background: #e8ffe8;
  border-color: #008800;
  color: #005500;
}

.alert-info {
  background: #e0f0ff;
  border-color: #0055aa;
  color: #003388;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: bold;
  border-radius: 0;
}

.badge-teal   { background: var(--teal);   color: #fff; }
.badge-gray   { background: var(--sh);     color: #fff; }
.badge-red    { background: #aa2222;       color: #fff; }
.badge-purple { background: var(--titlebar-1); color: #fff; }

/* ── Download Bar ── */
.download-bar {
  background: var(--win-bg);
  border-style: solid;
  border-width: 2px;
  border-color: var(--sh) var(--hi) var(--hi) var(--sh);
  padding: 5px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.download-bar .sel-count {
  font-size: 11px;
  color: var(--dsh);
}

/* ── Info Bar ── */
.info-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--sh);
  padding-bottom: 6px;
  margin-bottom: 8px;
  font-size: 12px;
  flex-wrap: wrap;
  gap: 6px;
}

.info-bar-left  { color: var(--dsh); }
.info-bar-right { display: flex; gap: 6px; }

/* ── Copy Link ── */
.copy-link {
  background: none;
  border: 1px solid var(--sh);
  color: var(--link);
  font-size: 11px;
  padding: 1px 6px;
  cursor: pointer;
  font-family: inherit;
}

.copy-link:hover {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal-dark);
}

/* ── Login Panel ── */
.login-wrap {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 300px;
  padding: 20px 0;
}

.login-panel {
  width: 100%;
  max-width: 360px;
}

/* ── Section Tabs (admin) ── */
.section-tabs {
  display: flex;
  gap: 2px;
  margin-bottom: 12px;
  border-bottom: 2px solid var(--sh);
  padding-bottom: 0;
}

.section-tab {
  padding: 4px 14px;
  background: var(--win-bg);
  color: var(--text);
  text-decoration: none;
  border-style: solid;
  border-width: 2px;
  border-bottom: none;
  border-color: var(--hi) var(--sh) transparent var(--hi);
  font-size: 12px;
  position: relative;
  bottom: -2px;
}

.section-tab:hover {
  background: #d2d2d2;
  text-decoration: none;
  color: var(--text);
}

.section-tab.active {
  background: var(--win-bg);
  border-color: var(--teal) var(--sh) var(--win-bg) var(--teal);
  color: var(--teal-dark);
  font-weight: bold;
  z-index: 1;
}

/* ── Password Dialog ── */
.password-dialog {
  max-width: 400px;
  margin: 30px auto;
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--sh);
}

.empty-state .empty-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
}

/* ── Scrollbar (OS/2 style) ── */
::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}

::-webkit-scrollbar-track {
  background: var(--win-bg);
  border-left: 1px solid var(--sh);
}

::-webkit-scrollbar-thumb {
  background: var(--win-bg);
  border-style: solid;
  border-width: 1px;
  border-color: var(--hi) var(--sh) var(--sh) var(--hi);
}

::-webkit-scrollbar-thumb:hover {
  background: #b0b0b0;
}

::-webkit-scrollbar-button {
  background: var(--win-bg);
  border-style: solid;
  border-width: 1px;
  border-color: var(--hi) var(--sh) var(--sh) var(--hi);
  height: 14px;
}

/* ── Utility ── */
.mt-0  { margin-top: 0; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.flex { display: flex; }
.flex-gap { gap: 8px; }
.flex-wrap { flex-wrap: wrap; }
.align-center { align-items: center; }
.bold { font-weight: bold; }
.text-sm { font-size: 11px; }
.text-teal { color: var(--teal); }
.text-muted { color: var(--sh); }
.d-none { display: none !important; }

/* Lock icon inline */
.lock-icon {
  display: inline-block;
  font-style: normal;
  font-size: 12px;
  margin-left: 3px;
}

/* Admin notice on login */
.admin-notice {
  background: #fff8cc;
  border: 1px solid #ccaa00;
  color: #665500;
  padding: 6px 10px;
  margin-top: 8px;
  font-size: 11px;
}

/* Settings logo preview */
.logo-preview {
  margin: 8px 0;
  border: 1px solid var(--sh);
  padding: 4px;
  background: #fff;
  max-width: 200px;
}

/* ── Mobile Responsive ── */
@media (max-width: 600px) {
  body {
    padding: 0;
  }

  .desktop {
    max-width: 100%;
  }

  .window {
    border-width: 0;
    outline: none;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 4px;
  }

  .channel-grid {
    grid-template-columns: 1fr;
  }

  .download-bar {
    gap: 4px;
  }

  .lightbox-window {
    max-width: 100vw;
    max-height: 100vh;
  }

  #lightbox-img {
    max-width: 100vw;
    max-height: calc(100vh - 80px);
  }

  .section-tabs {
    flex-wrap: wrap;
  }

  .data-table {
    font-size: 11px;
  }

  .data-table th,
  .data-table td {
    padding: 3px 4px;
  }

  .window-navbar {
    gap: 4px;
  }

  .info-bar {
    flex-direction: column;
    align-items: flex-start;
  }
}
