/* ═══════════════════════════════════════════════════
   THE CUTTING TABLE — Stylesheet
   Aesthetic: Warm editorial, refined craft-studio feel
   Palette: warm cream, deep charcoal, dusty rose accent
   ═══════════════════════════════════════════════════ */

:root {
  --cream: #f7f3ee;
  --cream-dark: #ede8e0;
  --warm-white: #faf8f5;
  --charcoal: #2c2825;
  --charcoal-light: #4a4540;
  --muted: #8a8078;
  --rose: #c4796a;
  --rose-light: #e8a89c;
  --rose-pale: #f5e8e5;
  --sage: #7a9485;
  --border: #ddd8d0;
  --shadow-sm: 0 1px 3px rgba(44,40,37,0.08);
  --shadow-md: 0 4px 16px rgba(44,40,37,0.12);
  --shadow-lg: 0 12px 40px rgba(44,40,37,0.18);
  --radius: 8px;
  --radius-lg: 14px;
  --sidebar-w: 240px;
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
}

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

html, body {
  height: 100%;
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--charcoal);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ─── Page layout ───────────────────────────────────── */
.page { min-height: 100vh; }

/* ─── Auth Pages ─────────────────────────────────────── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  position: relative;
  overflow: hidden;
  background: var(--cream);
}

.auth-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.auth-pattern {
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(45deg, transparent, transparent 30px, rgba(196,121,106,0.04) 30px, rgba(196,121,106,0.04) 31px),
    repeating-linear-gradient(-45deg, transparent, transparent 30px, rgba(196,121,106,0.04) 30px, rgba(196,121,106,0.04) 31px);
}

.auth-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow-lg);
  margin: 1rem;
}

.auth-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.scissors-icon {
  display: inline-block;
  font-size: 2rem;
  color: var(--rose);
  transform: rotate(-45deg);
  margin-bottom: 0.5rem;
}

.auth-logo h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 400;
  color: var(--charcoal);
  letter-spacing: 0.02em;
}

.tagline {
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 0.25rem;
}

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

.auth-footer {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.auth-footer a { color: var(--rose); text-decoration: none; margin-left: 0.4em; }
.auth-footer a:hover { text-decoration: underline; }

/* ─── App Layout ─────────────────────────────────────── */
#page-app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: 1fr;
  min-height: 100vh;
}

/* ─── Sidebar ─────────────────────────────────────────── */
#sidebar {
  background: var(--charcoal);
  color: #e8e2da;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.5rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 1rem;
}

.sidebar-logo .scissors-icon {
  font-size: 1.4rem;
  color: var(--rose-light);
  flex-shrink: 0;
}

.sidebar-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 400;
  color: #f5f0ea;
  line-height: 1.2;
}

.sidebar-tagline {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.35);
  letter-spacing: 0.05em;
  margin-top: 0.1rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius);
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 400;
  transition: all 0.15s;
}

.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: rgba(196,121,106,0.2); color: var(--rose-light); }
.nav-icon { font-size: 1rem; opacity: 0.8; }

.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 1rem;
  margin-top: auto;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--rose);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 500;
  flex-shrink: 0;
}

.user-name {
  font-size: 0.88rem;
  color: #e8e2da;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.user-email {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.35);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.btn-logout {
  display: block;
  text-align: center;
  padding: 0.45rem;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.5);
  text-decoration: none;
  font-size: 0.82rem;
  transition: all 0.15s;
}

.btn-logout:hover { background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.8); }

/* ─── Mobile Header ──────────────────────────────────── */
.mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--charcoal);
  color: white;
  position: sticky;
  top: 0;
  z-index: 100;
}

.mobile-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: #f5f0ea;
}

.mobile-menu-btn, .btn-icon-sm {
  background: none;
  border: none;
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.mobile-menu-btn:hover, .btn-icon-sm:hover { background: rgba(255,255,255,0.1); }

/* ─── Main Content ──────────────────────────────────── */
#main-content {
  background: var(--cream);
  overflow-y: auto;
  min-height: 100vh;
}

.view { padding: 2rem 2.5rem; max-width: 1100px; }

.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.view-header h2 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 400;
  color: var(--charcoal);
}

