/* ═══════════════════════════════════════════════════════════════
   LOGO TOOLS — Shared Design System
   A unified stylesheet for all logo generator tools.
   ═══════════════════════════════════════════════════════════════ */

/* ── Design Tokens ── */
:root {
  /* Colors */
  --color-bg-body:        #0e0e0e;
  --color-bg-sidebar:     #161616;
  --color-bg-canvas:      #111111;
  --color-bg-surface:     #1e1e1e;
  --color-bg-elevated:    #262626;
  --color-bg-hover:       #2a2a2a;

  --color-border:         #2a2a2a;
  --color-border-subtle:  #222222;
  --color-border-focus:   #444444;

  --color-text-primary:   #e8e8e8;
  --color-text-secondary: #999999;
  --color-text-tertiary:  #666666;
  --color-text-muted:     #555555;

  --color-accent:         #e63946;
  --color-accent-hover:   #d62f3d;
  --color-accent-subtle:  rgba(230, 57, 70, 0.12);

  /* Typography */
  --font-sans:   -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono:   'SF Mono', 'Fira Code', 'Cascadia Code', monospace;

  --text-xs:     10px;
  --text-sm:     11px;
  --text-base:   12px;
  --text-md:     13px;
  --text-lg:     16px;
  --text-xl:     18px;

  --weight-normal:  400;
  --weight-medium:  500;
  --weight-semi:    600;
  --weight-bold:    700;

  --leading-tight:   1.3;
  --leading-normal:  1.5;
  --tracking-tight:  -0.02em;
  --tracking-wide:   0.06em;

  /* Spacing */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;

  /* Layout */
  --sidebar-width:    272px;
  --sidebar-padding:  24px 20px;
  --control-gap:      16px;
  --inner-gap:        4px;

  /* Radii */
  --radius-sm:   4px;
  --radius-md:   6px;
  --radius-lg:   8px;
  --radius-full: 50%;

  /* Transitions */
  --ease-default:  0.15s ease;
  --ease-smooth:   0.25s cubic-bezier(0.4, 0, 0.2, 1);

  /* Shadows */
  --shadow-canvas:  0 4px 32px rgba(0,0,0,0.5);
  --shadow-modal:   0 16px 48px rgba(0,0,0,0.6);
  --shadow-toast:   0 4px 16px rgba(0,0,0,0.4);
}

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

body {
  background: var(--color-bg-body);
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  display: flex;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ═══════════════════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════════════════ */

/* ── Sidebar ── */
.tool-sidebar {
  width: var(--sidebar-width);
  padding: var(--sidebar-padding);
  background: var(--color-bg-sidebar);
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: var(--control-gap);
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.tool-sidebar::-webkit-scrollbar { width: 4px; }
.tool-sidebar::-webkit-scrollbar-track { background: transparent; }
.tool-sidebar::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 2px;
}

/* ── Header ── */
.tool-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.tool-header__back {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--color-text-tertiary);
  cursor: pointer;
  transition: all var(--ease-default);
  flex-shrink: 0;
  text-decoration: none;
}

.tool-header__back:hover {
  background: var(--color-bg-elevated);
  color: var(--color-text-primary);
}

.tool-header__back svg {
  width: 16px;
  height: 16px;
}

.tool-header__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semi);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text-primary);
}

/* ── Hint text ── */
.tool-hint {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  line-height: var(--leading-normal);
}

/* ── Canvas Area ── */
.tool-canvas {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-canvas);
  overflow: hidden;
}

.tool-canvas canvas,
.tool-canvas svg {
  display: block;
}

/* Variant: fill entire area */
.tool-canvas--fill canvas {
  width: 100%;
  height: 100%;
}

/* Variant: centered with shadow (for fixed-size canvases) */
.tool-canvas--centered canvas {
  max-width: 90%;
  max-height: 90%;
  box-shadow: var(--shadow-canvas);
}


/* ═══════════════════════════════════════════════════════════════
   COMPONENTS
   ═══════════════════════════════════════════════════════════════ */

/* ── Control Group ── */
.control-group {
  display: flex;
  flex-direction: column;
  gap: var(--inner-gap);
}

.control-group label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: var(--text-base);
  color: var(--color-text-secondary);
}

.control-val,
.control-group .val {
  color: var(--color-text-tertiary);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

/* ── Section Label ── */
.section-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--color-text-muted);
  padding-top: var(--space-2);
}

/* ── Range Slider ── */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: #333;
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: var(--color-text-primary);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: transform var(--ease-default);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

input[type="range"]::-webkit-slider-thumb:active {
  transform: scale(0.95);
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--color-text-primary);
  border-radius: var(--radius-full);
  border: none;
  cursor: pointer;
}

/* ── Color Picker ── */
.color-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 32px;
  height: 26px;
  border: 1px solid var(--color-border-focus);
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
  padding: 0;
}

input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 2px; }
input[type="color"]::-moz-color-swatch { border: none; border-radius: 2px; }

.color-hex {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  font-family: var(--font-mono);
}

/* ── Buttons ── */
.btn {
  padding: 8px 14px;
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  font-family: var(--font-sans);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--ease-default);
  text-align: center;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn:active { transform: scale(0.97); }

/* Primary — accent filled */
.btn-primary {
  background: var(--color-accent);
  color: white;
  border-color: var(--color-accent);
}
.btn-primary:hover {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
}

