/* ══════════════════════════════════════════
   PaintProof App Styles
   Design tokens from landing page
   ══════════════════════════════════════════ */

:root {
  --ink: #0d0d0d;
  --chalk: #fafaf8;
  --swatch-blue: #3d5a80;
  --swatch-sage: #6b8f71;
  --swatch-warm: #d4a574;
  --swatch-clay: #c17f59;
  --swatch-slate: #7f8c9b;
  --accent: #e8572a;
  --accent-hover: #d14a21;
  --muted: #8a8a82;
  --border: rgba(0,0,0,0.08);
  --card-bg: #ffffff;
  --sidebar-bg: #f6f5f2;
  --radius: 14px;
  --radius-sm: 8px;
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--chalk);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4 { font-family: 'Space Grotesk', sans-serif; }

/* ── App Nav ── */
.app-nav {
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 100;
  padding: 0.9rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(250, 250, 248, 0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.app-nav .logo {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: -0.5px;
  color: var(--ink);
  text-decoration: none;
}

.app-nav .logo span { color: var(--accent); }

.nav-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }

.btn-secondary {
  background: white;
  color: var(--ink);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: #f0efec; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
}
.btn-ghost:hover { color: var(--ink); }

.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }

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

/* ── App Layout ── */
.app-container {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 0;
  min-height: 100vh;
  padding-top: 52px;
}

/* ── Canvas Area ── */
.canvas-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  position: relative;
  background: #e8e4dd;
  min-height: calc(100vh - 52px);
}

.canvas-wrapper {
  position: relative;
  max-width: 100%;
  max-height: calc(100vh - 160px);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0,0,0,0.1);
}

#paint-canvas {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 160px);
  cursor: crosshair;
}

.canvas-controls {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  align-items: center;
}

.view-toggle {
  display: flex;
  background: white;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.view-toggle button {
  padding: 0.45rem 1rem;
  font-size: 0.8rem;
  font-family: 'DM Sans', sans-serif;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
}

.view-toggle button.active {
  background: var(--accent);
  color: white;
}

/* ── Upload Area ── */
.upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 560px;
  min-height: 380px;
  border: 2px dashed rgba(0,0,0,0.15);
  border-radius: var(--radius);
  background: white;
  cursor: pointer;
  transition: all 0.2s;
  padding: 3rem;
  text-align: center;
}

.upload-area:hover {
  border-color: var(--accent);
  background: rgba(232, 87, 42, 0.02);
}

.upload-area.dragover {
  border-color: var(--accent);
  background: rgba(232, 87, 42, 0.05);
  transform: scale(1.01);
}

.upload-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.4;
}

.upload-area h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  letter-spacing: -0.5px;
}

.upload-area p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* ── Sidebar ── */
.sidebar {
  background: var(--sidebar-bg);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  max-height: calc(100vh - 52px);
  padding-bottom: 2rem;
}

.sidebar-section {
  padding: 1.25rem 1.25rem 0;
}

.sidebar-section h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

/* ── Surface List ── */
.surface-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.1s;
  margin-bottom: 0.35rem;
  background: white;
  border: 1px solid transparent;
}

.surface-item:hover { border-color: var(--border); }

.surface-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(232, 87, 42, 0.15);
}

.surface-swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.1);
  flex-shrink: 0;
}

.surface-info {
  flex: 1;
  min-width: 0;
}