.view-subtitle {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.2rem;
}

/* ─── Search + Filters ──────────────────────────────── */
.search-bar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.search-bar input[type="search"] {
  width: 100%;
  padding: 0.7rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--warm-white);
  font-size: 0.95rem;
  font-family: var(--font-body);
  color: var(--charcoal);
  outline: none;
  transition: border-color 0.15s;
}

.search-bar input[type="search"]:focus { border-color: var(--rose); }

.filters {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.filters select, .filters input {
  padding: 0.5rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--warm-white);
  font-family: var(--font-body);
  font-size: 0.88rem;
  color: var(--charcoal);
  outline: none;
  transition: border-color 0.15s;
  min-width: 130px;
}

.filters select:focus, .filters input:focus { border-color: var(--rose); }

/* ─── Pattern Grid ──────────────────────────────────── */
.patterns-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
}

.pattern-card {
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow-sm);
}

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

.card-images {
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: 160px;
  background: var(--cream-dark);
}

.card-images.single { grid-template-columns: 1fr; }

.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}

.card-img-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cream-dark);
  color: var(--border);
  font-size: 2rem;
  height: 160px;
}

.card-body {
  padding: 0.9rem 1rem;
}

.card-brand {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--rose);
  font-weight: 500;
  margin-bottom: 0.2rem;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--charcoal);
  line-height: 1.3;
  margin-bottom: 0.3rem;
}

.card-meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.tag-chip {
  background: var(--rose-pale);
  color: var(--rose);
  font-size: 0.7rem;
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  font-weight: 500;
}

.tag-chip.sage { background: #edf2ef; color: var(--sage); }

.empty-state {
  grid-column: 1/-1;
  text-align: center;
  padding: 4rem 2rem;
  color: var(--muted);
}

.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h3 { font-family: var(--font-display); font-size: 1.5rem; font-weight: 400; margin-bottom: 0.5rem; color: var(--charcoal-light); }
.empty-state p { font-size: 0.9rem; }

.loading-spinner {
  grid-column: 1/-1;
  text-align: center;
  padding: 3rem;
  color: var(--muted);
  font-style: italic;
}

/* ─── Detail Modal Content ───────────────────────────── */
.detail-content {
  padding: 1.5rem 2rem 2rem;
}

.detail-images {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.detail-img-wrap {
  flex: 1;
  min-width: 120px;
  max-width: 200px;
}

.detail-img-wrap img {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: zoom-in;
}

.detail-img-label {
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
  margin-top: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.detail-field { }
.detail-field label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 500;
  display: block;
  margin-bottom: 0.2rem;
}

.detail-field .value {
  font-size: 0.95rem;
  color: var(--charcoal);
}

.detail-notes {
  background: var(--cream);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  color: var(--charcoal-light);
  margin-bottom: 1.25rem;
  line-height: 1.6;
}

.detail-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  margin-top: 0.5rem;
}

.detail-shares {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.detail-shares h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-bottom: 0.6rem;
}

.share-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0;
  font-size: 0.88rem;
}

.share-user .btn-ghost-sm { font-size: 0.75rem; color: var(--rose); cursor: pointer; background: none; border: none; padding: 0.2rem 0.4rem; }

/* ─── Admin ──────────────────────────────────────────── */
.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 1.5rem;
  align-items: start;
}

.admin-card {
  background: var(--warm-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.admin-card h3 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--charcoal);
  margin-bottom: 1.25rem;
}

.admin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.admin-users-card { overflow: hidden; }

.users-list { display: flex; flex-direction: column; gap: 0; }

.user-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.5rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.user-row:last-child { border-bottom: none; }

.user-row-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--rose-pale);
  color: var(--rose);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}

.user-row-info { flex: 1; min-width: 0; }
.user-row-name { font-weight: 500; color: var(--charcoal); }
.user-row-email { font-size: 0.78rem; color: var(--muted); }