/* Secondary — ghost outline */
.btn-secondary {
  background: var(--color-bg-elevated);
  color: var(--color-text-secondary);
  border-color: var(--color-border-focus);
}
.btn-secondary:hover {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
  border-color: var(--color-text-tertiary);
}

/* Full width */
.btn-full { width: 100%; }

/* Button rows */
.btn-row {
  display: flex;
  gap: var(--space-2);
}
.btn-row .btn { flex: 1; }

/* ── Select ── */
select {
  width: 100%;
  padding: 6px 8px;
  font-size: var(--text-md);
  font-family: var(--font-sans);
  background: var(--color-bg-surface);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border-focus);
  border-radius: var(--radius-sm);
  cursor: pointer;
  outline: none;
  transition: border-color var(--ease-default);
}
select:focus { border-color: var(--color-text-tertiary); }

/* ── Text Input ── */
input[type="text"],
input[type="number"] {
  background: var(--color-bg-surface);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border-focus);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  text-align: center;
  width: 100%;
  text-transform: uppercase;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color var(--ease-default);
}
input[type="text"]:focus,
input[type="number"]:focus {
  border-color: var(--color-text-tertiary);
}

/* ── Preset Buttons ── */
.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.preset-btn {
  padding: 5px 10px;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  font-family: var(--font-sans);
  background: var(--color-bg-elevated);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--ease-default);
}
.preset-btn:hover {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
}
.preset-btn.active {
  background: var(--color-bg-hover);
  border-color: var(--color-text-tertiary);
  color: var(--color-text-primary);
}

/* ── Picker Grid (letters, shapes) ── */
.picker-grid {
  display: grid;
  gap: 3px;
}
.picker-grid--letters { grid-template-columns: repeat(9, 1fr); }
.picker-grid--shapes  { grid-template-columns: repeat(5, 1fr); }

.picker-btn {
  padding: 5px 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-focus);
  background: var(--color-bg-elevated);
  color: var(--color-text-secondary);
  font-size: var(--text-base);
  font-weight: var(--weight-semi);
  font-family: var(--font-sans);
  cursor: pointer;
  text-align: center;
  transition: all 0.1s;
}
.picker-btn:hover {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
}
.picker-btn.active {
  background: var(--color-bg-hover);
  border-color: var(--color-text-tertiary);
  color: var(--color-text-primary);
}

/* ── Toggle / Checkbox ── */
.toggle-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}

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

.toggle-row span {
  font-size: var(--text-md);
  color: var(--color-text-secondary);
}


/* ═══════════════════════════════════════════════════════════════
   EXPORT PANEL
   ═══════════════════════════════════════════════════════════════ */

.export-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 900;
  opacity: 0;
  transition: opacity var(--ease-smooth);
  pointer-events: none;
}
.export-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.export-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 901;
  transform: translateY(100%);
  transition: transform var(--ease-smooth);
}
.export-panel.visible {
  transform: translateY(0);
}

.export-sheet {
  background: var(--color-bg-sidebar);
  border-top: 1px solid var(--color-border-focus);
  padding: 24px 32px 32px;
  max-width: 480px;
  margin: 0 auto;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.export-sheet__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.export-sheet__header h2 {
  font-size: var(--text-lg);
  font-weight: var(--weight-semi);
  letter-spacing: var(--tracking-tight);
}

.export-sheet__close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--color-text-tertiary);
  font-size: 18px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--ease-default);
}
.export-sheet__close:hover {
  background: var(--color-bg-elevated);
  color: var(--color-text-primary);
}

/* Format tabs */
.export-formats {
  display: flex;
  gap: 2px;
  background: var(--color-bg-body);
  border-radius: var(--radius-md);
  padding: 2px;
  margin-bottom: 16px;
}

.export-format-btn {
  flex: 1;
  padding: 7px 0;
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  font-family: var(--font-sans);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-tertiary);
  cursor: pointer;
  transition: all var(--ease-default);
}
.export-format-btn:hover {
  color: var(--color-text-secondary);
}
.export-format-btn.active {
  background: var(--color-bg-elevated);
  color: var(--color-text-primary);
}

/* Resolution pills */
.export-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.export-res-row {
  display: flex;
  gap: 6px;
}

.export-res-btn {
  padding: 5px 14px;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  font-family: var(--font-mono);
  border: 1px solid var(--color-border-focus);
  border-radius: var(--radius-sm);
  background: var(--color-bg-elevated);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--ease-default);
}
.export-res-btn:hover {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
}
.export-res-btn.active {
  border-color: var(--color-text-tertiary);
  color: var(--color-text-primary);
}

.export-dims {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  font-family: var(--font-mono);
  margin-left: 8px;
  align-self: center;
}

/* Export actions */
.export-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--color-bg-elevated);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border-focus);
  padding: 10px 20px;
  border-radius: var(--radius-lg);
  font-size: var(--text-md);
  font-family: var(--font-sans);
  box-shadow: var(--shadow-toast);
  opacity: 0;
  transition: all var(--ease-smooth);
  z-index: 1000;
  pointer-events: none;
  white-space: nowrap;
}
.toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast--error {
  border-color: var(--color-accent);
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  body {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .tool-sidebar {
    width: 100%;
    max-height: 45vh;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    padding: 16px;
    gap: 12px;
  }

  .tool-canvas {
    min-height: 55vh;
  }

  .export-sheet {
    max-width: 100%;
    padding: 20px 20px 28px;
  }
}
