/**
 * Reka Gallery Stylesheet
 * Responsive RTL gallery & album stylesheet for reka.us
 * Lightweight custom replacement for NextGEN Gallery
 */

/* ==========================================================================
   1. Theme Variables & Base RTL
   ========================================================================== */
:root {
  --reka-primary: #2563eb;
  --reka-primary-hover: #1d4ed8;
  --reka-text: #1e293b;
  --reka-muted: #64748b;
  --reka-bg: #ffffff;
  --reka-card-bg: #ffffff;
  --reka-border: #e2e8f0;
  --reka-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --reka-shadow-hover: 0 8px 16px rgba(0, 0, 0, 0.15);
}

.reka-gallery,
.reka-gallery-container,
.reka-gallery-grid,
.reka-album-extend,
.reka-album-compact,
.reka-gallery-pagination,
.reka-gallery-count {
  direction: rtl;
  text-align: right;
  box-sizing: border-box;
}

.reka-gallery *,
.reka-album-extend *,
.reka-album-compact * {
  box-sizing: border-box;
}

/* Reset */
.reka-gallery img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ==========================================================================
   2. Gallery Grid & Items
   ========================================================================== */
.reka-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin: 0 0 24px;
  padding: 0;
  list-style: none;
}

.reka-gallery-item {
  position: relative;
  margin: 0;
  border-radius: 8px;
  overflow: hidden;
  background: var(--reka-card-bg);
  box-shadow: var(--reka-shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.reka-gallery-item:hover {
  transform: scale(1.03);
  box-shadow: var(--reka-shadow-hover);
  z-index: 2;
}

.reka-gallery-item a {
  display: block;
  width: 100%;
  height: 100%;
  text-decoration: none;
}

.reka-gallery-item img {
  width: 100%;
  height: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

/* Portrait / Mobile Wallpaper Support (9:16 Aspect Ratio) */
.reka-gallery-grid.is-portrait-grid {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}

.reka-gallery-item.is-portrait img {
  aspect-ratio: 9 / 16;
}

/* Dual Monitor / Panoramic Wallpaper Support (32:9 Aspect Ratio) */
.reka-gallery-grid.is-panoramic-grid {
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}

.reka-gallery-item.is-panoramic img {
  aspect-ratio: 32 / 9;
}

/* Triple Monitor Super Ultrawide Support (48:9 Aspect Ratio) */
.reka-gallery-grid.is-triple-grid {
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
}

.reka-gallery-item.is-triple img {
  aspect-ratio: 48 / 9;
}

/* ==========================================================================
   3. Album Views (Extended & Compact)
   ========================================================================== */
/* Extended: Stack of horizontal cards (RTL: image right, info left) */
.reka-album-extend {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 0 0 24px;
}

.reka-album-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 16px;
  background: var(--reka-card-bg);
  border: 1px solid var(--reka-border);
  border-radius: 8px;
  padding: 12px;
  box-shadow: var(--reka-shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.reka-album-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--reka-shadow-hover);
}

.reka-album-card img,
.reka-album-preview {
  width: 200px;
  min-width: 200px;
  height: 130px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
}

.reka-album-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.reka-album-title,
.reka-album-title a {
  color: var(--reka-primary);
  text-decoration: none;
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  transition: color 0.2s ease;
}

.reka-album-title a:hover {
  text-decoration: underline;
  color: var(--reka-primary-hover);
}

.reka-album-desc {
  color: var(--reka-muted);
  font-size: 0.9rem;
  margin: 0;
  line-height: 1.5;
}

.reka-album-badge,
.reka-album-count-badge,
.reka-album-count {
  align-self: flex-start;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 9999px;
  background: #f1f5f9;
  color: var(--reka-muted);
  border: 1px solid var(--reka-border);
}

/* Compact: CSS Grid of square-ish thumbnails with overlaid text */
.reka-album-compact {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin: 0 0 24px;
}

.reka-album-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--reka-shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.reka-album-thumb:hover {
  transform: scale(1.03);
  box-shadow: var(--reka-shadow-hover);
  z-index: 2;
}

.reka-album-thumb a.reka-album-link {
  display: block;
  width: 100%;
  height: 100%;
  text-decoration: none;
  color: inherit;
}

.reka-album-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.reka-album-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 24px 10px 8px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.4) 60%, transparent 100%);
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  pointer-events: none;
}

