/* ─────────────────────────────────────────────────────────────────────────────
   LIBOORU - Minimalist & Modern UI Stylesheet
   No Gradients, No Neon Colors. Pure, clean, high-UX media gallery.
   ───────────────────────────────────────────────────────────────────────────── */

:root {
  --bg-main: #09090b;
  --bg-card: #18181b;
  --bg-elevated: #27272a;
  --bg-input: #18181b;
  
  --text-main: #f4f4f5;
  --text-muted: #a1a1aa;
  --text-dim: #71717a;
  
  --border-color: #27272a;
  --border-hover: #3f3f46;
  
  --accent: #e4e4e7;
  --accent-hover: #ffffff;
  --accent-bg: #27272a;
  
  --tag-general: #38bdf8;
  --tag-artist: #f87171;
  --tag-copyright: #c084fc;
  --tag-character: #4ade80;
  --tag-meta: #fbbf24;

  --radius-sm: 3px;
  --radius-md: 4px;
  --radius-lg: 6px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.4);

  --font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg-main: #fafafa;
    --bg-card: #ffffff;
    --bg-elevated: #f4f4f5;
    --bg-input: #ffffff;
    
    --text-main: #09090b;
    --text-muted: #71717a;
    --text-dim: #a1a1aa;
    
    --border-color: #e4e4e7;
    --border-hover: #d4d4d8;
    
    --accent: #18181b;
    --accent-hover: #000000;
    --accent-bg: #e4e4e7;
    
    --tag-general: #0284c7;
    --tag-artist: #dc2626;
    --tag-copyright: #9333ea;
    --tag-character: #16a34a;
    --tag-meta: #d97706;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  }
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.adult-warning-open {
  overflow: hidden;
}

.adult-warning[hidden] {
  display: none;
}

.adult-warning {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.88);
}

.adult-warning-card {
  width: min(100%, 460px);
  padding: 32px;
  background: var(--bg-card);
  box-shadow: var(--shadow-md);
  text-align: center;
}

.adult-warning-card h1 {
  margin: 0 0 12px;
  font-size: 26px;
}

.adult-warning-card p {
  margin: 0 0 24px;
  color: var(--text-muted);
}

.adult-warning-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

.adult-warning-actions button {
  min-width: 130px;
}

.adult-warning-actions button.secondary {
  color: var(--text-muted);
  background: transparent;
}

a {
  color: var(--text-main);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--tag-general);
}

/* ── Header Navigation ─────────────────────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--bg-main);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 24px;
}

header nav {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 1600px;
  margin: 0 auto;
}

header nav a {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13px;
  transition: all 0.15s ease;
}

header nav a:hover {
  color: var(--text-main);
  background-color: var(--bg-elevated);
}

header nav a:first-child {
  padding: 4px 10px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  margin-right: 12px;
  border-radius: var(--radius-sm);
}

header nav a:first-child:hover {
  background-color: transparent;
  color: var(--text-main);
  opacity: 0.85;
}

/* ── Layout & Container ───────────────────────────────────────────────────── */
#container {
  display: flex;
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px;
  gap: 32px;
  min-height: calc(100vh - 60px);
}

main {
  flex-grow: 1;
  min-width: 0;
}

main.full-width {
  width: 100%;
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
#sidebar {
  width: 220px;
  flex-shrink: 0;
}

#sidebar h5 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 12px 0;
  color: var(--text-dim);
  font-weight: 600;
}

#sidebar .form-group {
  margin-bottom: 12px;
}

#sidebar input[type="text"],
#sidebar select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  color: var(--text-main);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease;
}

#sidebar input[type="text"]:focus,
#sidebar select:focus {
  border-color: var(--text-muted);
}

#sidebar button {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  font-size: 13px;
  margin-bottom: 24px;
  transition: background-color 0.15s ease;
}

#sidebar button:hover {
  background: var(--border-hover);
}

#sidebar .tag-list {
  list-style: none;
  padding: 0;
  margin: 0 0 24px 0;
  font-size: 13px;
}

#sidebar .tag-list li {
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#sidebar .tag-list a {
  color: var(--tag-general);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 6px;
}

#sidebar .tag-list a:hover {
  text-decoration: underline;
}

#sidebar .tag-list span {
  color: var(--text-dim);
  font-size: 11px;
  flex-shrink: 0;
}

/* ── Typography & Headings ────────────────────────────────────────────────── */
h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 20px 0;
}

h2 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 24px 0 16px 0;
}

h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 16px 0 12px 0;
}

