/* ===== VARIABLES ===== */
:root {
  --charcoal: #1E1E1E;
  --cream: #FDF8F0;
  --cream-dark: #F5EDE0;
  --ivory: #F5F0E8;
  --gold: #D4A853;
  --gold-dark: #B8943E;
  --gold-light: #E0BC6A;
  --gold-text: #886611;
  --sage: #A8B99C;
  --sage-dark: #8FA383;
  --sage-text: #5E7A4F;
  --text-dark: #2A2522;
  --text-mid: #5A524A;
  --warm-grey: #B8B0A4;
  --warm-grey-light: #D4CEC4;

  --green: #4A7C59;
  --green-dark: #3D6A4B;
  --green-light: #E8F0EB;
  --danger: #B85450;
  --danger-dark: #9E4440;
  --danger-light: #F5EAEA;
  --card-bg: #FFFFFF;
  --card-border: #EDE8E0;
  --card-radius: 6px;
  --input-height: 48px;
  --top-bar-height: 64px;
  --tab-height: 56px;

  --font-display: 'Instrument Serif', Georgia, serif;
  --font-body: 'Outfit', 'Segoe UI', sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ===== RESET ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 17px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: var(--font-body);
  color: var(--text-dark);
  background: var(--cream);
  line-height: 1.5;
  min-height: 100vh;
}
img { max-width: 100%; height: auto; display: block; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }
.hidden { display: none !important; }

/* ===== LOGIN ===== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cream);
  padding: 2rem;
  position: relative;
}

.login-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 25% 35%, rgba(212, 168, 83, 0.08), transparent 55%),
    radial-gradient(ellipse at 75% 65%, rgba(30, 71, 160, 0.05), transparent 50%),
    radial-gradient(ellipse at 50% 90%, rgba(168, 185, 156, 0.06), transparent 45%);
  pointer-events: none;
}

.login-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--card-bg);
  padding: clamp(2rem, 5vw, 3rem);
  border: 1px solid var(--card-border);
  text-align: center;
  box-shadow: 0 8px 40px rgba(42, 37, 34, 0.06);
}

.login-label {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold-text);
  margin-bottom: 4px;
}

.login-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 400;
  color: var(--text-dark);
}

.login-rule {
  width: 50px;
  height: 1px;
  background: var(--gold);
  border: none;
  margin: 1.25rem auto;
}

.login-welcome {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--text-mid);
  margin-bottom: 1.5rem;
}

.login-form { text-align: left; }

.login-error {
  color: var(--danger);
  font-size: 0.85rem;
  text-align: center;
  margin-top: 1rem;
  min-height: 1.2em;
}

.btn-login {
  width: 100%;
  height: var(--input-height);
  margin-top: 0.5rem;
  background: var(--gold);
  color: var(--charcoal);
  border: none;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: background 0.3s var(--ease);
}

.btn-login:hover { background: var(--gold-dark); }
.btn-login:active { transform: translateY(1px); }

/* ===== FORM FIELDS ===== */
.field { margin-bottom: 1.25rem; }

.field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-mid);
  margin-bottom: 0.4rem;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field input[type="url"],
.field select,
.field textarea {
  width: 100%;
  height: var(--input-height);
  padding: 0 1rem;
  border: 1.5px solid var(--warm-grey-light);
  border-radius: 3px;
  background: var(--card-bg);
  color: var(--text-dark);
  font-size: 1rem;
  transition: border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
  outline: none;
}

.field textarea {
  height: auto;
  min-height: 100px;
  padding: 0.75rem 1rem;
  resize: vertical;
  line-height: 1.6;
}

.field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235A524A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 14px;
  padding-right: 2.5rem;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 168, 83, 0.12);
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--warm-grey);
  font-weight: 300;
}

.input-prefix {
  position: relative;
}

.input-prefix span {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-mid);
  font-size: 1rem;
  pointer-events: none;
}

.input-prefix input { padding-left: 2rem; }