.reka-album-label .reka-album-count {
  display: block;
  font-size: 0.8rem;
  font-weight: 400;
  opacity: 0.9;
  margin-top: 2px;
  background: transparent;
  border: none;
  color: #ffffff;
  padding: 0;
}

/* ==========================================================================
   4. Pagination & Gallery Count
   ========================================================================== */
.reka-gallery-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 24px 0 8px;
}

.reka-gallery-pagination a,
.reka-gallery-pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  font-size: 14px;
  color: var(--reka-text);
  background: var(--reka-card-bg);
  border: 1px solid var(--reka-border);
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.reka-gallery-pagination a:hover {
  border-color: var(--reka-primary);
  color: var(--reka-primary);
  background: #eff6ff;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.reka-gallery-pagination .reka-page-current,
.reka-gallery-pagination span.reka-page-current,
.reka-gallery-pagination .current,
.reka-gallery-pagination span.current {
  background: var(--reka-primary) !important;
  border-color: var(--reka-primary) !important;
  color: #ffffff !important;
  font-weight: 700 !important;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35) !important;
  cursor: default !important;
  transform: scale(1.05);
  pointer-events: none;
}

.reka-page-ellipsis,
.reka-gallery-pagination .reka-page-ellipsis {
  border: none !important;
  background: transparent !important;
  color: var(--reka-muted);
  min-width: auto;
  padding: 0 4px;
  cursor: default;
}

.reka-gallery-count {
  text-align: center;
  font-size: 13px;
  color: var(--reka-muted);
  margin: 6px 0 20px;
}

/* ==========================================================================
   5. Advertisement Slots
   ========================================================================== */
.reka-gallery-ad {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 90px;
  width: 100%;
  margin: 12px 0;
  text-align: center;
}

/* ==========================================================================
   6. Mobile Breakpoints
   ========================================================================== */