/* ── Upload Form ──────────────────────────────────────────────────────────── */
.upload-form {
  display: flex;
  width: min(100%, 640px);
  flex-direction: column;
  gap: 18px;
  padding: 4px 0 12px;
}

.upload-form label {
  display: flex;
  width: 100%;
  flex-direction: column;
  gap: 7px;
}

.upload-form label > span {
  line-height: 1.4;
}

.upload-form label small {
  color: var(--text-muted);
  font-weight: 400;
}

.upload-form input,
.upload-form select {
  width: 100%;
}

.upload-form input[type="file"] {
  padding: 10px;
}

.upload-form .upload-rating {
  max-width: 220px;
}

.upload-form > button {
  align-self: flex-start;
  margin-top: 4px;
}
/* ── Post Grid (Infinite / Scrolling UX) ─────────────────────────────────── */
.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.post-thumb {
  display: block;
  position: relative;
  aspect-ratio: 1 / 1;
  background-color: var(--bg-card);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1), border-color 0.2s ease, box-shadow 0.2s ease;
}

.post-thumb:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

.post-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.post-thumb:hover img {
  transform: scale(1.04);
}

.post-thumb.is-video {
  border: 2px solid #38bdf8;
}

.post-thumb.is-video:hover {
  border-color: #0284c7;
}

.post-thumb.is-gif {
  border: 2px solid #4ade80;
}

.post-thumb.is-gif:hover {
  border-color: #16a34a;
}

/* ── Single Post Detail ───────────────────────────────────────────────────── */
.post-view {
  max-width: 1100px;
  margin: 0 auto;
}

.post-image {
  margin-bottom: 24px;
  text-align: center;
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 16px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
}

.post-image img, .post-image video {
  max-width: 100%;
  max-height: 82vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-sm);
}

.post-info {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
  font-size: 13px;
  background: var(--bg-card);
  padding: 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-bottom: 20px;
}

.post-info dt {
  color: var(--text-dim);
  font-weight: 500;
}

.post-info dd {
  margin: 0;
  color: var(--text-main);
}

.post-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

/* ── Form Controls & Buttons ──────────────────────────────────────────────── */
input, select, textarea {
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--text-muted);
}

button {
  background: var(--bg-elevated);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

button:hover {
  background: var(--border-hover);
  border-color: var(--border-hover);
}

/* Filter bar on Browse page */
form select, form input[name="q"] {
  margin-right: 8px;
  margin-bottom: 8px;
}

/* ── Pagination ───────────────────────────────────────────────────────────── */
.pagination {
  margin: 32px 0;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.pagination a {
  padding: 6px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  background: var(--bg-card);
  transition: all 0.15s ease;
}

.pagination a:hover {
  color: var(--text-main);
  border-color: var(--border-hover);
  background: var(--bg-elevated);
  text-decoration: none;
}

.pagination a.active {
  background: var(--text-main);
  color: var(--bg-main);
  border-color: var(--text-main);
  font-weight: 600;
}

.pagination .ellipsis {
  padding: 6px 8px;
  color: var(--text-dim);
}

/* ── Comments ─────────────────────────────────────────────────────────────── */
.comments {
  margin-top: 40px;
  border-top: 1px solid var(--border-color);
  padding-top: 24px;
}

.comment {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 12px;
}

.comment-author {
  font-weight: 600;
  color: var(--text-main);
}

.comment-date {
  color: var(--text-dim);
  font-size: 12px;
  margin-left: 8px;
}

.comment p {
  margin: 8px 0 0 0;
  color: var(--text-muted);
}

/* ── Flash Notifications ──────────────────────────────────────────────────── */
.flash {
  margin: 0 0 16px;
  padding: 2px 0 2px 10px;
  border: 0;
  border-left: 2px solid var(--border-hover);
  border-radius: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 400;
}

.flash-ok {
  border-left-color: #22c55e;
}

.flash-error {
  border-left-color: #ef4444;
}

/* ── Minimalist Home Page ─────────────────────────────────────────────────── */
body:has(.gelbooru-home) {
  background-color: var(--bg-main);
}

body:has(.gelbooru-home) #container {
  max-width: 100% !important;
  width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
}

body:has(.gelbooru-home) header {
  display: none;
}

.gelbooru-home {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 90vh;
  width: 100%;
  padding: 40px 20px;
  color: var(--text-main);
  text-align: center;
}

.gelbooru-title {
  font-size: 3.2rem;
  letter-spacing: -0.04em;
  color: var(--text-main);
  font-weight: 800;
  margin: 0 0 12px 0;
  user-select: none;
}

.gelbooru-home-header {
  display: block;
  box-sizing: border-box;
  width: min(100%, 1300px);
  max-width: 100%;
  max-height: 400px;
  width: auto;
  height: auto;
  object-fit: contain;
  padding-bottom: 16px;
  margin: 0 0 24px;
}

.gelbooru-subnav {
  margin-bottom: 24px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.gelbooru-subnav a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.gelbooru-subnav a:hover {
  color: var(--text-main);
  background-color: var(--bg-elevated);
}

.gelbooru-search-form {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 560px;
  margin: 0 auto 20px auto;
}

.gelbooru-search-input {
  flex-grow: 1;
  padding: 12px 18px;
  font-size: 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-card);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.gelbooru-search-input:focus {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
}

.gelbooru-search-button {
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  color: var(--bg-main);
  background-color: var(--text-main);
  border: 1px solid var(--text-main);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.gelbooru-search-button:hover {
  opacity: 0.9;
  background-color: var(--text-main);
  border-color: var(--text-main);
}

.gelbooru-info-links {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 24px;
  line-height: 1.6;
}

.gelbooru-info-links a {
  color: var(--text-muted);
  text-decoration: none;
}

.gelbooru-info-links a:hover {
  color: var(--text-main);
  text-decoration: underline;
}

/* Minimalist Counter Container - Solid Clean Styling (NO GRADIENT) */
.gelbooru-counter-wrapper {
  position: relative;
  width: 100%;
  padding: 10px 0;
  margin: 10px 0 24px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
}

.blue-band {
  display: none; /* Removed gradient background entirely */
}

.digit-counter {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2px;
}

.counter-mascot {
  height: 145px;
  width: auto;
  object-fit: contain;
}

footer {
  text-align: center;
  padding: 24px;
  border-top: 1px solid var(--border-color);
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 48px;
}

/* Admin panel accordion sections */
.admin-section {
  margin: 12px 0;
  background: var(--bg-card);
  overflow: hidden;
}

.admin-section > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  color: var(--text-main);
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background-color 0.15s ease;
}

.admin-section > summary::-webkit-details-marker {
  display: none;
}

.admin-section > summary::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-left: auto;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.15s ease;
}

.admin-section > summary:hover,
.admin-section > summary:focus-visible {
  background: var(--bg-elevated);
}

.admin-section > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}


