/* ============================================
   B2B QuoteTool — Modern Design System
   ============================================ */

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

:root {
  /* Color Palette */
  --color-bg: #f8f9fb;
  --color-surface: #ffffff;
  --color-surface-hover: #f3f4f6;
  --color-surface-active: #eef0f3;
  --color-border: #e5e7eb;
  --color-border-light: #f0f1f3;
  --color-text: #111827;
  --color-text-secondary: #6b7280;
  --color-text-tertiary: #9ca3af;
  --color-text-inverse: #ffffff;

  /* Accent */
  --color-primary: #4f46e5;
  --color-primary-hover: #4338ca;
  --color-primary-light: #eef2ff;
  --color-primary-subtle: #e0e7ff;

  /* Status Colors */
  --color-success: #059669;
  --color-success-bg: #ecfdf5;
  --color-warning: #d97706;
  --color-warning-bg: #fffbeb;
  --color-error: #dc2626;
  --color-error-bg: #fef2f2;
  --color-info: #2563eb;
  --color-info-bg: #eff6ff;

  /* Sidebar */
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;
  --sidebar-hover: #1e293b;
  --sidebar-width: 240px;

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

  /* Spacing (8px base) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--color-primary-hover); }

img { max-width: 100%; display: block; }
hr { border: none; border-top: 1px solid var(--color-border); margin: var(--space-6) 0; }

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-text);
  letter-spacing: -0.01em;
}
h1 { font-size: 1.875rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }
p { color: var(--color-text-secondary); line-height: 1.6; }
small { font-size: 0.8125rem; color: var(--color-text-tertiary); }

/* --- App Layout --- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.sidebar-brand svg { color: var(--color-primary); flex-shrink: 0; }
.sidebar-brand span {
  font-size: 1rem;
  font-weight: 700;
  color: var(--sidebar-text-active);
  letter-spacing: -0.02em;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-3) var(--space-3);
}

.sidebar-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(148,163,184,0.5);
  padding: var(--space-4) var(--space-3) var(--space-2);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  margin-bottom: 2px;
}
.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
}
.sidebar-link.active {
  background: rgba(79,70,229,0.15);
  color: var(--color-primary);
}
.sidebar-link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.7; }
.sidebar-link.active svg { opacity: 1; }

.sidebar-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid rgba(255,255,255,0.06);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-primary), #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}
.sidebar-user-info {
  flex: 1;
  min-width: 0;
}
.sidebar-user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--sidebar-text-active);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 0.6875rem;
  color: var(--sidebar-text);
  text-transform: capitalize;
}
.sidebar-logout {
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
}
.sidebar-logout:hover {
  color: var(--color-error);
  background: rgba(220,38,38,0.1);
}

/* --- Main Content --- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.page-container {
  max-width: 1120px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-8);
}

/* --- Page Header --- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-8);
}
.page-header-left { display: flex; flex-direction: column; gap: var(--space-1); }
.page-header h1 { margin: 0; }
.page-header p { margin: 0; }
.page-header-actions { display: flex; gap: var(--space-3); align-items: center; }

/* --- Cards --- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition-base);
}
.card:hover { box-shadow: var(--shadow-sm); }
.card-body { padding: var(--space-5); }
.card-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h3 { font-size: 0.875rem; font-weight: 600; }
.card-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-border);
  background: var(--color-bg);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* --- Stat Cards --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: all var(--transition-base);
}
.stat-card:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--color-primary-subtle);
}
.stat-label {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-tertiary);
  margin-bottom: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.stat-label svg { width: 14px; height: 14px; }
.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: var(--font-sans);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.5;
}
.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-color: var(--color-primary);
  box-shadow: 0 1px 2px rgba(79,70,229,0.3);
}
.btn-primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  color: var(--color-text-inverse);
  box-shadow: 0 2px 4px rgba(79,70,229,0.35);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
  background: var(--color-surface-hover);
  border-color: #d1d5db;
  color: var(--color-text);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.btn-success {
  background: var(--color-success);
  color: white;
  border-color: var(--color-success);
}
.btn-success:hover { background: #047857; border-color: #047857; color: white; }

.btn-danger {
  background: transparent;
  color: var(--color-error);
  border-color: var(--color-error);
}
.btn-danger:hover { background: var(--color-error); color: white; }

.btn-sm { padding: var(--space-1) var(--space-3); font-size: 0.75rem; }
.btn-lg { padding: var(--space-3) var(--space-6); font-size: 0.875rem; }
.btn:disabled, .btn[disabled] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn-icon { padding: var(--space-2); }

/* --- Forms --- */
.form-group { margin-bottom: var(--space-5); }
.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}
.form-hint {
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
  margin-top: var(--space-1);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-size: 0.875rem;
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  line-height: 1.5;
  outline: none;
}
.form-input:hover, .form-select:hover, .form-textarea:hover {
  border-color: #d1d5db;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}
.form-input::placeholder { color: var(--color-text-tertiary); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-select { appearance: auto; }

.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
}
.form-row-3 { grid-template-columns: repeat(3, 1fr); }

.form-actions {
  display: flex;
  gap: var(--space-3);
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-border);
  margin-top: var(--space-6);
}

