/* @brief Custom CSS overrides for the CMS. */

/* Honeypot field — hidden from humans, catches bots that auto-fill all fields */
.hp { display: none !important; }

/* Breadcrumb separators in nav left side */
.nav-crumbs li + li::before {
  content: "›";
  padding-right: 0.5rem;
  color: var(--pico-muted-color);
}

/* Mobile responsive nav — stack vertically and hide less critical items */
@media (max-width: 768px) {
  nav.container-fluid {
    flex-direction: column;
    padding: 0.5rem;
  }
  nav.container-fluid > ul {
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.25rem;
  }
  /* Hide Help and Settings on small screens — accessible via Dashboard */
  nav.container-fluid > ul:last-child .nav-hide-mobile {
    display: none;
  }
}

/* Smooth scrolling for TOC anchor links */
html {
  scroll-behavior: smooth;
}

/* Flash message bar */
.flash-message {
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border-radius: 4px;
  background-color: var(--pico-primary-background);
  color: var(--pico-primary-inverse);
}

/* Flash banner for admin pages — prominent colored alert, auto-fades */
.flash-banner {
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
  border-radius: 4px;
  border: 2px solid #1565c0;
  background-color: #e3f2fd;
  color: #0d47a1;
  font-weight: 600;
  animation: flash-fade 4s ease-in forwards;
}
@keyframes flash-fade {
  0%, 70% { opacity: 1; }
  100% { opacity: 0; display: none; }
}
.flash-banner.flash-error {
  border-color: #c62828;
  background-color: #ffebee;
  color: #b71c1c;
}
@media (prefers-color-scheme: dark) {
  .flash-banner {
    background-color: #0d2137;
    color: #90caf9;
    border-color: #42a5f5;
  }
  .flash-banner.flash-error {
    background-color: #3e1010;
    color: #ef9a9a;
    border-color: #ef5350;
  }
}

/* Edit toolbar */
.page-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

/* Search dropdown overlay */
.search-dropdown {
  position: absolute;
  z-index: 100;
  background: var(--pico-background-color);
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 4px;
  max-height: 400px;
  overflow-y: auto;
  width: 100%;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.search-dropdown a {
  display: block;
  padding: 0.5rem 1rem;
  text-decoration: none;
}

.search-dropdown a:hover {
  background-color: var(--pico-secondary-background);
}

/* Visibility badge icons */
.badge-private::before { content: "🔒 "; }
.badge-scheduled::before { content: "⏰ "; }

/* TOC sidebar */
.toc-sidebar {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}

/* Private file placeholder */
img[src$="private-file.svg"] {
  opacity: 0.5;
  max-width: 200px;
}

/* Delete buttons — red for destructive actions */
.btn-danger {
  --pico-color: #c62828;
  --pico-border-color: #c62828;
  color: #c62828;
  border-color: #c62828;
}
.btn-danger:hover {
  --pico-color: #fff;
  --pico-background-color: #c62828;
  --pico-border-color: #c62828;
  background-color: #c62828;
  color: #fff;
}

/* Visibility toggle — normal text color, not disabled-looking */
.btn-vis {
  --pico-color: var(--pico-primary);
  --pico-border-color: var(--pico-primary);
  color: var(--pico-primary);
  border-color: var(--pico-primary);
}
.btn-vis:hover {
  --pico-background-color: var(--pico-primary);
  background-color: var(--pico-primary);
  color: var(--pico-primary-inverse);
}

/* Status badge for enabled/disabled */
.badge-enabled {
  color: #2e7d32;
}
.badge-disabled {
  color: #c62828;
}

/* Editor container */
#editor-container {
  min-height: 400px;
}

/* Editor Save/Cancel actions — same row, compact */
.editor-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.editor-actions button {
  width: auto;
  padding: 0.4rem 1.5rem;
}

/* Warning button (Cancel) — amber/orange */
.btn-warning {
  --pico-color: #e65100;
  --pico-border-color: #e65100;
  color: #e65100;
  border-color: #e65100;
}
.btn-warning:hover {
  --pico-color: #fff;
  --pico-background-color: #e65100;
  --pico-border-color: #e65100;
  background-color: #e65100;
  color: #fff;
}

/* Admin table button sizing */
.btn-sm {
  padding: 0.15rem 0.5rem;
  margin: 0.1rem;
  font-size: 0.875rem;
}

/* User actions cell — uniform button widths */
.user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}
.user-actions form {
  display: inline;
  margin: 0;
}
.user-actions .btn-sm {
  min-width: 6rem;
  text-align: center;
}

/* Footer content */
.site-footer {
  text-align: center;
  padding: 1rem 0;
  margin-top: 2rem;
  border-top: 1px solid var(--pico-muted-border-color);
  color: var(--pico-muted-color);
}

.copyright-footer {
  text-align: center;
  padding: 0.5rem 0;
  margin-top: 1rem;
  color: var(--pico-muted-color);
}

