/* frontend/style.css */

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

body {
  font-family: system-ui, sans-serif;
  background: #111;
  color: #eee;
  min-height: 100vh;
}

[hidden] { display: none !important; }

/* ── Login ───────────────────────────────────────────────── */
#login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-card {
  background: #1e1e1e;
  border-radius: 8px;
  padding: 2rem;
  width: 100%;
  max-width: 360px;
}

.login-card h1 {
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
  text-align: center;
  letter-spacing: 0.05em;
}

.login-card label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
  color: #aaa;
}

.login-card input {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 4px;
  color: #eee;
  font-size: 1rem;
}

.login-card input:focus {
  outline: none;
  border-color: #667eea;
}

.login-card button[type="submit"] {
  width: 100%;
  padding: 0.6rem;
  background: #667eea;
  border: none;
  border-radius: 4px;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
}

.login-card button[type="submit"]:hover { background: #5a6fd6; }

.error { color: #f87171; font-size: 0.85rem; margin-top: 0.5rem; }

/* ── Gallery header ──────────────────────────────────────── */
.gallery-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: #1e1e1e;
  border-bottom: 1px solid #333;
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-name { font-weight: 600; font-size: 1.1rem; margin-right: auto; }

.controls { display: flex; gap: 0.5rem; align-items: center; }

.controls input[type="search"] {
  padding: 0.4rem 0.75rem;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 4px;
  color: #eee;
  font-size: 0.9rem;
  width: 220px;
}

.controls input[type="search"]:focus { outline: none; border-color: #667eea; }

.controls select {
  padding: 0.4rem 0.5rem;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 4px;
  color: #eee;
  font-size: 0.9rem;
  cursor: pointer;
}

.controls select:focus { outline: none; border-color: #667eea; }

.controls button, #logout-btn {
  padding: 0.4rem 0.9rem;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 4px;
  color: #eee;
  font-size: 0.9rem;
  cursor: pointer;
}

.controls button:hover, #logout-btn:hover { background: #333; }

/* ── Photo grid ──────────────────────────────────────────── */
main { padding: 1rem; }

.photo-grid {
  columns: 4 220px;
  column-gap: 8px;
}

.photo-card {
  break-inside: avoid;
  margin-bottom: 8px;
  cursor: pointer;
  border-radius: 4px;
  overflow: hidden;
  background: #1e1e1e;
}

.photo-card img {
  display: block;
  width: 100%;
  height: auto;
}

.photo-card:hover { opacity: 0.85; }

#load-more-container { text-align: center; padding: 1.5rem; }

#scroll-sentinel { height: 1px; }

#end-of-gallery { color: #666; font-size: 0.9rem; }

/* ── Detail view ─────────────────────────────────────────── */
.detail-main {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.5rem;
  padding: 1.5rem;
  min-height: calc(100vh - 56px);
}

@media (max-width: 700px) {
  .detail-main { grid-template-columns: 1fr; }
}

.detail-image-wrap {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.detail-image-wrap img {
  max-width: 100%;
  max-height: 80vh;
  border-radius: 4px;
  object-fit: contain;
}

.detail-meta {
  background: #1e1e1e;
  border-radius: 6px;
  padding: 1.25rem;
  overflow-y: auto;
  max-height: calc(100vh - 80px);
}

.detail-meta h2 {
  font-size: 1rem;
  font-weight: 600;
  word-break: break-all;
  margin-bottom: 0.25rem;
}

.detail-subtitle {
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 1.25rem;
}

.detail-meta h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #666;
  margin-bottom: 0.5rem;
}

.detail-meta section {
  margin-bottom: 1.25rem;
}

.detail-meta ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.detail-meta li {
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.label-confidence {
  font-size: 0.75rem;
  color: #888;
  background: #2a2a2a;
  border-radius: 3px;
  padding: 0.1rem 0.4rem;
}

/* ── Admin view ──────────────────────────────────────────── */
.admin-main {
  padding: 1.5rem;
  max-width: 900px;
  margin: 0 auto;
}

.admin-section {
  margin-bottom: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #333;
}

.admin-section:first-child { border-top: none; }

.admin-section h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

table.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

table.admin-table th {
  text-align: left;
  padding: 0.4rem 0.75rem;
  color: #666;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #333;
}

table.admin-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #222;
  word-break: break-all;
}

table.admin-table tr:last-child td { border-bottom: none; }

table.admin-table button {
  padding: 0.25rem 0.6rem;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 3px;
  color: #eee;
  font-size: 0.8rem;
  cursor: pointer;
}

table.admin-table button:hover { background: #333; }
table.admin-table button:disabled { opacity: 0.5; cursor: default; }

.admin-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.admin-form input, .admin-form select {
  padding: 0.4rem 0.75rem;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 4px;
  color: #eee;
  font-size: 0.9rem;
}

.admin-form input:focus, .admin-form select:focus {
  outline: none;
  border-color: #667eea;
}

.admin-form button {
  padding: 0.4rem 0.9rem;
  background: #667eea;
  border: none;
  border-radius: 4px;
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
}

.admin-form button:hover { background: #5a6fd6; }

/* ── Upload modal ────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
}

.modal-box {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 101;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 1.5rem;
  width: min(560px, 95vw);
  max-height: 80vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-box h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.upload-file-label {
  display: inline-block;
  padding: 0.4rem 0.9rem;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  width: fit-content;
}

.upload-file-label:hover { background: #333; }

#upload-file-input { display: none; }

#upload-queue {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.upload-item {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem;
  background: #222;
  border-radius: 4px;
  font-size: 0.85rem;
}

.upload-item-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.upload-item input[type="number"] {
  width: 4.5rem;
  padding: 0.2rem 0.4rem;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 3px;
  color: #eee;
  font-size: 0.8rem;
}

.upload-item select {
  padding: 0.2rem 0.4rem;
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 3px;
  color: #eee;
  font-size: 0.8rem;
}

.upload-item-status {
  font-size: 0.8rem;
  min-width: 5rem;
  text-align: right;
}

.upload-item-status.pending { color: #888; }
.upload-item-status.uploading { color: #667eea; }
.upload-item-status.processing { color: #f0a500; }
.upload-item-status.done { color: #4caf50; }
.upload-item-status.error { color: #f44336; }

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.modal-actions button {
  padding: 0.4rem 0.9rem;
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
}

#upload-start-btn {
  background: #667eea;
  color: #fff;
}

#upload-start-btn:hover:not(:disabled) { background: #5a6fd6; }
#upload-start-btn:disabled { opacity: 0.4; cursor: default; }

#upload-cancel-btn {
  background: #2a2a2a;
  color: #eee;
  border: 1px solid #444;
}

#upload-cancel-btn:hover { background: #333; }