/* --- Table --- */
.table-wrapper {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th {
  text-align: left;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-tertiary);
  padding: var(--space-3) var(--space-4);
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}
.data-table td {
  padding: var(--space-3) var(--space-4);
  font-size: 0.875rem;
  border-bottom: 1px solid var(--color-border-light);
  vertical-align: middle;
}
.data-table tbody tr {
  transition: background var(--transition-fast);
}
.data-table tbody tr:hover {
  background: var(--color-surface-hover);
}
.data-table tbody tr:last-child td {
  border-bottom: none;
}
.data-table tfoot td {
  background: var(--color-bg);
  font-weight: 600;
  border-top: 1px solid var(--color-border);
  border-bottom: none;
}
.table-actions {
  display: flex;
  gap: var(--space-1);
}

/* --- Status Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: capitalize;
  letter-spacing: 0.01em;
}
.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.badge-draft { background: #f3f4f6; color: #4b5563; }
.badge-draft::before { background: #9ca3af; }
.badge-sent { background: var(--color-info-bg); color: var(--color-info); }
.badge-sent::before { background: var(--color-info); }
.badge-approved { background: var(--color-success-bg); color: var(--color-success); }
.badge-approved::before { background: var(--color-success); }
.badge-changes_requested { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-changes_requested::before { background: var(--color-warning); }

/* --- Flash / Toast Messages --- */
.flash {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  font-weight: 500;
  margin-bottom: var(--space-6);
  animation: flashSlideIn 0.3s ease, flashFadeOut 0.4s ease 4s forwards;
}
.flash svg { width: 18px; height: 18px; flex-shrink: 0; }
.flash-success {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid #a7f3d0;
}
.flash-error {
  background: var(--color-error-bg);
  color: var(--color-error);
  border: 1px solid #fecaca;
}

@keyframes flashSlideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes flashFadeOut {
  to { opacity: 0; height: 0; padding: 0; margin: 0; overflow: hidden; }
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-8);
}
.empty-state svg {
  width: 48px;
  height: 48px;
  color: var(--color-text-tertiary);
  margin: 0 auto var(--space-4);
  opacity: 0.5;
}
.empty-state h3 { margin-bottom: var(--space-2); color: var(--color-text); }
.empty-state p { margin-bottom: var(--space-5); }

/* --- Search Bar --- */
.search-bar {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}
.search-bar .form-input {
  flex: 1;
  padding-left: var(--space-8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cpath d='m21 21-4.3-4.3'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
}

/* --- Filter Bar --- */
.filter-bar {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-5);
}
.filter-bar .form-select {
  width: auto;
  min-width: 180px;
}
.filter-bar label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

/* --- Info Grid (quote detail) --- */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}
.info-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}
.info-card-title {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-tertiary);
  margin-bottom: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.info-card-title svg { width: 14px; height: 14px; }
.info-row {
  display: flex;
  justify-content: space-between;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border-light);
}
.info-row:last-child { border-bottom: none; }
.info-row-label { color: var(--color-text-secondary); font-size: 0.8125rem; }
.info-row-value { color: var(--color-text); font-weight: 500; font-size: 0.8125rem; }

/* --- Section Headers --- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}
.section-header h2 { font-size: 1.125rem; }
.section-header h3 { font-size: 1rem; }

/* --- Line Item Card (quote form) --- */
.line-item-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-3);
  transition: border-color var(--transition-fast);
}
.line-item-card:hover {
  border-color: var(--color-primary-subtle);
}
.line-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-4);
}
.line-item-number {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.line-item-total {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-primary);
  background: var(--color-primary-light);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
}

/* --- Grand Total Bar --- */
.grand-total-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-6);
}
.grand-total-label { font-size: 0.875rem; color: var(--color-text-secondary); }
.grand-total-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

/* --- Status Actions (quote detail) --- */
.status-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* --- Mockup Section --- */
.mockup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
}
.mockup-thumb {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
}
.mockup-thumb img {
  width: 100%;
  height: auto;
  display: block;
}

/* --- Login Page --- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  padding: var(--space-4);
}
.login-card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-10);
  width: 100%;
  max-width: 400px;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
}
.login-brand svg { color: var(--color-primary); }
.login-brand span {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.login-card h2 {
  font-size: 1.25rem;
  margin-bottom: var(--space-1);
}
.login-card .login-subtitle {
  color: var(--color-text-secondary);
  margin-bottom: var(--space-6);
  font-size: 0.875rem;
}

/* --- Mockup Editor Layout --- */
.editor-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}
.editor-sidebar {
  width: 300px;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.editor-sidebar-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.editor-sidebar-header a {
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.8125rem;
  font-weight: 500;
}
.editor-sidebar-header a:hover { color: var(--color-text); }

.editor-panel {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}
.editor-panel-title {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-tertiary);
  margin-bottom: var(--space-3);
}

