/* ============================================================
   THE SALT & PEPPER COLLECTION — Main Stylesheet
   Warm, cozy aesthetic: creams, terracottas, wood tones
   Fonts: Playfair Display (headings) + Lora (body)
   ============================================================ */

/* --- CSS Variables --- */
:root {
  --cream:       #f9f4ec;
  --cream-dark:  #f0e8d8;
  --cream-card:  #fdf9f3;
  --parchment:   #e8dcc8;
  --clay:        #b85c38;
  --clay-light:  #d4795a;
  --clay-dark:   #8e3e22;
  --terracotta:  #c9684a;
  --amber:       #c4843a;
  --wood:        #7a4f2e;
  --wood-light:  #a3734e;
  --espresso:    #2e1a0e;
  --text:        #3b2412;
  --text-muted:  #7a5c42;
  --text-light:  #a07a58;
  --shadow-sm:   0 2px 8px rgba(62,28,10,0.08);
  --shadow-md:   0 6px 24px rgba(62,28,10,0.12);
  --shadow-lg:   0 12px 48px rgba(62,28,10,0.16);
  --radius:      12px;
  --radius-sm:   8px;
  --radius-lg:   20px;
  --transition:  0.22s ease;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Lora', Georgia, serif;
  background-color: var(--cream);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(196,132,58,0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(184,92,56,0.07) 0%, transparent 60%);
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }

/* --- Header --- */
.site-header {
  background: linear-gradient(135deg, var(--espresso) 0%, var(--wood) 100%);
  color: var(--cream);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 16px rgba(46,26,14,0.35);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.header-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.header-eyebrow {
  font-family: 'Lora', serif;
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--parchment);
  opacity: 0.75;
}

.site-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--cream);
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.title-link { color: inherit; }
.title-link:hover { color: var(--parchment); }

.header-subtitle {
  font-family: 'Lora', serif;
  font-style: italic;
  font-size: 0.78rem;
  color: var(--parchment);
  opacity: 0.7;
}

.header-nav {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.nav-link {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: 'Lora', serif;
  font-size: 0.85rem;
  color: var(--parchment);
  transition: background var(--transition), color var(--transition);
  border: 1px solid transparent;
}

.nav-link:hover, .nav-link.active {
  background: rgba(249,244,236,0.12);
  color: var(--cream);
  border-color: rgba(249,244,236,0.2);
}

/* --- Main Content --- */
.main-content {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 32px 64px;
  width: 100%;
}

/* --- Controls Bar (Search + Sort) --- */
.controls-bar {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.search-wrap {
  flex: 1;
  min-width: 260px;
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--text-light);
  pointer-events: none;
  flex-shrink: 0;
}

.search-input {
  width: 100%;
  padding: 12px 40px 12px 42px;
  border: 2px solid var(--parchment);
  border-radius: 40px;
  font-family: 'Lora', serif;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--cream-card);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.search-input:focus {
  border-color: var(--clay);
  box-shadow: 0 0 0 3px rgba(184,92,56,0.12);
}

.search-input::placeholder { color: var(--text-light); font-style: italic; }

.search-clear {
  position: absolute;
  right: 14px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  padding: 4px;
  line-height: 1;
  transition: color var(--transition);
}
.search-clear:hover { color: var(--clay); }

.sort-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.sort-label {
  font-family: 'Lora', serif;
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.sort-select {
  padding: 10px 14px;
  border: 2px solid var(--parchment);
  border-radius: var(--radius-sm);
  font-family: 'Lora', serif;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--cream-card);
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
}
.sort-select:focus { border-color: var(--clay); }

/* --- Results Info --- */
.results-info {
  font-family: 'Lora', serif;
  font-size: 0.82rem;
  font-style: italic;
  color: var(--text-light);
  margin-bottom: 20px;
  min-height: 1.2em;
}

/* --- Gallery Grid --- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 24px;
}

.gallery-card {
  display: block;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--cream-card);
  box-shadow: var(--shadow-sm);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  opacity: 0;
  animation: fadeUp 0.45s ease forwards;
  border: 1px solid rgba(200,170,130,0.3);
}

.gallery-card:hover {
  transform: translateY(-5px) scale(1.01);
  box-shadow: var(--shadow-lg);
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-image-wrap {
  position: relative;
  width: 100%;
  padding-bottom: 100%; /* square */
  overflow: hidden;
  background: var(--cream-dark);
}

