/* ============================================================
   Jrafina Gallery — Global Stylesheet
   Design: dark/light minimal, IBM Plex Mono, brick-red accent
   ============================================================ */

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

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: "IBM Plex Mono", "HarmonyOS Sans", "Noto Sans SC", "Courier New", monospace;
  background: #f4f4f4;
  color: #1a1a1a;
  line-height: 1.6;
}

a { color: #c44d34; text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* ---------- Utility ---------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

/* ============================================================
   Gallery Page
   ============================================================ */
.gallery-header {
  background: #1a1a1a;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.gallery-header h1 {
  color: #f4f4f4;
  font-size: 1.2rem;
  font-weight: 400;
  letter-spacing: 0.05em;
}

.gallery-header h1 span { color: #c44d34; }

.gallery-header .admin-link {
  margin-left: auto;
  color: #888;
  font-size: 0.8rem;
  border: 1px solid #444;
  padding: 4px 10px;
  transition: color 0.15s, border-color 0.15s;
}
.gallery-header .admin-link:hover {
  color: #f4f4f4;
  border-color: #888;
  text-decoration: none;
}

/* Category filter */
.category-filter {
  background: #fff;
  padding: 12px 24px;
  border-bottom: 1px solid #ddd;
  display: flex;
  align-items: center;
  gap: 10px;
}

.category-filter label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
}

.category-filter select {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.85rem;
  padding: 4px 8px;
  border: 1px solid #ccc;
  border-radius: 0;
  background: #fff;
  color: #1a1a1a;
  cursor: pointer;
}

/* Waterfall layout */
.gallery-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px;
}

.waterfall {
  column-count: 4;
  column-gap: 6px;
  padding: 0;
}

@media (max-width: 1200px) { .waterfall { column-count: 3; } }
@media (max-width: 800px)  { .waterfall { column-count: 2; } }
@media (max-width: 500px)  { .waterfall { column-count: 1; } }

.waterfall .item {
  break-inside: avoid;
  margin-bottom: 6px;
  cursor: pointer;
  overflow: hidden;
  background: #e8e8e8;
  transition: opacity 0.2s;
}

.waterfall .item:hover { opacity: 0.92; }

.waterfall .item img {
  width: 100%;
  height: auto;
  display: block;
}

/* Loading & empty states */
.gallery-loading,
.gallery-empty,
.gallery-error {
  text-align: center;
  padding: 80px 20px;
  color: #888;
  font-size: 0.9rem;
}

/* ============================================================
   Lightbox
   ============================================================ */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.95);
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

.lightbox.active { display: flex; }

.lightbox .close-btn {
  position: absolute;
  top: 16px;
  right: 20px;
  color: #fff;
  font-size: 1.6rem;
  cursor: pointer;
  background: none;
  border: none;
  font-family: "IBM Plex Mono", monospace;
  z-index: 10;
}
.lightbox .close-btn:hover { color: #c44d34; }

.lightbox img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  box-shadow: 0 0 40px rgba(0,0,0,0.5);
}

.lightbox .download-link {
  display: inline-block;
  margin-top: 16px;
  color: #aaa;
  font-size: 0.8rem;
  border: 1px solid #555;
  padding: 6px 14px;
  transition: color 0.15s, border-color 0.15s;
}
.lightbox .download-link:hover {
  color: #fff;
  border-color: #aaa;
  text-decoration: none;
}

/* ============================================================
   Admin Page
   ============================================================ */
.admin-body {
  display: flex;
  min-height: 100vh;
  background: #f4f4f4;
}

