:root {
  --red: #bc0108;
  --red-deep: #7c0006;
  --ink: #21070a;
  --muted: #6f4b4f;
  --surface: #fff2f3;
  --surface-strong: #ffe7e9;
  --line: rgba(188, 1, 8, 0.16);
  --shadow: 0 22px 55px rgba(82, 0, 6, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Manrope, "Noto Sans Thai", system-ui, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(188, 1, 8, 0.16), rgba(188, 1, 8, 0.05)),
    #f5c2c7;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  color: #fff;
  background: var(--red);
  cursor: pointer;
  font-weight: 800;
}

button:hover {
  background: var(--red-deep);
}

button.secondary {
  color: var(--red);
  background: #fff;
  border: 1px solid var(--line);
}

button.ghost {
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

label {
  display: grid;
  gap: 8px;
  color: var(--red-deep);
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
}

textarea {
  min-height: 76px;
  resize: vertical;
}

.admin-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0 60px;
}

.admin-hero,
.admin-card,
.notice {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(255, 242, 243, 0.9);
  box-shadow: var(--shadow);
}

.admin-hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 28px;
  margin-bottom: 22px;
}

.admin-hero h1,
.toolbar h2,
.admin-card h2,
.admin-card h3 {
  margin: 0;
  line-height: 1.08;
}

.admin-hero h1 {
  font-size: clamp(2rem, 4vw, 4rem);
}

.admin-hero p {
  max-width: 760px;
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.75;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--red);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.site-link {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 12px 18px;
  color: var(--red);
  background: #fff;
  border: 1px solid var(--line);
  text-decoration: none;
  font-weight: 900;
}

.notice {
  display: grid;
  gap: 6px;
  padding: 18px 20px;
  margin-bottom: 18px;
}

.notice span,
.status {
  color: var(--muted);
}

.admin-card {
  padding: 24px;
}

.login-form {
  display: grid;
  gap: 16px;
  max-width: 520px;
  margin-top: 18px;
}

.dashboard {
  display: grid;
  gap: 22px;
}

.dashboard[hidden],
#login-panel[hidden],
#setup-panel[hidden] {
  display: none;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
}

.toolbar-actions,
.gallery-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(0, 1.15fr);
  gap: 20px;
  align-items: start;
}

.hero-preview {
  width: 100%;
  aspect-ratio: 16 / 10;
  margin: 18px 0;
  border-radius: 18px;
  background: #2a0608;
  object-fit: cover;
}

.upload-box {
  border: 1px dashed rgba(188, 1, 8, 0.36);
  border-radius: 18px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.48);
}

.upload-box input {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.gallery-manager {
  min-height: 520px;
}

.gallery-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.gallery-item {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.52);
}

.gallery-item img {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 14px;
  object-fit: cover;
}

.gallery-item-fields {
  display: grid;
  gap: 10px;
}

.gallery-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.gallery-item-actions button {
  padding: 9px 12px;
  font-size: 0.86rem;
}

.status {
  min-height: 24px;
  margin: 0;
  font-weight: 800;
}

@media (max-width: 860px) {
  .admin-hero,
  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .admin-grid,
  .gallery-item {
    grid-template-columns: 1fr;
  }
}

.admin-help {
  margin: 10px 0 18px;
  color: var(--muted);
  line-height: 1.65;
}

.media-manager {
  display: grid;
  gap: 14px;
}

.media-preview {
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.58);
  object-fit: contain;
}

/* Admin UI polish: cleaner desktop layout, balanced cards, and clearer gallery editing */
body {
  background:
    radial-gradient(circle at top left, rgba(188, 1, 8, 0.14), transparent 34vw),
    linear-gradient(180deg, #fff8f8 0%, #fff2f3 48%, #fff8f8 100%);
}

.admin-shell {
  width: min(1260px, calc(100% - 36px));
  padding-top: 26px;
}

.admin-hero,
.admin-card,
.notice,
.toolbar {
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 12px 34px rgba(82, 0, 6, 0.08);
  backdrop-filter: blur(16px);
}

.admin-hero {
  position: relative;
  overflow: hidden;
  padding: 26px 28px;
}

.admin-hero::after {
  content: "";
  position: absolute;
  inset: 0 0 0 auto;
  width: 34%;
  background: linear-gradient(135deg, transparent, rgba(188, 1, 8, 0.10));
  pointer-events: none;
}

.admin-hero > * {
  position: relative;
  z-index: 1;
}

.admin-hero h1 {
  font-size: clamp(1.8rem, 3vw, 3.15rem);
}

.toolbar {
  position: sticky;
  top: 14px;
  z-index: 20;
  padding: 18px 20px;
}

.admin-card {
  display: grid;
  align-content: start;
  gap: 15px;
  padding: 22px;
}

.admin-card h3 {
  font-size: 1.35rem;
}

button {
  background: linear-gradient(135deg, var(--red), #d90412);
  box-shadow: 0 12px 24px rgba(188, 1, 8, 0.18);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(188, 1, 8, 0.24);
}

button.secondary {
  background: #fff;
  box-shadow: 0 10px 22px rgba(82, 0, 6, 0.07);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(188, 1, 8, 0.42);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(188, 1, 8, 0.08);
  outline: 0;
}

.admin-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 18px;
}

.hero-manager,
.media-manager {
  grid-column: span 6;
}

.gallery-manager {
  grid-column: 1 / -1;
  min-height: 520px;
}

.hero-preview {
  aspect-ratio: 16 / 9;
  margin: 0;
  border-radius: 20px;
  box-shadow: 0 18px 34px rgba(82, 0, 6, 0.14);
}

.media-preview {
  max-height: 340px;
  padding: 12px;
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(255, 247, 248, 0.92), rgba(255, 255, 255, 0.92));
}