.card-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.gallery-card:hover .card-image {
  transform: scale(1.06);
}

.card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(46,26,14,0.82) 0%, rgba(46,26,14,0.1) 55%, transparent 100%);
  opacity: 0;
  transition: opacity 0.28s ease;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 16px;
  gap: 4px;
}

.gallery-card:hover .card-overlay { opacity: 1; }

.card-name {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  line-height: 1.3;
  text-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.card-country {
  font-family: 'Lora', serif;
  font-size: 0.75rem;
  color: var(--parchment);
  opacity: 0.85;
  font-style: italic;
}

/* --- Gallery Empty / Loading --- */
.gallery-loading, .gallery-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 32px;
  color: var(--text-muted);
  font-style: italic;
}

.loading-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
}

.loading-dots span {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--clay);
  opacity: 0.3;
  animation: dot-pulse 1.4s ease-in-out infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot-pulse {
  0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
  40%           { opacity: 1;   transform: scale(1.1); }
}

/* --- Set Detail Page --- */
.set-page .main-content { padding-top: 48px; }

.set-main { padding-bottom: 80px; }

.set-loading { text-align: center; padding: 80px 32px; color: var(--text-muted); font-style: italic; }

.set-detail {
  display: flex;
  gap: 56px;
  align-items: flex-start;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.set-detail.visible {
  opacity: 1;
  transform: translateY(0);
}

.set-image-side {
  flex: 0 0 420px;
  max-width: 420px;
}

.set-image-frame {
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg), 0 0 0 6px var(--cream-card), 0 0 0 8px var(--parchment);
  background: var(--cream-dark);
  aspect-ratio: 1;
}

.set-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.set-info-side {
  flex: 1;
  min-width: 0;
  padding-top: 8px;
}

.set-tag {
  display: inline-block;
  background: var(--cream-dark);
  color: var(--text-muted);
  border: 1px solid var(--parchment);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: 'Lora', serif;
  margin-bottom: 14px;
}

.set-name {
  font-family: 'Playfair Display', serif;
  font-size: 2.2rem;
  font-weight: 600;
  color: var(--espresso);
  line-height: 1.2;
  margin-bottom: 28px;
  letter-spacing: -0.02em;
}

.set-meta {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 32px;
  border-top: 1px solid var(--parchment);
  border-bottom: 1px solid var(--parchment);
}

.meta-row {
  display: flex;
  gap: 20px;
  padding: 13px 0;
  border-bottom: 1px solid rgba(200,170,130,0.25);
}
.meta-row:last-child { border-bottom: none; }

.meta-row dt {
  flex: 0 0 130px;
  font-family: 'Lora', serif;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-light);
  padding-top: 2px;
}

.meta-row dd {
  font-family: 'Lora', serif;
  font-size: 0.96rem;
  color: var(--text);
  font-style: italic;
}

.desc-label {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--wood);
  margin-bottom: 10px;
  letter-spacing: -0.01em;
}

.set-description {
  font-family: 'Lora', serif;
  font-size: 0.96rem;
  line-height: 1.75;
  color: var(--text-muted);
  font-style: italic;
}

.set-description-wrap {
  margin-bottom: 36px;
}

.set-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.set-error { text-align: center; padding: 80px 32px; color: var(--text-muted); font-style: italic; }

