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

:root {
  --red:      #e1251b;
  --red-dark: #b81e15;
  --black:    #111111;
  --gray:     #555555;
  --light:    #f5f5f5;
  --border:   #dddddd;
  --white:    #ffffff;
  --shadow:   rgba(0,0,0,0.08);
  --radius:   10px;
}

html { font-size: 16px; }

body {
  font-family: 'Nunito', sans-serif;
  background: var(--white);
  color: var(--black);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* ============================================================
   Nav
   ============================================================ */
.nav {
  background: var(--black);
  color: var(--white);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.75rem;
  color: var(--red);
  letter-spacing: 0.05em;
}
.nav-brand:hover { text-decoration: none; color: var(--white); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.nav-links a {
  color: var(--white);
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  transition: color 0.15s;
}
.nav-links a:hover { color: var(--red); text-decoration: none; }

.nav-logout {
  border: 1px solid rgba(255,255,255,0.3);
  padding: 0.3rem 0.8rem;
  border-radius: 6px;
}
.nav-logout:hover { border-color: var(--red) !important; }

/* ============================================================
   Flash Messages
   ============================================================ */
.flash {
  padding: 0.85rem 1.25rem;
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
}
.flash--success { background: #d4edda; color: #155724; }
.flash--error   { background: #f8d7da; color: #721c24; }
.flash--info    { background: #d1ecf1; color: #0c5460; }

/* ============================================================
   Main Layout
   ============================================================ */
.main {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* ============================================================
   Footer
   ============================================================ */
.footer {
  background: var(--black);
  color: rgba(255,255,255,0.4);
  text-align: center;
  padding: 1rem;
  font-size: 0.8rem;
}

/* ============================================================
   Headings
   ============================================================ */
h1, h2, h3 {
  font-family: 'Bebas Neue', sans-serif;
  letter-spacing: 0.04em;
  line-height: 1.1;
}
h1 { font-size: 2.5rem; }
h2 { font-size: 1.9rem; }
h3 { font-size: 1.4rem; }

.page-title {
  margin-bottom: 1.5rem;
  color: var(--black);
}
.page-title span { color: var(--red); }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius);
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  border: 2px solid transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
  text-decoration: none;
  min-height: 44px;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--red);
  color: var(--white);
  border-color: var(--red);
}
.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); }

.btn-secondary {
  background: var(--white);
  color: var(--black);
  border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--red); color: var(--red); }

.btn-danger {
  background: var(--white);
  color: var(--red);
  border-color: var(--red);
}
.btn-danger:hover { background: var(--red); color: var(--white); }

.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.85rem; min-height: 36px; }
.btn-block { width: 100%; }

/* ============================================================
   Forms
   ============================================================ */
.form-group {
  margin-bottom: 1.1rem;
}

label {
  display: block;
  font-weight: 700;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  color: var(--black);
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-family: 'Nunito', sans-serif;
  font-size: 1rem;
  color: var(--black);
  background: var(--white);
  transition: border-color 0.15s;
  min-height: 44px;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--red);
}

.form-hint {
  font-size: 0.8rem;
  color: var(--gray);
  margin-top: 0.25rem;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 2px 8px var(--shadow);
  overflow: hidden;
}

.card-body { padding: 1.25rem; }
.card-footer { padding: 0.85rem 1.25rem; border-top: 1px solid var(--border); background: var(--light); }

/* ============================================================
   Auth / Center Panel
   ============================================================ */
.auth-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 56px - 48px);
  padding: 2rem 1rem;
}

.auth-box {
  width: 100%;
  max-width: 420px;
}

.auth-logo {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 3.5rem;
  color: var(--red);
  text-align: center;
  margin-bottom: 0.25rem;
  letter-spacing: 0.05em;
}

.auth-subtitle {
  text-align: center;
  color: var(--gray);
  font-size: 0.95rem;
  margin-bottom: 1.75rem;
}

/* ============================================================
   Image Grid
   ============================================================ */
.image-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

@media (min-width: 600px)  { .image-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px)  { .image-grid { grid-template-columns: repeat(4, 1fr); } }

.image-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 2px 6px var(--shadow);
  display: flex;
  flex-direction: column;
  transition: transform 0.15s, box-shadow 0.15s;
}
.image-card:hover { transform: translateY(-3px); box-shadow: 0 6px 18px rgba(0,0,0,0.12); }

.image-card__thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--light);
}

.image-card__body {
  padding: 0.6rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}

