/* ============================================================
   CSS Gallery CMS — Light Theme Stylesheet
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --bg:          #f5f6f8;
  --bg2:         #ffffff;
  --bg3:         #f0f1f4;
  --border:      #e2e4e9;
  --border2:     #d0d3db;
  --text:        #1a1d27;
  --text-muted:  #6b7280;
  --accent:      #2563eb;
  --accent-hover:#1d4ed8;
  --accent2:     #7c3aed;
  --up:          #059669;
  --down:        #dc2626;
  --card-radius: 10px;
  --header-h:    62px;
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.10), 0 2px 6px rgba(0,0,0,0.06);
  --shadow-lg:   0 12px 40px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06);
  --font:        'Space Grotesk', system-ui, sans-serif;
  --font-body:   'Inter', system-ui, sans-serif;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }

/* ── Layout ─────────────────────────────────────────────────── */
.container {
  max-width: 1380px;
  margin: 0 auto;
  padding: 0 24px;
}

.layout-with-sidebar {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 32px;
  align-items: start;
  padding-top: 28px;
  padding-bottom: 60px;
}

/* ── Header ─────────────────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.site-header .container {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 100%;
}

.logo {
  font-family: var(--font);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  text-decoration: none;
}
.logo:hover { text-decoration: none; color: var(--accent); }
.logo-icon { color: var(--accent); font-size: 1.4rem; }

.main-nav { display: flex; gap: 2px; }
.main-nav a {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.15s;
}
.main-nav a:hover { color: var(--text); background: var(--bg3); text-decoration: none; }
.main-nav a.active { color: var(--accent); background: #eff6ff; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.search-form {
  display: flex;
  align-items: center;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-form:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.10);
}
.search-form input {
  background: transparent;
  border: none;
  color: var(--text);
  padding: 7px 12px;
  font-size: 0.875rem;
  width: 200px;
  outline: none;
}
.search-form input::placeholder { color: var(--text-muted); }
.search-form button {
  background: transparent;
  border: none;
  padding: 7px 10px;
  color: var(--text-muted);
  font-size: 0.875rem;
}
.search-form button:hover { color: var(--accent); }

.btn-submit {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-submit:hover { background: var(--accent-hover); }

/* ── Ad strips ──────────────────────────────────────────────── */
.ad-strip {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  text-align: center;
  padding: 12px;
}

/* ── Featured strip ─────────────────────────────────────────── */
.featured-strip {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 20px 0;
}
.strip-label {
  font-family: var(--font);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.featured-grid {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
  padding-bottom: 4px;
}
.featured-card {
  flex: 0 0 180px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg3);
  text-decoration: none;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow-sm);
}
.featured-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}
.featured-thumb {
  height: 110px;
  overflow: hidden;
  background: var(--bg3);
}
.featured-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: top;
}
.featured-title {
  display: block;
  padding: 8px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Filters bar ────────────────────────────────────────────── */
.filters-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.filters-left { display: flex; align-items: center; gap: 10px; }
.filter-label { font-size: 0.875rem; color: var(--text-muted); }
.filter-label strong { color: var(--text); }
.clear-filter {
  font-size: 0.75rem;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 4px;
  padding: 3px 8px;
  color: var(--text-muted);
}
.clear-filter:hover { color: var(--down); text-decoration: none; }
.sort-tabs { display: flex; gap: 3px; }
.sort-tab {
  font-size: 0.8rem;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 6px;
  color: var(--text-muted);
  transition: all 0.15s;
  text-decoration: none;
}
.sort-tab:hover { background: var(--bg3); color: var(--text); text-decoration: none; }
.sort-tab.active { background: #eff6ff; color: var(--accent); font-weight: 600; }

/* ── Gallery Grid ───────────────────────────────────────────── */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.gallery-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  overflow: hidden;
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  box-shadow: var(--shadow-sm);
}
.gallery-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border2);
}

.card-thumb-link { display: block; text-decoration: none; }
.card-thumb {
  position: relative;
  height: 200px;
  background: var(--bg3);
  overflow: hidden;
}
.card-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: top;
  transition: transform 0.4s;
}
.gallery-card:hover .card-thumb img { transform: scale(1.03); }

