/* ═══════════════════════════════════════════════════════════════════
   PaperFrame Studio — style.css
   Clean craft-studio aesthetic with full responsiveness
═══════════════════════════════════════════════════════════════════ */

/* ── Design Tokens ── */
:root {
  --bg-page:         #F4F1EC;
  --bg-sidebar:      #FEFCF8;
  --bg-workspace:    #E8E4DC;
  --bg-canvas-wrap:  #D5D0C6;
  --accent:          #3D7EAA;
  --accent-hover:    #2F6289;
  --accent-2:        #E8734A;
  --danger:          #C0392B;
  --success:         #27AE60;
  --text-primary:    #1A1A1A;
  --text-secondary:  #5A5A5A;
  --text-muted:      #8A8A8A;
  --border:          #DDD8CF;
  --border-dark:     #C8C2B6;
  --shadow-sm:       0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:       0 4px 16px rgba(0,0,0,0.12);
  --shadow-lg:       0 8px 32px rgba(0,0,0,0.18);
  --radius-sm:       6px;
  --radius-md:       10px;
  --radius-lg:       16px;
  --sidebar-w:       300px;
  --header-h:        60px;
  --font-sans:       'Segoe UI', system-ui, -apple-system, sans-serif;
  --transition:      0.18s ease;
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ── App Header ── */
.app-header {
  height: var(--header-h);
  background: #FEFCF8;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon { font-size: 1.6rem; line-height: 1; }

.brand-text h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.brand-tagline {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: block;
  margin-top: 1px;
}

.header-privacy { }

.privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #EAF7EE;
  color: var(--success);
  border: 1px solid #B8DFCA;
  border-radius: 20px;
  padding: 4px 11px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.2px;
}

/* ── Main Layout ── */
.app-layout {
  display: flex;
  flex: 1;
  min-height: calc(100vh - var(--header-h));
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 14px 32px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* custom scrollbar */
.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 4px; }

/* ── Sidebar Sections ── */
.sidebar-section {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

/* ── Button Groups ── */
.btn-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-toggle {
  flex: 1;
  min-width: 70px;
  padding: 8px 10px;
  border: 1.5px solid var(--border-dark);
  border-radius: var(--radius-sm);
  background: #F9F7F4;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.btn-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: #EBF4FB;
}

.btn-toggle.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.btn-icon { font-size: 0.95em; }

/* ── Control Labels ── */
.ctrl-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: block;
}

/* ── Sliders ── */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 3px;
  background: var(--border-dark);
  outline: none;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  cursor: pointer;
  transition: transform 0.1s;
}

.slider::-webkit-slider-thumb:hover { transform: scale(1.2); }

.slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  cursor: pointer;
}

/* ── Color Swatches ── */
.color-swatch-grid {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2.5px solid var(--border-dark);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  position: relative;
  flex-shrink: 0;
  background: none; /* will be set inline */
}

#swatch-white  { background: #FFFFFF; }
#swatch-black  { background: #1C1C1C; }
#swatch-kraft  { background: #B5894A; }
#swatch-cream  { background: #F5EDD6; }

.swatch:hover { transform: scale(1.15); border-color: var(--accent); }

.swatch.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(61,126,170,0.3);
  transform: scale(1.1);
}

.swatch-custom {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  background: linear-gradient(135deg, #f9b5ac, #fcdfa6, #b5e7a0, #a2cffe);
  cursor: pointer;
}

.swatch-custom input[type="color"] {
  position: absolute;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: none;
}

/* ── Drop Zone ── */
.drop-zone {
  border: 2px dashed var(--border-dark);
  border-radius: var(--radius-md);
  padding: 20px 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: #FAFAF8;
  user-select: none;
}

.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: #EBF4FB;
}

.drop-zone:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(61,126,170,0.25);
}

.drop-icon { font-size: 2rem; display: block; margin-bottom: 8px; }

.drop-text {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.drop-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 5px;
}

/* ── Checkboxes ── */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.checkbox-row label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
}

/* ── Primary / Secondary Buttons ── */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  padding: 11px 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s, transform 0.1s;
  letter-spacing: 0.2px;
}

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