.field-hint {
  font-size: 0.78rem;
  font-weight: 300;
  color: var(--warm-grey);
  margin-top: 0.3rem;
}

/* ===== TOP BAR ===== */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--top-bar-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--card-border);
  z-index: 100;
}

.top-bar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 clamp(1rem, 3vw, 2rem);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.top-bar-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--text-dark);
  white-space: nowrap;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.publish-status {
  font-size: 0.82rem;
  color: var(--text-mid);
  font-weight: 300;
  white-space: nowrap;
}

.publish-status.has-changes {
  color: var(--gold-text);
  font-weight: 500;
}

.btn-publish {
  height: 40px;
  padding: 0 1.25rem;
  background: var(--green);
  color: white;
  border: none;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 4px;
  transition: background 0.3s var(--ease), transform 0.15s var(--ease), box-shadow 0.3s var(--ease);
  white-space: nowrap;
}

.btn-publish:hover {
  background: var(--green-dark);
  transform: translateY(-1px);
}

.btn-publish:active { transform: translateY(0); }

.btn-publish.publishing {
  opacity: 0.7;
  cursor: wait;
  pointer-events: none;
}

.btn-publish.pulse {
  animation: publishPulse 2.5s ease-in-out infinite;
}

@keyframes publishPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74, 124, 89, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(74, 124, 89, 0); }
}

.btn-signout {
  height: 36px;
  padding: 0 0.75rem;
  background: transparent;
  border: 1px solid var(--warm-grey-light);
  color: var(--text-mid);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  border-radius: 4px;
  transition: all 0.3s var(--ease);
  white-space: nowrap;
}

.btn-signout:hover {
  border-color: var(--text-mid);
  color: var(--text-dark);
}

/* ===== TAB NAV ===== */
.tab-nav {
  position: fixed;
  top: var(--top-bar-height);
  left: 0;
  right: 0;
  height: var(--tab-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--card-border);
  z-index: 99;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0 1rem;
}

.tab {
  height: 38px;
  padding: 0 clamp(0.75rem, 2.5vw, 1.5rem);
  background: transparent;
  border: 1.5px solid transparent;
  color: var(--text-mid);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 4px;
  transition: all 0.25s var(--ease);
}

.tab:hover {
  color: var(--gold-text);
  border-color: var(--warm-grey-light);
}

.tab.active {
  background: rgba(212, 168, 83, 0.1);
  border-color: var(--gold);
  color: var(--gold-text);
}

/* ===== CONTENT ===== */
.content {
  max-width: 960px;
  margin: 0 auto;
  padding: calc(var(--top-bar-height) + var(--tab-height) + 2rem) clamp(1rem, 3vw, 2rem) 4rem;
}

.panel { display: none; }
.panel.active { display: block; animation: panelIn 0.35s var(--ease); }

@keyframes panelIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.panel-title {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 3vw, 1.7rem);
  font-weight: 400;
  color: var(--text-dark);
}

.btn-add {
  height: 44px;
  padding: 0 1.5rem;
  background: transparent;
  border: 1.5px solid var(--gold);
  color: var(--gold-text);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  transition: color 0.4s var(--ease);
  z-index: 1;
}

.btn-add::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gold);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s var(--ease);
  z-index: -1;
}

.btn-add:hover { color: var(--charcoal); }
.btn-add:hover::before { transform: scaleX(1); }

/* ===== CARD LIST ===== */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.item-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  padding: 1.25rem;
  transition: border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}

.item-card:hover {
  border-color: var(--warm-grey);
  box-shadow: 0 2px 12px rgba(42, 37, 34, 0.05);
}

.card-thumb {
  width: 80px;
  height: 80px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--cream-dark);
  flex-shrink: 0;
}

.card-thumb-empty {
  width: 80px;
  height: 80px;
  border-radius: 4px;
  background: var(--cream-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--warm-grey);
  font-size: 1.4rem;
}