.card-hover-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.40);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}
.gallery-card:hover .card-hover-overlay { opacity: 1; }
.visit-badge {
  background: var(--accent);
  color: #fff;
  padding: 8px 18px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.875rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.no-screenshot {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 16px;
  text-align: center;
  background: linear-gradient(135deg, #f0f1f4, #e8eaef);
}

.card-footer {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg2);
}
.card-meta { min-width: 0; flex: 1; }
.card-title {
  display: block;
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
}
.card-title:hover { color: var(--accent); text-decoration: none; }
.card-url {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
}
.card-url:hover { color: var(--accent); text-decoration: underline; }

.card-category {
  position: absolute;
  top: 10px; left: 10px;
  background: rgba(255,255,255,0.92);
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  backdrop-filter: blur(4px);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid rgba(37,99,235,0.15);
}
.card-category:hover {
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  border-color: var(--accent);
}

/* ── Vote buttons ───────────────────────────────────────────── */
.vote-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}
.vote-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 5px;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 8px;
  transition: all 0.15s;
  min-width: 44px;
  justify-content: center;
}
.vote-btn:hover { border-color: var(--accent); color: var(--accent); background: #eff6ff; }
.vote-up.voted  { border-color: var(--up);   color: var(--up);   background: #f0fdf4; }
.vote-down.voted{ border-color: var(--down); color: var(--down); background: #fef2f2; }
.vote-up:hover  { border-color: var(--up);   color: var(--up);   background: #f0fdf4; }
.vote-down:hover{ border-color: var(--down); color: var(--down); background: #fef2f2; }

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar { position: sticky; top: calc(var(--header-h) + 16px); }
.widget {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.widget-title {
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.cat-list { list-style: none; }
.cat-list li { margin: 1px 0; }
.cat-list a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.875rem;
  transition: all 0.15s;
  text-decoration: none;
}
.cat-list a:hover { background: var(--bg3); color: var(--text); text-decoration: none; }
.cat-list a.active { background: #eff6ff; color: var(--accent); font-weight: 500; }
.cat-list span {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg3);
  border: 1px solid var(--border);
  padding: 1px 7px;
  border-radius: 99px;
}

.widget-submit p {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.5;
}
.btn-submit-lg {
  display: block;
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  text-align: center;
  transition: background 0.15s;
  cursor: pointer;
}
.btn-submit-lg:hover { background: var(--accent-hover); }

.text-links { font-size: 0.875rem; }
.text-links a {
  display: block;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  transition: color 0.15s;
}
.text-links a:last-child { border: none; }
.text-links a:hover { color: var(--accent); text-decoration: none; }

/* ── Pagination ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: 5px;
  justify-content: center;
  align-items: center;
  margin-top: 40px;
  flex-wrap: wrap;
}
.pg-btn, .pg-num {
  padding: 7px 14px;
  border-radius: 7px;
  background: var(--bg2);
  border: 1px solid var(--border2);
  color: var(--text-muted);
  font-size: 0.875rem;
  transition: all 0.15s;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}
.pg-btn:hover, .pg-num:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; background: #eff6ff; }
.pg-num.active { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: none; }
.pg-dots { color: var(--text-muted); padding: 0 4px; }

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}
.empty-state a { color: var(--accent); }

/* ── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 999;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
  overflow-x: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 24px;
  width: 100%;
  max-width: 480px;
  overflow-y: auto;
  position: relative;
  margin: auto;
  transform: translateY(20px);
  transition: transform 0.25s;
  box-shadow: var(--shadow-lg);
  flex-shrink: 0;
  box-sizing: border-box;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 30px; height: 30px;
  color: var(--text-muted);
  font-size: 0.8rem;
  transition: all 0.15s;
}
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-title {
  font-family: var(--font);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
}

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 7px;
  color: var(--text);
  padding: 9px 12px;
  font-size: 0.9rem;
  font-family: var(--font-body);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.10);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-group select { appearance: none; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }

.btn-primary {
  display: block;
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 11px;
  font-size: 1rem;
  font-weight: 700;
  transition: background 0.15s;
  margin-top: 6px;
  cursor: pointer;
}
.btn-primary:hover { background: var(--accent-hover); }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  font-weight: 500;
}
.alert-success { background: #f0fdf4; border: 1px solid #86efac; color: #166534; }
.alert-error   { background: #fef2f2; border: 1px solid #fca5a5; color: #991b1b; }

/* ── Footer ─────────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 20px 0;
  background: var(--bg2);
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.footer-copy { font-size: 0.8rem; color: var(--text-muted); }
.footer-nav { display: flex; gap: 16px; }
.footer-nav a { font-size: 0.8rem; color: var(--text-muted); }
.footer-nav a:hover { color: var(--accent); }

/* ── Admin bar ──────────────────────────────────────────────── */
.admin-bar {
  background: var(--accent);
  color: #fff;
  text-align: center;
  padding: 6px;
  font-size: 0.8rem;
}
.admin-bar a { color: #fff; font-weight: 600; margin: 0 10px; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .layout-with-sidebar { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
  }
  .widget { margin-bottom: 0; }
}

@media (max-width: 768px) {
  .site-header .container { gap: 12px; }
  .main-nav { display: none; }
  .search-form input { width: 140px; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
  .header-actions { gap: 8px; }
  .sidebar { display: block; }
}

@media (max-width: 480px) {
  .btn-submit span { display: none; }
  .filters-bar { flex-direction: column; align-items: flex-start; }
}