.btn-primary.btn-secondary-style {
  background: #F4F1EC;
  color: var(--accent);
  border: 1.5px solid var(--border-dark);
}
.btn-primary.btn-secondary-style:hover { background: #EBF4FB; border-color: var(--accent); }

.btn-secondary {
  width: 100%;
  padding: 7px 12px;
  border: 1.5px solid #E0D6C8;
  border-radius: var(--radius-sm);
  background: #FFF5F5;
  color: var(--danger);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-secondary:hover { background: #FCEAEA; }

/* ── Print Tip ── */
.print-tip {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  background: #FFFBEC;
  border: 1px solid #EED98A;
  border-radius: var(--radius-sm);
  padding: 10px 11px;
  font-size: 0.75rem;
  color: #6B5600;
  line-height: 1.5;
}

.tip-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }

/* ══════════════════════════════════════════════
   WORKSPACE
══════════════════════════════════════════════ */
.workspace {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-workspace);
}

.workspace-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: rgba(255,255,255,0.65);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(4px);
  flex-shrink: 0;
}

.canvas-info {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

.toolbar-right { display: flex; gap: 8px; }

.btn-sm {
  padding: 5px 11px;
  border: 1.5px solid var(--border-dark);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.btn-sm:hover { border-color: var(--accent); color: var(--accent); }

/* ── Canvas Wrapper ── */
.canvas-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: auto;
  position: relative;
}

#main-canvas {
  display: block;
  box-shadow: var(--shadow-lg);
  cursor: grab;
  max-width: 100%;
  max-height: 100%;
  border-radius: 2px;
  background: #fff;
}

#main-canvas:active { cursor: grabbing; }

.canvas-hint {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(26,26,26,0.72);
  color: #fff;
  font-size: 0.75rem;
  padding: 7px 14px;
  border-radius: 20px;
  pointer-events: none;
  transition: opacity 0.3s;
  white-space: nowrap;
}

.canvas-hint.hidden { opacity: 0; }

/* ══════════════════════════════════════════════
   MODALS
══════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(3px);
}

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

.modal-box {
  background: #fff;
  border-radius: var(--radius-lg);
  max-width: 580px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 28px 32px;
  position: relative;
  box-shadow: var(--shadow-lg);
}

.modal-box-sm { max-width: 440px; }

.modal-close {
  position: absolute;
  top: 16px;
  right: 18px;
  width: 30px;
  height: 30px;
  border: none;
  background: #F0ECE6;
  border-radius: 50%;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background 0.15s;
}

.modal-close:hover { background: #E0D8CE; color: var(--text-primary); }

.modal-box h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.modal-intro {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 18px;
}

.steps-list {
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.steps-list li {
  font-size: 0.84rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.steps-list li strong { color: var(--text-primary); }

.modal-note {
  margin-top: 20px;
  background: #FFFBEC;
  border: 1px solid #EED98A;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.8rem;
  color: #6B5600;
  line-height: 1.5;
}

/* ── Legend ── */
.legend-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 10px;
}

.legend-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.legend-line {
  width: 60px;
  height: 3px;
  flex-shrink: 0;
  margin-top: 8px;
  border-radius: 2px;
}

.legend-fold {
  border-top: 2.5px dashed #3A86C8;
  height: 0;
}

.legend-cut {
  border-top: 2.5px solid #C0392B;
  height: 0;
}

.legend-tab {
  border-top: 2.5px dashed #E8734A;
  height: 0;
}

.legend-outer {
  border-top: 1.5px solid #AAA;
  height: 0;
}

.legend-item > div {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.legend-item > div strong { color: var(--text-primary); }

/* ══════════════════════════════════════════════
   RESPONSIVE — Mobile & Tablet
══════════════════════════════════════════════ */
@media (max-width: 768px) {
  .app-layout {
    flex-direction: column;
    overflow-y: auto;
    min-height: auto;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: none;
    overflow-y: visible;
    padding: 12px 12px 20px;
  }

  .workspace {
    min-height: 60vw;
  }

  .canvas-wrapper { padding: 14px; }

  .brand-tagline { display: none; }

  .btn-group { flex-wrap: nowrap; }

  .modal-box { padding: 20px 18px; }
}

@media (max-width: 480px) {
  :root { --sidebar-w: 100%; }

  .header-privacy { display: none; }

  .workspace-toolbar { flex-direction: column; gap: 6px; align-items: flex-start; }
}

/* ── Loading Spinner ── */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}

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

/* ── Utility ── */
.hidden { display: none !important; }