.role-badge {
  font-size: 0.68rem;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.role-badge.admin { background: var(--rose-pale); color: var(--rose); }
.role-badge.user { background: #edf2ef; color: var(--sage); }

.inactive-badge {
  font-size: 0.68rem;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  background: var(--cream-dark);
  color: var(--muted);
}

.user-row-actions { display: flex; gap: 0.4rem; }

.save-msg { font-size: 0.85rem; color: var(--sage); margin-left: 0.75rem; }

/* ─── Forms & Fields ─────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--charcoal-light);
  letter-spacing: 0.01em;
}

.field input, .field select, .field textarea {
  padding: 0.6rem 0.85rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--warm-white);
  font-family: var(--font-body);
  font-size: 0.92rem;
  color: var(--charcoal);
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}

.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--rose); }
.field textarea { resize: vertical; min-height: 80px; }

.checkbox-field { flex-direction: row !important; align-items: center; gap: 0.5rem !important; }
.checkbox-field label { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; font-weight: 400; }
.checkbox-field input[type="checkbox"] { width: auto; padding: 0; border: none; accent-color: var(--rose); }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

.req { color: var(--rose); }
.hint { font-size: 0.78rem; color: var(--muted); font-weight: 400; }

.form-error {
  background: #fdf0ee;
  color: #b85242;
  border: 1px solid #f0c4be;
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  font-size: 0.85rem;
}

.form-success {
  background: #edf5f0;
  color: #3a7a56;
  border: 1px solid #b8dfc8;
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  font-size: 0.85rem;
}

.auth-form .form-error, .auth-form .form-success { margin: 0; }

/* ─── Buttons ────────────────────────────────────────── */
.btn-primary {
  padding: 0.65rem 1.5rem;
  background: var(--rose);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}

.btn-primary:hover { background: #b5685a; }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
  padding: 0.6rem 1.25rem;
  background: transparent;
  color: var(--charcoal);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.88rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  white-space: nowrap;
}

.btn-secondary:hover { border-color: var(--charcoal-light); background: var(--cream); }

.btn-ghost {
  padding: 0.6rem 1.25rem;
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.88rem;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.btn-ghost:hover { color: var(--charcoal); background: var(--cream); }

.btn-full { width: 100%; }
.btn-sm { padding: 0.4rem 0.9rem; font-size: 0.82rem; }
.btn-danger { background: #c0392b !important; }
.btn-danger:hover { background: #a93226 !important; }

/* ─── Modals ─────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(44,40,37,0.5);
  backdrop-filter: blur(2px);
}

.modal-box {
  position: relative;
  background: var(--warm-white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.2s ease;
}

.modal-large { max-width: 820px; }

@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--warm-white);
  z-index: 1;
}

.modal-header h3 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 400;
  color: var(--charcoal);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  color: var(--muted);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: color 0.15s;
}

.modal-close:hover { color: var(--charcoal); }

.modal-form {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* ─── Pattern Form Cols ──────────────────────────────── */
.form-cols {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 1.5rem;
}

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

.images-col { gap: 0.75rem; }

.image-upload-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.image-upload-area {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

.image-preview {
  width: 100%;
  height: 140px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cream);
  transition: border-color 0.15s;
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
}

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

.upload-icon { font-size: 1.5rem; }
.upload-hint { font-size: 0.72rem; color: var(--rose-light); }
.upload-label { cursor: pointer; }

.share-intro { font-size: 0.9rem; color: var(--charcoal-light); }

/* ─── Responsive ─────────────────────────────────────── */
@media (max-width: 768px) {
  #page-app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  #sidebar {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    height: 100vh;
    padding-top: 4rem;
  }

  #sidebar.open { display: flex; }

  .mobile-header { display: flex; }

  #main-content { min-height: calc(100vh - 56px); }

  .view { padding: 1.25rem 1rem; }

  .view-header { flex-direction: column; align-items: flex-start; }
  .view-header .btn-primary { display: none; }

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

  .form-cols { grid-template-columns: 1fr; }
  .images-col { flex-direction: row; }
  .image-upload-group { flex-direction: row; }
  .image-upload-area { flex: 1; }

  .patterns-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .card-images { height: 120px; }
}

@media (max-width: 480px) {
  .filters { flex-direction: column; }
  .field-row { grid-template-columns: 1fr; }
  .modal-box { max-height: 95vh; }
}