.image-card__name {
  font-size: 0.75rem;
  color: var(--gray);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meme-badge {
  display: inline-block;
  background: var(--red);
  color: var(--white);
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  letter-spacing: 0.03em;
}

/* ============================================================
   Upload Zone
   ============================================================ */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 1.5rem;
  position: relative;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--red);
  background: #fff5f5;
}
.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.upload-zone__icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.upload-zone__label { font-weight: 700; font-size: 1rem; margin-bottom: 0.25rem; }
.upload-zone__hint  { font-size: 0.8rem; color: var(--gray); }

/* ============================================================
   Meme Generator
   ============================================================ */
.meme-wrap {
  display: grid;
  gap: 1.5rem;
}

@media (min-width: 720px) {
  .meme-wrap { grid-template-columns: 1fr 340px; align-items: start; }
}

.meme-canvas-wrap {
  background: var(--light);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
}

#meme-canvas {
  max-width: 100%;
  border-radius: 6px;
  display: block;
}

.meme-controls { display: flex; flex-direction: column; gap: 1rem; }

.meme-text-input {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.1rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.meme-text-input::placeholder { font-family: 'Nunito', sans-serif; text-transform: none; font-size: 0.95rem; }

.meme-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }

/* ============================================================
   Slideshow
   ============================================================ */
.slideshow-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.slideshow-mode-bar {
  display: flex;
  gap: 0.5rem;
  background: var(--light);
  padding: 0.4rem;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.slideshow-mode-btn {
  padding: 0.45rem 1rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.85rem;
  border: none;
  cursor: pointer;
  background: transparent;
  color: var(--gray);
  transition: background 0.15s, color 0.15s;
  min-height: 36px;
  font-family: 'Nunito', sans-serif;
}
.slideshow-mode-btn.active,
.slideshow-mode-btn:hover {
  background: var(--red);
  color: var(--white);
}

.slideshow-stage {
  width: 100%;
  max-width: 820px;
  height: 60vh;
  min-height: 300px;
  position: relative;
  background: var(--black);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.slideshow-stage img,
.slideshow-stage canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.slideshow-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.55);
  color: var(--white);
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  z-index: 10;
}
.slideshow-nav:hover { background: var(--red); }
.slideshow-nav--prev { left: 0.75rem; }
.slideshow-nav--next { right: 0.75rem; }

.slideshow-counter {
  font-size: 0.85rem;
  color: var(--gray);
  font-weight: 700;
}

.slideshow-caption {
  text-align: center;
  font-size: 0.85rem;
  color: var(--gray);
  min-height: 1.2em;
}

.slideshow-pause-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.85rem;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--gray);
  transition: border-color 0.15s, color 0.15s;
}
.slideshow-pause-btn:hover,
.slideshow-pause-btn.active { border-color: var(--red); color: var(--red); }

/* Slideshow toast */
.slideshow-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--black);
  color: var(--white);
  padding: 0.65rem 1.25rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: 'Nunito', sans-serif;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 2000;
  pointer-events: none;
  white-space: nowrap;
}
.slideshow-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================================
   Admin Tables
   ============================================================ */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.table th { font-weight: 800; background: var(--light); }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fff8f8; }

/* ============================================================
   Section Header Row
   ============================================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--gray);
}
.empty-state__icon { font-size: 3rem; margin-bottom: 0.75rem; }
.empty-state__text { font-size: 1rem; }

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

.lightbox-close {
  position: fixed;
  top: 0.85rem;
  right: 0.85rem;
  background: rgba(255,255,255,0.1);
  border: none;
  color: var(--white);
  font-size: 1.6rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  z-index: 1001;
  line-height: 1;
}
.lightbox-close:hover { background: var(--red); }

.lightbox-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 60px;
  height: 100px;
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 2.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s;
  z-index: 1001;
}
.lightbox-nav:hover { color: var(--white); background: rgba(225,37,27,0.3); }
.lightbox-nav--prev { left: 0; }
.lightbox-nav--next { right: 0; }

.lightbox-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: calc(100vw - 140px);
  gap: 0.75rem;
}

.lightbox-img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 6px;
  display: block;
}

.lightbox-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 1rem;
  flex-wrap: wrap;
}

.lightbox-filename {
  color: rgba(255,255,255,0.6);
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.lightbox-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

@media (max-width: 500px) {
  .lightbox-nav { width: 44px; font-size: 1.75rem; }
  .lightbox-content { max-width: calc(100vw - 100px); }
}

/* ============================================================
   Slideshow Fullscreen
   ============================================================ */
.slideshow-stage:fullscreen,
.slideshow-stage:-webkit-full-screen {
  max-width: 100vw;
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  border-radius: 0;
}

.slideshow-stage:fullscreen .slideshow-nav,
.slideshow-stage:-webkit-full-screen .slideshow-nav {
  display: none;
}

/* ============================================================
   Utilities
   ============================================================ */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.text-center { text-align: center; }
.text-muted { color: var(--gray); }
.text-red { color: var(--red); }