.upload-box {
  background: linear-gradient(180deg, rgba(255,255,255,0.78), rgba(255,247,248,0.86));
}

.compact-upload {
  min-width: min(100%, 260px);
}

.gallery-actions {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #fff7f8;
}

.gallery-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.gallery-item {
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 16px;
  padding: 14px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 10px 24px rgba(82, 0, 6, 0.06);
}

.gallery-item img {
  aspect-ratio: 4 / 5;
  border-radius: 18px;
}

.gallery-item-fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
}

.gallery-item-fields label:first-child,
.gallery-item-fields label:nth-child(4),
.gallery-item-fields .gallery-item-actions {
  grid-column: 1 / -1;
}

.status {
  position: sticky;
  bottom: 14px;
  z-index: 30;
  width: fit-content;
  max-width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 34px rgba(82, 0, 6, 0.08);
}

@media (max-width: 1120px) {
  .hero-manager,
  .media-manager,
  .gallery-manager {
    grid-column: 1 / -1;
  }

  .gallery-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .admin-shell {
    width: min(100% - 24px, 1260px);
    padding-top: 18px;
  }

  .toolbar {
    position: static;
  }

  .toolbar-actions,
  .gallery-actions {
    width: 100%;
  }

  .toolbar-actions button,
  .gallery-actions button,
  .site-link {
    width: 100%;
    text-align: center;
  }

  .gallery-item {
    grid-template-columns: 1fr;
  }

  .gallery-item img {
    aspect-ratio: 16 / 10;
  }

  .gallery-item-fields {
    grid-template-columns: 1fr;
  }

  .status {
    position: static;
    width: 100%;
    border-radius: 18px;
  }
}

/* Text content manager */
.text-manager {
  grid-column: 1 / -1;
}

.text-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #fff7f8;
}

.text-tab {
  box-shadow: none;
}

.text-tab.is-active {
  color: #fff;
  background: linear-gradient(135deg, var(--red), #d90412);
}

.text-panel {
  display: grid;
  gap: 16px;
}

.text-panel[hidden] {
  display: none;
}

.text-panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.7);
}

.text-panel-heading h4 {
  margin: 0 0 6px;
  font-size: 1.08rem;
}

.text-panel-heading p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.text-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.compact-text-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.text-editor-item {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 10px 24px rgba(82, 0, 6, 0.055);
}

.text-editor-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--red-deep);
  font-weight: 900;
}

.text-editor-title::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--red);
  box-shadow: 0 0 0 6px rgba(188, 1, 8, 0.08);
}

.text-editor-title span {
  margin-right: auto;
}

.text-editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.text-editor-grid .span-2 {
  grid-column: 1 / -1;
}

.text-editor-grid textarea {
  min-height: 112px;
}

.review-text-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.review-editor-item .text-editor-grid {
  grid-template-columns: 1fr;
}

.small-button {
  padding: 8px 12px;
  font-size: 0.84rem;
  box-shadow: none;
}

.guest-info-editor-item .text-editor-grid {
  grid-template-columns: 1fr;
}

@media (max-width: 1120px) {
  .text-list,
  .compact-text-list,
  .review-text-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .text-panel-heading {
    flex-direction: column;
  }

  .text-panel-heading button,
  .text-tab {
    width: 100%;
  }

  .text-editor-grid {
    grid-template-columns: 1fr;
  }
}


/* Round 3 admin usability: save states, validation feedback, and clearer action status */
.dashboard-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.unsaved-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(188, 1, 8, 0.18);
  border-radius: 999px;
  padding: 7px 11px;
  color: var(--red-deep);
  background: #fff2f3;
  font-size: 0.82rem;
  font-weight: 900;
}

.unsaved-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--red);
  box-shadow: 0 0 0 5px rgba(188, 1, 8, 0.08);
}

.unsaved-badge[hidden] {
  display: none;
}

#save-content.has-unsaved {
  animation: softPulse 1.8s ease-in-out infinite;
}

@keyframes softPulse {
  0%, 100% { box-shadow: 0 12px 24px rgba(188, 1, 8, 0.18); }
  50% { box-shadow: 0 16px 32px rgba(188, 1, 8, 0.34); }
}

.status {
  color: var(--muted);
}

.status-success {
  color: #116b3d;
  border-color: rgba(17, 107, 61, 0.20);
  background: rgba(237, 255, 246, 0.95);
}

.status-error {
  color: var(--red-deep);
  border-color: rgba(188, 1, 8, 0.28);
  background: rgba(255, 242, 243, 0.96);
}

.status-warning {
  color: #8a4b00;
  border-color: rgba(207, 132, 0, 0.26);
  background: rgba(255, 248, 231, 0.96);
}

.status-info {
  color: var(--muted);
}

input:invalid,
select:invalid,
textarea:invalid {
  border-color: rgba(188, 1, 8, 0.36);
}

.text-editor-item:focus-within,
.gallery-item:focus-within,
.media-manager:focus-within,
.hero-manager:focus-within {
  border-color: rgba(188, 1, 8, 0.26);
  box-shadow: 0 14px 30px rgba(82, 0, 6, 0.08);
}

@media (max-width: 760px) {
  .dashboard-title-row {
    align-items: flex-start;
    flex-direction: column;
  }
}

/* v13 admin stability: make dropdown values visible and media previews resilient */
select {
  min-height: 48px;
  color: var(--ink);
  background-color: #fff;
}

select option {
  color: var(--ink);
  background: #fff;
}

.media-preview,
.hero-preview,
.gallery-item img {
  display: block;
}