.card-body {
  flex: 1;
  min-width: 0;
}

.card-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--text-dark);
  margin-bottom: 0.15rem;
}

.card-meta {
  font-size: 0.85rem;
  color: var(--text-mid);
  font-weight: 300;
  margin-bottom: 0.4rem;
  line-height: 1.4;
}

.card-meta .price {
  color: var(--gold);
  font-weight: 500;
}

.card-desc {
  font-size: 0.85rem;
  color: var(--warm-grey);
  font-weight: 300;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: 3px;
  vertical-align: middle;
  margin-left: 0.5rem;
}

.badge-active {
  background: var(--green-light);
  color: var(--sage-text);
}

.badge-sold {
  background: rgba(212, 168, 83, 0.15);
  color: var(--gold-text);
}

.badge-full {
  background: rgba(212, 168, 83, 0.15);
  color: var(--gold-text);
}

/* ===== CARD ACTIONS ===== */
.card-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.btn-action {
  height: 34px;
  padding: 0 0.7rem;
  background: transparent;
  border: 1px solid var(--warm-grey-light);
  color: var(--text-mid);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  border-radius: 3px;
  transition: all 0.25s var(--ease);
  white-space: nowrap;
}

.btn-action:hover {
  border-color: var(--gold);
  color: var(--gold-text);
}

.btn-action.btn-toggle {
  border-color: var(--gold);
  color: var(--gold-text);
}

.btn-action.btn-toggle:hover {
  background: var(--gold);
  color: var(--charcoal);
}

.btn-action.btn-del {
  border-color: transparent;
  color: var(--warm-grey);
}

.btn-action.btn-del:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* ===== FAQ REORDER ===== */
.faq-reorder {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
}

.btn-reorder {
  width: 30px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--warm-grey-light);
  border-radius: 3px;
  color: var(--text-mid);
  font-size: 0.75rem;
  transition: all 0.2s var(--ease);
  line-height: 1;
}

.btn-reorder:hover:not(:disabled) {
  border-color: var(--gold);
  color: var(--gold-text);
  background: rgba(212, 168, 83, 0.06);
}

.btn-reorder:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(42, 37, 34, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: overlayIn 0.2s var(--ease);
}

@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  background: var(--card-bg);
  border-radius: var(--card-radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalUp 0.3s var(--ease);
  box-shadow: 0 20px 60px rgba(42, 37, 34, 0.18);
}

@keyframes modalUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--card-border);
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 400;
}

.modal-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--warm-grey);
  font-size: 1.6rem;
  border-radius: 50%;
  transition: all 0.2s var(--ease);
  line-height: 1;
}

.modal-close:hover {
  background: var(--cream-dark);
  color: var(--text-dark);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--card-border);
}

.btn-cancel {
  height: 44px;
  padding: 0 1.25rem;
  background: transparent;
  border: 1px solid var(--warm-grey-light);
  color: var(--text-mid);
  font-size: 0.85rem;
  font-weight: 400;
  border-radius: 4px;
  transition: all 0.25s var(--ease);
}

.btn-cancel:hover {
  border-color: var(--text-mid);
  color: var(--text-dark);
}

.btn-save {
  height: 44px;
  padding: 0 1.75rem;
  background: var(--gold);
  border: none;
  color: var(--charcoal);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 4px;
  transition: background 0.3s var(--ease);
}

.btn-save:hover { background: var(--gold-dark); }
.btn-save:active { transform: translateY(1px); }

/* ===== CONFIRM DIALOG ===== */
.confirm-card {
  width: 100%;
  max-width: 380px;
  background: var(--card-bg);
  border-radius: var(--card-radius);
  padding: 2rem;
  text-align: center;
  animation: modalUp 0.3s var(--ease);
  box-shadow: 0 20px 60px rgba(42, 37, 34, 0.18);
}

.confirm-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin-bottom: 0.5rem;
}

