@import url("https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;500;600;700&family=DM+Sans:wght@400;500;600&display=swap");

:root {
  --background: #f7f4ef;
  --foreground: #2a2a2a;
  --muted: #6b6560;
  --border: #e0d9d0;
  --accent: #b8956b;
  --accent-hover: #a6835a;
  --surface: #ffffff;
  --surface-warm: #f0ebe3;
  --danger: #dc2626;
  --font-sans: "DM Sans", system-ui, sans-serif;
  --font-serif: "Cormorant Garamond", Georgia, serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  overflow-x: clip;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  overflow-x: clip;
}

body.menu-open {
  overflow: hidden;
}

h1,
h2,
h3,
h4 {
  font-family: var(--font-serif);
  font-weight: 500;
}

a {
  color: inherit;
}

::selection {
  background: var(--accent);
  color: white;
}

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

.mt-2 {
  margin-top: 0.5rem;
}

.label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.input {
  width: 100%;
  margin-top: 0.5rem;
  border: 1px solid var(--border);
  background: var(--background);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  outline: none;
}

.input:focus {
  border-color: var(--accent);
}

textarea.input {
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.75rem 1.5rem;
  border: none;
  font-size: 0.875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--foreground);
  color: var(--foreground);
}

.btn-block {
  width: 100%;
}

.form-error {
  color: var(--danger);
  font-size: 0.875rem;
}

/* Login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 28rem;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 1.5rem;
}

@media (min-width: 640px) {
  .login-card {
    padding: 2rem;
  }
}

.login-card h1 {
  margin: 0;
  font-size: 1.875rem;
}

.login-form {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Dashboard shell */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

@media (min-width: 768px) {
  .app-shell {
    flex-direction: row;
  }
}

#sidebar-root {
  flex-shrink: 0;
}

@media (min-width: 768px) {
  #sidebar-root {
    align-self: stretch;
    width: 14rem;
    min-height: 100vh;
  }
}

.mobile-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 40;
  display: flex;
  height: 3.5rem;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--surface-warm);
  padding: 0 1rem;
}

@media (min-width: 768px) {
  .mobile-header {
    display: none;
  }
}

.mobile-menu-btn {
  display: flex;
  height: 2.75rem;
  width: 2.75rem;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--foreground);
  cursor: pointer;
}

.mobile-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.1em;
}

.mobile-spacer {
  width: 2.75rem;
}

.sidebar-overlay {
  position: fixed;
  inset: 3.5rem 0 0 0;
  z-index: 40;
  background: rgba(42, 42, 42, 0.2);
}

.sidebar-overlay[hidden] {
  display: none;
}

.sidebar {
  position: fixed;
  top: 3.5rem;
  bottom: 0;
  left: 0;
  z-index: 50;
  display: flex;
  width: 16rem;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--surface-warm);
  transform: translateX(-100%);
  transition: transform 0.2s;
}

.sidebar--open {
  transform: translateX(0);
}

@media (min-width: 768px) {
  .sidebar {
    position: sticky;
    top: 0;
    width: 100%;
    min-height: 100vh;
    height: 100%;
    transform: none;
  }
}

.sidebar-brand {
  display: none;
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 1.25rem;
}

@media (min-width: 768px) {
  .sidebar-brand {
    display: block;
  }
}

.sidebar-brand-name {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.125rem;
  font-weight: 500;
  letter-spacing: 0.1em;
}

.sidebar-brand-sub {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.sidebar-nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.25rem;
  overflow-y: auto;
  padding: 1rem;
}

.sidebar-link {
  display: flex;
  min-height: 2.75rem;
  align-items: center;
  padding: 0.625rem 0.75rem;
  font-size: 0.875rem;
  text-decoration: none;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}

.sidebar-link:hover {
  background: var(--surface);
  color: var(--foreground);
}

.sidebar-link--active {
  background: var(--foreground);
  color: var(--background);
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 1rem;
}

.sidebar-footer-link {
  display: block;
  min-height: 2.75rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  color: var(--muted);
  text-decoration: none;
}

.sidebar-footer-link:hover {
  color: var(--accent);
}

.sidebar-logout {
  width: 100%;
  min-height: 2.75rem;
  border: none;
  background: transparent;
  padding: 0.625rem 0.75rem;
  text-align: left;
  font-size: 0.875rem;
  color: var(--muted);
  cursor: pointer;
}

