/* ===========================================
   StickerPress — style.css
   Custom CSS variables + component overrides
   =========================================== */

/* -------- CSS VARIABLES (Light Theme) -------- */
:root {
  --accent: #f97316; /* orange-500 */
  --accent-light: #fed7aa; /* orange-200 */
  --accent-dark: #c2410c; /* orange-700 */

  --bg-app: #f8f7f5;
  --bg-canvas: #ede9e4;
  --bg-card: #ffffff;
  --bg-input: #f1efec;
  --bg-hover: #e8e5e1;

  --text-primary: #1c1917;
  --text-secondary: #57534e;
  --text-muted: #a8a29e;

  --border: #e7e5e4;
  --border-strong: #d6d3d1;

  --shadow-paper: 0 8px 40px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);

  --ruler-bg: #f8f7f5;
  --ruler-tick: #a8a29e;
}

/* -------- Dark Theme -------- */
html.dark {
  --bg-app: #141312;
  --bg-canvas: #0e0d0c;
  --bg-card: #1e1c1b;
  --bg-input: #2a2826;
  --bg-hover: #312f2d;

  --text-primary: #fafaf9;
  --text-secondary: #a8a29e;
  --text-muted: #57534e;

  --border: #2a2826;
  --border-strong: #3d3a37;

  --shadow-paper: 0 8px 40px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);

  --ruler-bg: #1e1c1b;
  --ruler-tick: #57534e;
}

/* -------- Base -------- */
* {
  box-sizing: border-box;
}

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* -------- Scrollbar -------- */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}

/* -------- Navbar -------- */
.navbar {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* -------- Logo Icon -------- */
.logo-icon {
  background: linear-gradient(135deg, var(--accent), #fb923c);
  font-family: "Syne", sans-serif;
  font-size: 14px;
  font-weight: 800;
}

/* -------- Count badge -------- */
.count-badge {
  background: var(--bg-input);
  color: var(--text-secondary);
}

/* -------- Icon button -------- */
.icon-btn {
  color: var(--text-secondary);
  transition:
    background 0.15s,
    color 0.15s;
}
.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* -------- Action button -------- */
.action-btn {
  background: var(--accent);
  color: white;
  transition:
    background 0.15s,
    transform 0.1s;
}
.action-btn:hover {
  background: var(--accent-dark);
}
.action-btn:active {
  transform: scale(0.97);
}

/* -------- Sidebar -------- */
.sidebar {
  background: var(--bg-card);
}

/* -------- Section title -------- */
.section-title {
  color: var(--text-muted);
  letter-spacing: 0.1em;
}

/* -------- Drop Zone -------- */
.drop-zone {
  border: 2px dashed var(--border-strong);
  background: var(--bg-input);
  color: var(--text-secondary);
  transition:
    border-color 0.2s,
    background 0.2s;
}
.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: #fff7ed;
}
html.dark .drop-zone:hover,
html.dark .drop-zone.drag-over {
  background: #2a1a0a;
}
.drop-icon {
  background: var(--bg-hover);
  color: var(--text-secondary);
  transition:
    background 0.2s,
    color 0.2s;
}
.drop-zone:hover .drop-icon,
.drop-zone.drag-over .drop-icon {
  background: var(--accent-light);
  color: var(--accent-dark);
}

/* -------- Thumbnail -------- */
.thumb-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: var(--bg-input);
  transition: border-color 0.15s;
}
.thumb-item:hover {
  border-color: var(--accent);
}
.thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.thumb-item .thumb-remove {
  display: none;
  position: absolute;
  top: 1px;
  right: 1px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ef4444;
  color: white;
  font-size: 9px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  line-height: 1;
}
.thumb-item:hover .thumb-remove {
  display: flex;
}

/* -------- Preset buttons -------- */
.preset-btn {
  border: 1.5px solid var(--border);
  background: var(--bg-input);
  color: var(--text-secondary);
  transition: all 0.15s;
}
.preset-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.preset-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* -------- Unit buttons -------- */
.unit-btn {
  color: var(--text-muted);
  transition: all 0.15s;
}
.unit-btn.active {
  background: var(--bg-card);
  color: var(--accent);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* -------- Toggle -------- */
.toggle-track {
  background: var(--border-strong);
  transition: background 0.2s;
}
input[type="checkbox"]:checked ~ .toggle-track {
  background: var(--accent);
}
.toggle-thumb {
  transition: transform 0.2s;
}
input[type="checkbox"]:checked ~ .toggle-thumb {
  transform: translateX(16px);
}

/* -------- Input fields -------- */
.input-field {
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
  font-family: "DM Sans", sans-serif;
}
.input-field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.12);
}

/* -------- Label xs -------- */
.label-xs {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

/* -------- Range slider -------- */
.range-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border-strong);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
}
.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid white;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition: transform 0.1s;
}
.range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* -------- Color input -------- */
.color-input {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  padding: 2px;
  cursor: pointer;
  background: none;
  overflow: hidden;
}
.color-input::-webkit-color-swatch-wrapper {
  padding: 0;
}
.color-input::-webkit-color-swatch {
  border-radius: 5px;
  border: none;
}

/* -------- Reset button -------- */
.reset-btn {
  border: 1.5px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text-secondary);
}
.reset-btn:hover {
  border-color: #ef4444;
  color: #ef4444;
  background: #fef2f2;
}
html.dark .reset-btn:hover {
  background: #2d1111;
}

/* -------- Canvas toolbar -------- */
.canvas-toolbar {
  background: var(--bg-card);
  min-height: 44px;
}

/* -------- Zoom buttons -------- */
.zoom-btn {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  transition:
    background 0.15s,
    color 0.15s;
  border-radius: 6px;
}
.zoom-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* -------- Paper sheet -------- */
.paper-sheet {
  box-shadow: var(--shadow-paper);
  transition: box-shadow 0.3s;
}

/* -------- Sticker items -------- */
.sticker-item {
  position: absolute;
  overflow: hidden;
  cursor: grab;
  border-radius: 4px;
  transition:
    box-shadow 0.15s,
    outline 0.1s;
  user-select: none;
  -webkit-user-select: none;
}
.sticker-item:hover {
  z-index: 10;
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.sticker-item.dragging {
  cursor: grabbing;
  z-index: 100;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
  outline: 2px solid var(--accent);
}
.sticker-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  display: block;
}

/* -------- Ruler canvases -------- */
.ruler-h,
.ruler-v {
  background: var(--ruler-bg);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

/* -------- Transparent checkerboard -------- */
.transparent-bg {
  background-image:
    linear-gradient(45deg, #ccc 25%, transparent 25%),
    linear-gradient(-45deg, #ccc 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ccc 75%),
    linear-gradient(-45deg, transparent 75%, #ccc 75%);
  background-size: 12px 12px;
  background-position:
    0 0,
    0 6px,
    6px -6px,
    -6px 0px;
}

/* -------- Spinner -------- */
.spinner {
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* -------- Grid overlay (snap) -------- */
.grid-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(249, 115, 22, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(249, 115, 22, 0.06) 1px, transparent 1px);
  background-size: var(--grid-size-x, 50px) var(--grid-size-y, 50px);
  z-index: 0;
}

/* -------- Print styles -------- */
@media print {
  body > *:not(#printArea) {
    display: none !important;
  }
  #printArea {
    display: block !important;
    position: fixed;
    inset: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
  }
  #printArea .paper-sheet {
    box-shadow: none !important;
    margin: 0;
    page-break-inside: avoid;
  }
}

/* -------- Transitions -------- */
.sidebar-section {
  transition: background 0.2s;
}
.sidebar-section:hover {
  background: var(--bg-input);
}