.editor-item {
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.editor-item:hover {
  border-color: var(--color-primary-subtle);
  background: var(--color-primary-light);
}
.editor-item.active {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
  box-shadow: 0 0 0 2px var(--color-primary-subtle);
}
.editor-item strong { font-size: 0.8125rem; color: var(--color-text); display: block; }
.editor-item small { font-size: 0.75rem; color: var(--color-text-tertiary); }

.editor-canvas-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  padding: var(--space-8);
  flex-direction: column;
  gap: var(--space-6);
}
#canvasContainer {
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  background: white;
  transform-origin: center center;
  transition: transform 0.2s ease;
}

.editor-slider-group {
  margin-bottom: var(--space-4);
}
.editor-slider-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-1);
}
.editor-slider-label span {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text);
}
.editor-slider-label small {
  font-size: 0.75rem;
  color: var(--color-text-tertiary);
  font-variant-numeric: tabular-nums;
}
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--color-border);
  outline: none;
  transition: background var(--transition-fast);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(79,70,229,0.4);
  transition: transform var(--transition-fast);
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.2); }
input[type="range"]:disabled { opacity: 0.4; }

.upload-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}
.upload-zone:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}
.upload-zone svg {
  width: 24px;
  height: 24px;
  color: var(--color-text-tertiary);
  margin: 0 auto var(--space-2);
}
.upload-zone p { font-size: 0.8125rem; color: var(--color-text-secondary); margin: 0; }
.upload-zone small { color: var(--color-text-tertiary); }
.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.upload-zone.disabled { opacity: 0.4; pointer-events: none; }

/* Upload/Save status */
.status-message {
  display: none;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.8125rem;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  margin-top: var(--space-3);
}
.status-message.visible { display: flex; }
.status-message.loading { background: var(--color-info-bg); color: var(--color-info); }
.status-message.success { background: var(--color-success-bg); color: var(--color-success); }
.status-message.error { background: var(--color-error-bg); color: var(--color-error); }

/* Spinner */
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Preview Section --- */
#previewContainer {
  display: none;
  max-width: 500px;
  text-align: center;
}
#previewContainer h4 {
  font-size: 0.875rem;
  margin-bottom: var(--space-3);
  color: var(--color-text-secondary);
}
#previewImage {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* --- Canvas Toolbar & Bottom Bar --- */
.canvas-toolbar,
.canvas-bottom-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  width: 100%;
  max-width: 640px;
}
.canvas-bottom-bar {
  justify-content: center;
  gap: var(--space-3);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.toolbar-separator {
  width: 1px;
  height: 20px;
  background: var(--color-border);
  margin: 0 var(--space-2);
}
.toolbar-spacer { flex: 1; }
.zoom-display {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  min-width: 40px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.btn-toolbar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.btn-toolbar:hover {
  background: var(--color-surface-hover, #f1f5f9);
  color: var(--color-text);
}
.btn-toolbar.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
}
.btn-toolbar svg { width: 16px; height: 16px; }

.btn-bottom {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
}
.btn-bottom:hover {
  background: var(--color-surface-hover, #f1f5f9);
  color: var(--color-text);
  border-color: var(--color-text-tertiary);
}
.btn-bottom.active {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}
.btn-bottom svg { width: 14px; height: 14px; }

/* --- Canvas Workspace --- */
.canvas-workspace {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: auto;
}

/* --- Product Info Badge --- */
.product-info-badge {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  display: none;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  box-shadow: var(--shadow-xs);
  z-index: 10;
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.product-info-badge .badge-product-name {
  font-weight: 600;
  color: var(--color-text);
}
.product-info-badge .badge-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--color-text-tertiary);
  flex-shrink: 0;
}

/* --- Canvas Background Modes --- */
#canvasContainer.bg-white { background: #ffffff; }
#canvasContainer.bg-dark { background: #1a1a2e; }
#canvasContainer.bg-checkered {
  background-color: #ffffff;
  background-image:
    linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
    linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
}

/* --- Fullscreen Mode --- */
.editor-canvas-area.fullscreen {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--color-bg);
  padding: var(--space-6);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .page-container { padding: var(--space-4); }
  .page-header { flex-direction: column; align-items: flex-start; gap: var(--space-3); }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .info-grid { grid-template-columns: 1fr; }
  .editor-layout { flex-direction: column; height: auto; }
  .editor-sidebar { width: 100%; max-height: 40vh; }
  .canvas-toolbar, .canvas-bottom-bar { max-width: 100%; }
  .data-table { font-size: 0.8125rem; }
  .data-table th, .data-table td { padding: var(--space-2) var(--space-3); }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .status-actions { flex-direction: column; }
}