.surface-label {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.surface-color-name {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.surface-remove {
  opacity: 0;
  padding: 0.2rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.8rem;
  transition: opacity 0.15s;
}

.surface-item:hover .surface-remove { opacity: 1; }

/* ── Tolerance Slider ── */
.tolerance-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
}

.tolerance-row label {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

.tolerance-row input[type=range] {
  flex: 1;
  accent-color: var(--accent);
}

.tolerance-row .tol-val {
  font-size: 0.75rem;
  color: var(--muted);
  min-width: 24px;
  text-align: right;
}

/* ── Brand Tabs ── */
.brand-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 0.75rem;
  background: white;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.brand-tab {
  flex: 1;
  padding: 0.5rem 0.25rem;
  font-size: 0.68rem;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  text-align: center;
  transition: all 0.15s;
  white-space: nowrap;
}

.brand-tab.active {
  background: var(--ink);
  color: white;
}

/* ── Category Filters ── */
.category-filters {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.cat-filter {
  padding: 0.25rem 0.6rem;
  font-size: 0.7rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  color: var(--muted);
  transition: all 0.15s;
}

.cat-filter.active {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}

/* ── Color Grid ── */
.color-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.color-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
  border: 2px solid transparent;
}

.color-chip:hover {
  background: white;
  transform: translateY(-2px);
}

.color-chip.selected {
  border-color: var(--accent);
  background: white;
}

.chip-swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.08);
}

.chip-name {
  font-size: 0.62rem;
  text-align: center;
  line-height: 1.2;
  color: var(--ink);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-code {
  font-size: 0.58rem;
  color: var(--muted);
}

/* ── Share Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-overlay.show { display: flex; }

.modal {
  background: white;
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 460px;
  width: 90%;
  box-shadow: 0 24px 64px rgba(0,0,0,0.15);
}

.modal h2 {
  font-size: 1.3rem;
  margin-bottom: 0.75rem;
  letter-spacing: -0.5px;
}

.modal p {
  color: #555;
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 1.25rem;
}

.share-link-box {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.share-link-box input {
  flex: 1;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  color: var(--ink);
  background: var(--sidebar-bg);
}

.share-link-box input:focus {
  outline: none;
  border-color: var(--accent);
}

/* ── Loading / Processing States ── */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(250, 250, 248, 0.88);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 50;
  border-radius: var(--radius);
}

.loading-overlay.show { display: flex; }

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 1rem;
}

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

.loading-text {
  font-size: 0.9rem;
  color: var(--muted);
}

/* ── Empty State ── */
.empty-sidebar {
  padding: 2rem 1.25rem;
  text-align: center;
  color: var(--muted);
}

.empty-sidebar p {
  font-size: 0.85rem;
  line-height: 1.6;
}

/* ── Notification Toast ── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--ink);
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  z-index: 300;
  transition: transform 0.3s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.toast.show { transform: translateX(-50%) translateY(0); }

/* ── Responsive ── */
@media (max-width: 900px) {
  .app-container {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: none;
  }

  .canvas-area {
    min-height: 50vh;
    padding: 0.75rem;
  }

  .canvas-wrapper {
    width: 100%;
    max-width: 100%;
  }

  #paint-canvas {
    width: 100%;
    height: auto;
    max-height: 55vh;
  }

  .upload-area {
    max-width: 100%;
  }
}

@media (max-width: 600px) {
  .app-nav { padding: 0.75rem 1rem; }
  .canvas-area { padding: 0.5rem; }
  .upload-area { min-height: 260px; padding: 2rem 1.5rem; }
  .color-grid { grid-template-columns: repeat(3, 1fr); }

  .canvas-controls {
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* ── Share Page ── */
.share-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 6rem 2rem 3rem;
  text-align: center;
}

.share-page h1 {
  font-size: 1.8rem;
  letter-spacing: -1px;
  margin-bottom: 0.5rem;
}

.share-page .subtitle {
  color: var(--muted);
  margin-bottom: 2rem;
}

.share-comparison {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 2rem;
}

.share-comparison .panel {
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}

.share-comparison .panel canvas {
  width: 100%;
  display: block;
}

.share-comparison .panel-label {
  padding: 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.share-colors {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}

.share-color-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: white;
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.share-color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.1);
}

.share-color-info {
  text-align: left;
}

.share-color-info .name {
  font-size: 0.8rem;
  font-weight: 500;
}

.share-color-info .detail {
  font-size: 0.7rem;
  color: var(--muted);
}

.share-cta {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.share-cta p {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

/* ── Expired Link ── */
.expired-page {
  max-width: 500px;
  margin: 0 auto;
  padding: 10rem 2rem;
  text-align: center;
}

.expired-page h1 {
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
}

.expired-page p {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
}