/* --- Buttons --- */
.btn-back, .btn-soft, .btn-primary, .btn-danger, .btn-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  font-family: 'Lora', serif;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background var(--transition), transform 0.12s, box-shadow var(--transition);
  text-decoration: none;
}
.btn-back:active, .btn-soft:active, .btn-primary:active { transform: scale(0.97); }

.btn-back {
  background: var(--cream-dark);
  color: var(--text-muted);
  border: 1px solid var(--parchment);
}
.btn-back:hover { background: var(--parchment); color: var(--text); }

.btn-soft {
  background: var(--cream-dark);
  color: var(--text-muted);
  border: 1px solid var(--parchment);
}
.btn-soft:hover { background: var(--parchment); color: var(--text); }

.btn-primary {
  background: var(--clay);
  color: #fff;
  box-shadow: 0 2px 8px rgba(184,92,56,0.3);
}
.btn-primary:hover { background: var(--clay-dark); box-shadow: 0 4px 14px rgba(184,92,56,0.4); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-edit {
  background: var(--amber);
  color: #fff;
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  font-family: 'Lora', serif;
  font-size: 0.88rem;
  transition: background var(--transition);
}
.btn-edit:hover { background: var(--wood-light); }

.btn-danger {
  background: #b83232;
  color: #fff;
}
.btn-danger:hover { background: #8e2222; }
.btn-danger:disabled { opacity: 0.6; cursor: not-allowed; }

/* --- Footer --- */
.site-footer {
  background: var(--espresso);
  color: var(--parchment);
  text-align: center;
  padding: 20px 32px;
  font-family: 'Lora', serif;
  font-size: 0.8rem;
  font-style: italic;
  opacity: 0.85;
}

/* --- Login Page --- */
.login-page { background: var(--cream); }

.login-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}

.login-card {
  background: var(--cream-card);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--parchment);
}

.login-back {
  display: block;
  font-size: 0.82rem;
  color: var(--text-light);
  margin-bottom: 28px;
  transition: color var(--transition);
  font-style: italic;
}
.login-back:hover { color: var(--clay); }

.login-header { text-align: center; margin-bottom: 32px; }

.login-icon { font-size: 2.5rem; margin-bottom: 12px; }

.login-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.7rem;
  font-weight: 600;
  color: var(--espresso);
  margin-bottom: 6px;
}

.login-sub {
  font-family: 'Lora', serif;
  font-size: 0.85rem;
  color: var(--text-light);
  font-style: italic;
}

.login-form { display: flex; flex-direction: column; gap: 16px; }

/* --- Forms --- */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label {
  font-family: 'Lora', serif;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}
.required { color: var(--clay); }
.form-optional { color: var(--text-light); font-weight: 400; font-style: italic; }

.form-input {
  padding: 11px 14px;
  border: 2px solid var(--parchment);
  border-radius: var(--radius-sm);
  font-family: 'Lora', serif;
  font-size: 0.93rem;
  color: var(--text);
  background: var(--cream);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}
.form-input:focus {
  border-color: var(--clay);
  box-shadow: 0 0 0 3px rgba(184,92,56,0.1);
}
.form-textarea { resize: vertical; min-height: 100px; line-height: 1.6; }

.form-error {
  background: #fef0ed;
  border: 1px solid #e8b4a0;
  color: var(--clay-dark);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.87rem;
  font-family: 'Lora', serif;
}

.form-success {
  background: #f0f7ed;
  border: 1px solid #a8d4a0;
  color: #2d6e22;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.87rem;
  font-family: 'Lora', serif;
}

.login-form .btn-primary { width: 100%; padding: 13px; font-size: 0.95rem; }

/* --- Admin Panel --- */
.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}

.admin-heading {
  font-family: 'Playfair Display', serif;
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--espresso);
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.admin-card {
  background: var(--cream-card);
  border-radius: var(--radius);
  border: 1px solid var(--parchment);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: box-shadow var(--transition);
}
.admin-card:hover { box-shadow: var(--shadow-md); }