@media (max-width: 768px) {
  .reka-gallery-grid,
  .reka-album-compact {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
  .reka-album-card {
    flex-direction: column;
    align-items: stretch;
  }
  .reka-album-card img,
  .reka-album-preview {
    width: 100%;
    min-width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }
  .reka-admin-album-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px;
  }
  .reka-admin-album-bar-title {
    text-align: right;
    font-size: 14px;
  }
  .reka-admin-album-bar-actions {
    display: flex;
    gap: 8px;
    width: 100%;
    flex-wrap: wrap;
  }
  .reka-admin-album-bar-actions .reka-admin-btn-edit {
    flex: 1;
    min-width: 130px;
    justify-content: center;
    text-align: center;
    padding: 8px 12px;
    font-size: 13px;
  }
  .reka-admin-single-controls {
    border-radius: 12px;
    padding: 10px 14px;
    width: 100%;
    box-sizing: border-box;
    gap: 8px;
  }
  .reka-admin-single-controls button,
  .reka-admin-single-controls a {
    flex: 1 1 100%;
    justify-content: center;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .reka-gallery-grid,
  .reka-album-compact {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 8px;
  }
  .reka-album-label {
    font-size: 0.82rem;
    padding: 20px 6px 6px;
    line-height: 1.25;
  }
  .reka-admin-compact-edit-badge {
    top: 6px;
    right: 6px;
    padding: 3px 7px;
    font-size: 10px;
    gap: 2px;
  }
  .reka-admin-album-bar {
    padding: 10px 12px;
    margin-bottom: 16px;
  }
  .reka-admin-album-bar-actions {
    flex-direction: column;
  }
  .reka-admin-album-bar-actions .reka-admin-btn-edit {
    width: 100%;
  }
}

/* ==========================================================================
   7. Dark Mode
   ========================================================================== */
@media (prefers-color-scheme: dark) {
  :root {
    --reka-text: #f1f5f9;
    --reka-muted: #94a3b8;
    --reka-bg: #1a1a2e;
    --reka-card-bg: #2d2d44;
    --reka-border: #3f3f5a;
    --reka-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    --reka-shadow-hover: 0 8px 18px rgba(0, 0, 0, 0.6);
  }
  .reka-gallery-pagination a:hover {
    background: #383856;
    border-color: var(--reka-primary);
  }
  .reka-album-badge,
  .reka-album-count-badge,
  .reka-album-card .reka-album-count {
    background: #383856;
    border-color: #4a4a6e;
    color: #cbd5e1;
  }
}

/* ==========================================================================
   8. Admin Fast Controls (Logged-in Admins Only)
   ========================================================================== */
.reka-admin-single-controls {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  padding: 8px 18px;
  border-radius: 99px;
  margin: 0 auto 20px;
  font-size: 13px;
}

.reka-admin-single-label {
  font-weight: 700;
  color: #991b1b;
}

.reka-admin-btn-delete {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #dc2626;
  color: #ffffff !important;
  border: 1px solid #b91c1c;
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.reka-admin-btn-delete:hover {
  background: #b91c1c;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(220, 38, 38, 0.35);
}

.reka-admin-btn-edit {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #ffffff;
  color: #2563eb !important;
  border: 1px solid #bfdbfe;
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.reka-admin-btn-edit:hover {
  background: #2563eb;
  color: #ffffff !important;
  border-color: #2563eb;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

.reka-admin-btn-caption {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #0284c7;
  color: #ffffff !important;
  border: 1px solid #0369a1;
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.reka-admin-btn-caption:hover {
  background: #0369a1;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.35);
}

.reka-caption-edit-modal {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  padding: 20px;
  margin: 15px auto 25px;
  max-width: 550px;
  text-align: right;
  direction: rtl;
  animation: rekaSlideDown 0.25s ease-out;
}

@keyframes rekaSlideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.reka-caption-edit-modal h3 {
  margin: 0 0 15px;
  font-size: 16px;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
}

.reka-caption-field {
  margin-bottom: 14px;
}

.reka-caption-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
  text-align: right;
}

.reka-caption-input,
.reka-caption-textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  direction: rtl;
}

.reka-caption-input:focus,
.reka-caption-textarea:focus {
  border-color: #0284c7;
  outline: none;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.reka-caption-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 15px;
}

.reka-caption-btn-save {
  background: #0284c7;
  color: #ffffff;
  border: none;
  padding: 8px 20px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.reka-caption-btn-save:hover {
  background: #0369a1;
}

.reka-caption-btn-cancel {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
}

.reka-caption-btn-cancel:hover {
  background: #e2e8f0;
}

.reka-caption-msg {
  font-size: 13px;
  margin-right: 10px;
  font-weight: 500;
}

.reka-caption-msg.success {
  color: #16a34a;
}

.reka-caption-msg.error {
  color: #dc2626;
}

.reka-admin-album-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-right: 4px solid #2563eb;
  padding: 10px 18px;
  border-radius: 8px;
  margin-bottom: 24px;
  font-size: 14px;
}

.reka-admin-album-bar-title {
  color: #334155;
  font-weight: 500;
}

.reka-admin-album-bar-title strong {
  color: #1e293b;
}

.reka-admin-card-edit-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: #2563eb;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 2px 8px;
  border-radius: 4px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.reka-admin-card-edit-link:hover {
  background: #2563eb;
  color: #ffffff !important;
  border-color: #2563eb;
}

.reka-album-card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.reka-admin-compact-edit-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
  width: auto !important;
  height: auto !important;
  max-width: max-content;
  max-height: max-content;
  background: rgba(37, 99, 235, 0.92);
  color: #ffffff !important;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  padding: 4px 9px;
  border-radius: 99px;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
  transition: all 0.2s ease;
  display: inline-flex !important;
  align-items: center;
  gap: 3px;
  box-sizing: border-box;
  pointer-events: auto;
}

.reka-admin-compact-edit-badge:hover {
  background: #1d4ed8;
  transform: scale(1.06);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  color: #ffffff !important;
}