/* Sidebar */
.admin-sidebar {
  width: 200px;
  min-width: 200px;
  background: #1a1a1a;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.admin-sidebar .brand {
  padding: 20px 16px;
  font-size: 1rem;
  color: #f4f4f4;
  border-bottom: 1px solid #333;
  letter-spacing: 0.05em;
}
.admin-sidebar .brand span { color: #c44d34; }

.admin-sidebar nav { padding: 8px 0; flex: 1; }

.admin-sidebar nav a {
  display: block;
  padding: 10px 16px;
  color: #aaa;
  font-size: 0.8rem;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.admin-sidebar nav a:hover {
  color: #f4f4f4;
  background: #2a2a2a;
}
.admin-sidebar nav a.active {
  color: #f4f4f4;
  border-left-color: #c44d34;
  background: #2a2a2a;
}

.admin-sidebar .logout-area {
  padding: 12px 16px;
  border-top: 1px solid #333;
  font-size: 0.75rem;
  color: #666;
}

/* Main content */
.admin-main {
  margin-left: 200px;
  flex: 1;
  padding: 32px 40px;
  max-width: calc(100vw - 200px);
}

.admin-main h2 {
  font-size: 1.1rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 24px;
  color: #1a1a1a;
}

/* Dashboard stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: #fff;
  border: 1px solid #ddd;
  padding: 20px;
}

.stat-card .stat-value {
  font-size: 1.8rem;
  color: #1a1a1a;
  margin-bottom: 4px;
}

.stat-card .stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
}

/* Buttons */
.btn {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.8rem;
  border: 1px solid #555;
  background: #333;
  color: #eee;
  padding: 6px 12px;
  cursor: pointer;
  border-radius: 0;
  transition: background 0.15s;
}
.btn:hover { background: #444; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: #c44d34;
  border-color: #c44d34;
  color: #fff;
}
.btn-primary:hover { background: #d55a3f; }

.btn-danger {
  background: #a33;
  border-color: #a33;
  color: #fff;
}
.btn-danger:hover { background: #b44; }

.btn-small { font-size: 0.7rem; padding: 3px 8px; }

/* Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #ddd;
  font-size: 0.75rem;
}

.data-table thead th {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 400;
  font-size: 0.7rem;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #ddd;
  background: #fafafa;
  color: #666;
}

.data-table tbody tr:nth-child(even) { background: #fafafa; }
.data-table tbody tr:nth-child(odd) { background: #fff; }
.data-table tbody tr:hover { background: #f0f0f0; }

.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #eee;
  vertical-align: middle;
}

.data-table td .thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  background: #e8e8e8;
}

.data-table .cat-tag {
  display: inline-block;
  font-size: 0.65rem;
  padding: 2px 6px;
  background: #f4f4f4;
  border: 1px solid #ddd;
  color: #666;
}

.data-table .actions {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
}

/* Batch actions bar */
.batch-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0;
  font-size: 0.75rem;
  color: #666;
}

.batch-bar select {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.75rem;
  padding: 3px 6px;
  border: 1px solid #ccc;
  border-radius: 0;
  background: #fff;
}

/* Form elements */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
  margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="file"] {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.85rem;
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 0;
  background: #fff;
  width: 100%;
  max-width: 400px;
}

.form-group input[type="range"] {
  width: 100%;
  max-width: 400px;
  accent-color: #c44d34;
}

.form-group .range-value {
  font-size: 0.85rem;
  color: #1a1a1a;
  margin-left: 8px;
}

/* Watermark preview */
.watermark-preview {
  margin: 16px 0;
  padding: 20px;
  background: #333;
  border: 1px solid #555;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 80px;
  max-width: 400px;
}

.watermark-preview canvas {
  display: block;
}

/* Upload area */
.upload-area {
  border: 2px dashed #ccc;
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  max-width: 500px;
}

.upload-area:hover {
  border-color: #c44d34;
  background: #fefafa;
}

.upload-area.dragover {
  border-color: #c44d34;
  background: #fefafa;
}

.upload-area p {
  font-size: 0.8rem;
  color: #888;
}

/* Message */
.msg {
  padding: 8px 12px;
  margin-bottom: 16px;
  font-size: 0.8rem;
  border: 1px solid;
  max-width: 500px;
}
.msg-success { background: #f0faf0; border-color: #8c8; color: #363; }
.msg-error   { background: #faf0f0; border-color: #c88; color: #633; }

/* Category list */
.category-list {
  list-style: none;
  max-width: 400px;
}

.category-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid #eee;
  font-size: 0.8rem;
}

.category-list li .cat-actions {
  display: flex;
  gap: 4px;
}

/* Responsive admin */
@media (max-width: 768px) {
  .admin-sidebar {
    width: 160px;
    min-width: 160px;
  }
  .admin-main {
    margin-left: 160px;
    padding: 20px;
    max-width: calc(100vw - 160px);
  }
  .data-table { font-size: 0.7rem; }
  .data-table td, .data-table th { padding: 6px 8px; }
}