.admin-card-img-wrap {
  width: 100%;
  padding-bottom: 60%;
  position: relative;
  background: var(--cream-dark);
  overflow: hidden;
}

.admin-card-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.admin-card-info {
  padding: 12px 16px 8px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.admin-card-name {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--espresso);
}

.admin-card-meta {
  font-family: 'Lora', serif;
  font-size: 0.8rem;
  color: var(--text-light);
  font-style: italic;
}

.admin-card-actions {
  padding: 10px 14px 14px;
  display: flex;
  gap: 8px;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
}

.btn-view {
  background: var(--cream-dark);
  color: var(--text-muted);
  border: 1px solid var(--parchment);
}
.btn-view:hover { background: var(--parchment); }

.btn-edit-sm {
  background: var(--amber);
  color: #fff;
}
.btn-edit-sm:hover { background: var(--wood-light); }

.btn-del {
  background: #fef0ed;
  color: #b83232;
  border: 1px solid #e8b4a0;
}
.btn-del:hover { background: #b83232; color: #fff; }

.admin-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 32px;
  color: var(--text-muted);
  font-style: italic;
}

/* --- Edit Form --- */
.edit-form-wrap {
  max-width: 760px;
  margin: 0 auto;
}

.form-section {
  background: var(--cream-card);
  border: 1px solid var(--parchment);
  border-radius: var(--radius);
  padding: 28px 32px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.section-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--wood);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--parchment);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 20px;
}

.form-group.full-width { grid-column: 1 / -1; }

.form-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  align-items: center;
  padding-top: 8px;
}

/* --- Image Upload Area --- */
.image-upload-area {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: flex-start;
}

.upload-preview {
  width: 280px;
  height: 280px;
  border-radius: var(--radius);
  border: 2px dashed var(--parchment);
  background: var(--cream-dark);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  inset: 0;
}

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-light);
  font-family: 'Lora', serif;
  font-size: 0.85rem;
  text-align: center;
  padding: 20px;
}

.upload-icon { font-size: 2rem; opacity: 0.5; }
.upload-hint { font-size: 0.75rem; opacity: 0.7; font-style: italic; }

.file-input { display: none; }

/* --- Cropper Modal --- */
.cropper-modal {
  position: fixed;
  inset: 0;
  background: rgba(46,26,14,0.75);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(4px);
}

.cropper-modal-inner {
  background: var(--cream-card);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 640px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.cropper-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.3rem;
  color: var(--espresso);
  margin-bottom: 6px;
}

.cropper-hint {
  font-size: 0.83rem;
  color: var(--text-light);
  font-style: italic;
  margin-bottom: 16px;
}

.cropper-container {
  max-height: 400px;
  overflow: hidden;
  border-radius: var(--radius);
  margin-bottom: 20px;
}

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

.cropper-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* --- Delete Confirmation Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(46,26,14,0.6);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(3px);
}

.modal-card {
  background: var(--cream-card);
  border-radius: var(--radius-lg);
  padding: 36px;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.modal-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.3rem;
  color: var(--espresso);
  margin-bottom: 12px;
}

.modal-body {
  font-family: 'Lora', serif;
  font-size: 0.92rem;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .set-detail { flex-direction: column; gap: 32px; }
  .set-image-side { flex: unset; max-width: 100%; }
  .set-image-frame { max-width: 360px; margin: 0 auto; }
  .set-name { font-size: 1.8rem; }
}

@media (max-width: 640px) {
  .header-inner { padding: 14px 20px; }
  .site-title { font-size: 1.2rem; }
  .header-subtitle { display: none; }
  .main-content { padding: 28px 20px 48px; }
  .controls-bar { flex-direction: column; align-items: stretch; }
  .sort-wrap { justify-content: space-between; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-section { padding: 20px; }
  .login-card { padding: 32px 24px; }
  .set-image-frame { max-width: 100%; }
  .meta-row dt { flex: 0 0 100px; }
}