.admin-section[open] > summary::after {
  transform: rotate(225deg) translate(-2px, -2px);
}

.admin-section-content {
  padding: 16px;
}

.admin-section-content > :first-child {
  margin-top: 0;
}

.admin-section-content > :last-child {
  margin-bottom: 0;
}

.admin-section-count {
  min-width: 24px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

.admin-role-editor {
  display: flex;
  max-width: 820px;
  flex-direction: column;
  gap: 14px;
}

.admin-role-editor > label {
  display: flex;
  max-width: 420px;
  flex-direction: column;
  gap: 5px;
}

.admin-role-editor fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

.admin-role-editor legend {
  margin-bottom: 8px;
  font-weight: 600;
}

.admin-permissions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 8px 18px;
}

.admin-permissions label {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  color: var(--text-muted);
}

.admin-permissions input {
  margin-top: 3px;
}

.admin-role-card {
  margin-top: 12px;
  padding: 16px;
  background: var(--bg-elevated);
}

.admin-role-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.admin-role-note {
  margin: 0;
  color: var(--text-muted);
}
/* ── Mobile Responsiveness ────────────────────────────────────────────────── */
@media (max-width: 850px) {
  .gelbooru-home {
    padding: 28px 16px 48px;
  }

  .gelbooru-home-header {
    width: 74vw;
    max-width: 74vw;
    max-height: 150px;
    margin-bottom: 28px;
  }

  #container {
    flex-direction: column;
    padding: 12px;
    gap: 20px;
  }

  #sidebar {
    width: 100%;
    order: 2; /* Show tags below the image/posts on mobile */
  }

  main {
    width: 100%;
    order: 1;
  }

  .post-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
  }

  .post-image {
    padding: 8px;
    margin-bottom: 16px;
  }

  .post-info {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .post-info dt {
    margin-top: 8px;
  }
  .post-info dt:first-child {
    margin-top: 0;
  }

  header nav {
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .post-actions {
    justify-content: center;
  }

  /* Hamburger Navbar Toggle */
  #sidebar {
    display: none;
    width: 100%;
    order: 2; /* Show tags below the image/posts on mobile */
  }
  #sidebar.open {
    display: block;
  }
  
  .navbar-hamburger {
    display: inline-block;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 18px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-right: 8px;
  }
}

/* Hide hamburger on desktop */
@media (min-width: 851px) {
  .navbar-hamburger {
    display: none;
  }
}