.confirm-msg {
  font-size: 0.92rem;
  font-weight: 300;
  color: var(--text-mid);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.btn-danger {
  height: 44px;
  padding: 0 1.75rem;
  background: var(--danger);
  border: none;
  color: white;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  border-radius: 4px;
  transition: background 0.3s var(--ease);
}

.btn-danger:hover { background: var(--danger-dark); }

/* ===== UPLOAD ZONE ===== */
.upload-zone {
  position: relative;
  border: 2px dashed var(--warm-grey-light);
  border-radius: var(--card-radius);
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s var(--ease);
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.5rem;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--gold);
  background: rgba(212, 168, 83, 0.03);
}

.upload-zone.drag-over {
  border-style: solid;
  box-shadow: inset 0 0 0 1px var(--gold);
}

.upload-hint {
  font-size: 0.88rem;
  color: var(--warm-grey);
  font-weight: 300;
}

.upload-hint-sub {
  font-size: 0.75rem;
  color: var(--warm-grey-light);
  font-weight: 300;
}

.upload-preview {
  max-width: 220px;
  max-height: 180px;
  object-fit: contain;
  border-radius: 4px;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  top: calc(var(--top-bar-height) + 0.75rem);
  right: 1rem;
  z-index: 300;
  padding: 0.9rem 1.25rem;
  border-radius: var(--card-radius);
  font-size: 0.88rem;
  font-weight: 400;
  max-width: 360px;
  box-shadow: 0 4px 24px rgba(42, 37, 34, 0.12);
  animation: toastIn 0.35s var(--ease);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast-exit {
  animation: toastOut 0.25s var(--ease) forwards;
}

@keyframes toastOut {
  to { opacity: 0; transform: translateX(20px); }
}

.toast.success {
  background: var(--green-light);
  color: var(--green);
  border-left: 3px solid var(--green);
}

.toast.error {
  background: var(--danger-light);
  color: var(--danger);
  border-left: 3px solid var(--danger);
}

.toast.info {
  background: var(--cream);
  color: var(--gold-text);
  border-left: 3px solid var(--gold);
  border: 1px solid var(--card-border);
  border-left: 3px solid var(--gold);
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: clamp(2.5rem, 5vw, 4rem) 1rem;
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.35;
}

.empty-state p {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--warm-grey);
}

/* ===== LOADING ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(253, 248, 240, 0.75);
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--cream-dark);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  :root {
    --tab-height: 50px;
  }

  .top-bar {
    position: relative;
    height: auto;
  }

  .top-bar-inner {
    flex-wrap: wrap;
    padding: 0.6rem clamp(0.75rem, 2vw, 1rem);
    gap: 0.5rem;
  }

  .top-bar-right {
    gap: 0.5rem;
  }

  .publish-status {
    display: none;
  }

  .tab-nav {
    position: sticky;
    top: 0;
    overflow-x: auto;
    justify-content: flex-start;
    gap: 0.25rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .tab-nav::-webkit-scrollbar { display: none; }

  .tab {
    flex-shrink: 0;
    padding: 0 0.75rem;
    font-size: 0.78rem;
  }

  .content {
    padding: 1.5rem clamp(0.75rem, 2vw, 1.25rem) 3rem;
  }

  .item-card {
    flex-direction: column;
    align-items: stretch;
  }

  .card-thumb,
  .card-thumb-empty {
    width: 100%;
    height: 180px;
  }

  .card-actions {
    justify-content: flex-start;
  }

  .panel-header {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-add {
    text-align: center;
  }

  .faq-reorder {
    flex-direction: row;
    gap: 0.5rem;
  }

  .modal-card {
    max-height: 95vh;
  }

  .modal-body {
    padding: 1rem;
  }
}

@media (max-width: 374px) {
  html { font-size: 15px; }
}

/* ===== FOCUS STYLES ===== */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

button:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible),
textarea:focus:not(:focus-visible) {
  outline: none;
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