/* CSP-safe replacements for prior inline style attributes */
.editor-textarea {
  width: 100%;
  font-family: monospace;
}

.text-center {
  text-align: center;
}

.text-danger {
  color: var(--pico-del-color);
}

.text-muted {
  color: var(--pico-muted-color);
}

.toc-indent {
  margin-left: 1em;
}

.nav-inline-form {
  display: inline;
  margin: 0;
}

.nav-link-button {
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  color: var(--pico-primary);
  text-decoration: underline;
  cursor: pointer;
  font-size: inherit;
}

.admin-nav-logout-btn {
  padding: 0.25rem 0.75rem;
}

.btn-auto {
  width: auto;
}

/* Inline form validation error */
.field-error {
  display: block;
  margin-top: 0.25rem;
  padding: 0.375rem 0.75rem;
  border-radius: 4px;
  background-color: #fff3cd;
  color: #856404;
  font-weight: 500;
  border: 1px solid #ffc107;
}
@media (prefers-color-scheme: dark) {
  .field-error {
    background-color: #3e3209;
    color: #ffd54f;
    border-color: #f9a825;
  }
}

/* Upload file picker wrapper */
.upload-file-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.upload-file-status {
  font-size: 0.875rem;
  color: var(--pico-muted-color);
}

.auth-shell {
  max-width: 420px;
  padding-top: 4rem;
}

.auth-shell-420 {
  max-width: 420px;
  margin: 4rem auto;
  padding: 2rem;
}

.auth-shell-480 {
  max-width: 480px;
  margin: 4rem auto;
  padding: 2rem;
}

.move-form {
  display: flex;
  gap: 0.5rem;
  align-items: end;
}

.move-form-full {
  padding: 0.5rem 0;
}

.move-form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.flex-grow {
  flex: 1;
}

/* Storage file listing — scrollable container with collapsible folder groups */
.storage-listing {
  max-height: 600px;
  overflow-y: auto;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: 4px;
  padding: 0.5rem;
}
.storage-listing details {
  margin-bottom: 0.5rem;
}
.storage-listing summary {
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 4px;
}
.storage-listing summary:hover {
  background-color: var(--pico-secondary-background);
}
.storage-listing table {
  margin-top: 0.25rem;
  margin-bottom: 0;
}

/* EasyMDE/CodeMirror: prevent Pico classless CSS from overriding editor styles.
   Pico classless targets raw elements (button, a, i, etc.) which conflicts
   with EasyMDE's toolbar and CodeMirror's editor layout. */
.EasyMDEContainer button,
.EasyMDEContainer a {
  all: unset;
  cursor: pointer;
}
.EasyMDEContainer i.fa {
  font-family: "FontAwesome" !important;
  font-style: normal !important;
  font-weight: normal !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Image gallery grid */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.5rem;
  margin: 1rem 0;
}
.gallery img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  transition: opacity 0.2s;
}
.gallery img:hover {
  opacity: 0.85;
}

/* GLightbox: prevent Pico classless from overriding lightbox overlay */
.goverlay,
.glightbox-container,
.gslide,
.gslide-media {
  all: unset;
}

/* Plyr: prevent Pico classless CSS from overriding player controls */
.plyr button,
.plyr a,
.plyr input[type="range"] {
  all: unset;
}
.plyr {
  margin: 1rem 0;
}
.plyr__video-embed {
  margin: 1rem 0;
}

/* Blog post prev/next navigation arrows */
.post-nav {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--pico-muted-border-color);
}
.post-nav a {
  max-width: 45%;
  text-decoration: none;
}
.post-nav-prev {
  text-align: left;
}
.post-nav-next {
  text-align: right;
  margin-left: auto;
}

/* Blog listing pagination */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--pico-muted-border-color);
}
.pagination-prev,
.pagination-next {
  min-width: 5rem;
  text-decoration: none;
}
.pagination-prev {
  text-align: left;
}
.pagination-next {
  text-align: right;
}
.pagination-pages {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}
.pagination-pages a,
.pagination-current {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  text-decoration: none;
  min-width: 2rem;
  text-align: center;
}
.pagination-current {
  font-weight: 700;
  background-color: var(--pico-primary);
  color: var(--pico-primary-inverse);
}
.pagination-pages a:hover {
  background-color: var(--pico-secondary-background);
}
.pagination-ellipsis {
  padding: 0 0.25rem;
  color: var(--pico-muted-color);
}

/* Cart badge — hide nav link when cart is empty */
#cart-badge:empty { display: none; }
li:has(> a > #cart-badge:empty) { display: none; }

/* Cart quantity controls — inline +/− buttons */
.qty-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0;
}
.qty-display {
  display: inline-block;
  min-width: 2rem;
  text-align: center;
  font-weight: 600;
}

/* Disabled checkout button when Stripe is unconfigured */
.checkout-disabled-btn {
  opacity: 0.5;
  cursor: not-allowed;
}