.sidebar-logout:hover {
  color: var(--foreground);
}

.main-content {
  flex: 1;
  padding: 4.5rem 1rem 1.5rem;
}

@media (min-width: 768px) {
  .main-content {
    padding: 2rem;
  }
}

@media (min-width: 1024px) {
  .main-content {
    padding: 2rem;
  }
}

.page-header h1 {
  margin: 0;
  font-size: 1.875rem;
}

.page-header p {
  margin: 0.5rem 0 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.page-header-row {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (min-width: 640px) {
  .page-header-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

/* Stats */
.stats-grid {
  display: grid;
  gap: 1.5rem;
  margin-top: 3rem;
}

@media (min-width: 640px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.stat-card {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 1.5rem;
}

.stat-label {
  margin: 0;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.stat-value {
  margin: 0.5rem 0 0;
  font-family: var(--font-serif);
  font-size: 2.25rem;
}

.stat-value--accent {
  color: var(--accent);
}

.stat-value--muted {
  color: var(--muted);
}

.page-cta {
  margin-top: 3rem;
}

/* Product table */
.product-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (min-width: 768px) {
  .product-cards {
    display: none;
  }
}

.product-table-wrap {
  display: none;
  overflow-x: auto;
}

@media (min-width: 768px) {
  .product-table-wrap {
    display: block;
  }
}

.product-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  text-align: left;
}

.product-table th {
  padding-bottom: 0.75rem;
  padding-right: 1rem;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.product-table td {
  padding: 1rem 1rem 1rem 0;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.product-table .truncate {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-card {
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 1rem;
}

.product-card-main {
  display: flex;
  gap: 1rem;
}

.product-card-info h3 {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-card-actions {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.product-thumb {
  position: relative;
  width: 2.75rem;
  height: 3.5rem;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--surface-warm);
}

.product-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-thumb--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--muted);
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge--available {
  background: rgba(184, 149, 107, 0.1);
  color: var(--accent);
}

.badge--sold {
  background: var(--surface-warm);
  color: var(--muted);
}

.product-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.action-link {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  text-decoration: none;
  color: var(--foreground);
  background: none;
  border: none;
  cursor: pointer;
}

.action-link:hover {
  color: var(--accent);
}

.action-link--danger {
  color: var(--danger);
}

.action-link--danger:hover {
  color: #991b1b;
}

.empty-state {
  padding: 4rem 0;
  text-align: center;
}

.empty-link {
  display: inline-block;
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--accent);
}

/* Product form */
.product-form {
  max-width: 42rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.form-grid {
  display: grid;
  gap: 1.5rem;
}

@media (min-width: 640px) {
  .form-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

.form-checks {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (min-width: 640px) {
  .form-checks {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 1.5rem;
  }
}

.checkbox-label {
  display: flex;
  min-height: 2.75rem;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.form-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .form-actions {
    flex-direction: row;
    gap: 1rem;
  }
}

/* Tags */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--surface-warm);
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
}

.tag-remove {
  display: flex;
  height: 2rem;
  width: 2rem;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.25rem;
}

.tag-input-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

@media (min-width: 640px) {
  .tag-input-row {
    flex-direction: row;
  }
}

.tag-text-input {
  margin-top: 0;
  flex: 1;
}

/* Images */
.image-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.image-thumb {
  position: relative;
  width: 5rem;
  height: 6rem;
  overflow: hidden;
  border: 1px solid var(--border);
}

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

.image-thumb--pending {
  display: flex;
  align-items: center;
  justify-content: center;
  border-style: dashed;
  background: var(--surface-warm);
}

.image-filename {
  padding: 0.25rem;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

.image-remove {
  position: absolute;
  right: 0.25rem;
  top: 0.25rem;
  display: flex;
  height: 2rem;
  width: 2rem;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--foreground);
  color: var(--background);
  cursor: pointer;
  font-size: 1rem;
}

.image-upload-btn {
  margin-top: 1rem;
}

/* Page loader */
body.is-loading .app-shell,
body.is-loading #app {
  visibility: hidden;
}

.page-loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--background);
}

.page-loader[hidden] {
  display: none;
}

.page-loader__content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.page-loader__spinner {
  width: 2.5rem;
  height: 2.5rem;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: page-loader-spin 0.7s linear infinite;
}

.page-loader__text {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

@keyframes page-loader-spin {
  to {
    transform: rotate(360deg);
  }
}
