/**
 * Design Tokens for AUPD Configurator
 * CSS Variables for colors, spacing, typography, shadows, etc.
 * Includes light/dark theme support (dark by default)
 */

/* === Color Palette - Dark Theme (Default) === */
:root, [data-theme="dark"] {
  /* Background Colors */
  --color-bg-primary: #0f172a;
  --color-bg-secondary: #1e293b;
  --color-bg-tertiary: #334155;
  --color-bg-elevated: #1e293b;
  
  /* Text Colors */
  --color-text-primary: #f1f5f9;
  --color-text-secondary: #cbd5e1;
  --color-text-muted: #94a3b8;
  --color-text-inverse: #0f172a;
  
  /* Accent Colors */
  --color-accentprimary: #3b82f6;
  --color-accent-hover: #2563eb;
  --color-accent-foreground: #ffffff;
  
  /* Semantic Colors */
  --color-success: #10b981;
  --color-success-bg: #064e3b;
  --color-warning: #f59e0b;
  --color-warning-bg: #78350f;
  --color-error: #ef4444;
  --color-error-bg: #7f1d1d;
  --color-info: #3b82f6;
  --color-info-bg: #1e3a8a;
  
  /* Border & Divider */
  --color-border: #334155;
  --color-divider: rgba(255, 255, 255, 0.1);
  
  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4), 0 4px 6px rgba(0, 0, 0, 0.2);
  
  /* Spacing Scale (4px base) */
  --spacing-xs: 0.25rem;   /* 4px */
  --spacing-sm: 0.5rem;    /* 8px */
  --spacing-md: 1rem;      /* 16px */
  --spacing-lg: 1.5rem;    /* 24px */
  --spacing-xl: 2rem;      /* 32px */
  --spacing-2xl: 3rem;     /* 48px */
  --spacing-3xl: 4rem;     /* 64px */
  --spacing-4xl: 6rem;     /* 96px */
  
  /* Border Radius */
  --radius-sm: 0.25rem;   /* 4px */
  --radius-md: 0.5rem;    /* 8px */
  --radius-lg: 0.75rem;   /* 12px */
  --radius-xl: 1rem;      /* 16px */
  --radius-full: 9999px;
  
  /* Typography Scale */
  --font-family-base: "Roboto", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --font-size-xs: 0.75rem;     /* 12px */
  --font-size-sm: 0.875rem;    /* 14px */
  --font-size-base: 1rem;     /* 16px */
  --font-size-lg: 1.125rem;    /* 18px */
  --font-size-xl: 1.25rem;     /* 20px */
  --font-size-2xl: 1.5rem;    /* 24px */
  
  /* Line Height */
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;
  
  /* Font Weight */
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 700;
  
  /* Transitions */
  --transition-fast: 150ms ease-out;
  --transition-normal: 250ms ease-out;
  --transition-slow: 350ms ease-out;

  /* Layout */
  --app-footer-height: 44px;
  --app-header-height: 104px;
}

/* === Light Theme === */
[data-theme="light"] {
  /* Background Colors */
  --color-bg-primary: #ffffff;
  --color-bg-secondary: #f8fafc;
  --color-bg-tertiary: #f1f5f9;
  --color-bg-elevated: #ffffff;
  
  /* Text Colors */
  --color-text-primary: #0f172a;
  --color-text-secondary: #475569;
  --color-text-muted: #64748b;
  --color-text-inverse: #ffffff;
  
  /* Semantic Backgrounds */
  --color-success-bg: #d1fae5;
  --color-warning-bg: #fef3c7;
  --color-error-bg: #fee2e2;
  --color-info-bg: #dbeafe;
  
  /* Border & Divider */
  --color-border: #e2e8f0;
  --color-divider: rgba(0, 0, 0, 0.1);
  
  /* Adjusted Shadows for Light Theme */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
}

/* === Global Resets & Base Styles === */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: var(--font-family-base);
  background-color: var(--color-bg-primary);
  color: var(--color-text-primary);
  line-height: var(--leading-normal);
  font-size: var(--font-size-base);
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* === Sticky footer (always visible) === */
html[data-app="configurator-v2"] .app-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
}

/* === Sticky header (always visible) === */
html[data-app="configurator-v2"] header {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  z-index: 60;
  height: var(--app-header-height);
}

/* Make header content vertically centered */
html[data-app="configurator-v2"] header > div {
  height: 100%;
  display: flex;
  align-items: center;
}

html[data-app="configurator-v2"] main {
  padding-bottom: var(--app-footer-height);
  padding-top: var(--app-header-height);
}

/* === Header layout (center title) === */
html[data-app="configurator-v2"] .app-header-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: 100%;
  padding: 0 var(--spacing-lg);
}

html[data-app="configurator-v2"] .app-header-left {
  justify-self: start;
}

html[data-app="configurator-v2"] .app-header-center {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
}

html[data-app="configurator-v2"] .app-header-right {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
}

html[data-app="configurator-v2"] .app-header-title {
  margin: 0;
}

/* === 3D logo flip === */
html[data-app="configurator-v2"] .logo-3d {
  width: 64px;
  height: 64px;
  perspective: 900px;
}

html[data-app="configurator-v2"] .logo-3d-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  animation: logoSpin3d 11.2s infinite linear;
}

html[data-app="configurator-v2"] .logo-3d-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--color-border);
  background: var(--color-bg-tertiary);
  box-shadow: var(--shadow-sm);
}

html[data-app="configurator-v2"] .logo-3d-face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

html[data-app="configurator-v2"] .logo-3d-back {
  transform: rotateY(180deg);
}

@keyframes logoSpin3d {
  0% { transform: rotateY(0deg); }
  100% { transform: rotateY(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  html[data-app="configurator-v2"] .logo-3d-inner {
    animation: none;
  }
}

/* === Typography === */
h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--spacing-md) 0;
  font-weight: var(--font-weight-semibold);
  line-height: var(--leading-tight);
  color: var(--color-text-primary);
}

h1 { font-size: var(--font-size-2xl); }
h2 { font-size: var(--font-size-xl); }
h3, h4 { font-size: var(--font-size-lg); }
h5, h6 { font-size: var(--font-size-base); }

p {
  margin-bottom: var(--spacing-md);
}

/* === Form Elements === */
input, select, textarea, button {
  font-family: inherit;
  font-size: inherit;
}

input:focus, select:focus, textarea:focus, button:focus {
  outline: 2px solid var(--color-accentprimary);
  outline-offset: 2px;
}

/* === Links === */
a {
  color: var(--color-accentprimary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-accent-hover);
}

/* === Utility Classes === */
.text-primary { color: var(--color-text-primary); }
.text-secondary { color: var(--color-text-secondary); }
.text-muted { color: var(--color-text-muted); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-error { color: var(--color-error); }

.text-center { text-align: center; }

.bg-primary { background-color: var(--color-bg-primary); }
.bg-secondary { background-color: var(--color-bg-secondary); }
.bg-elevated { background-color: var(--color-bg-elevated); }

.text-sm { font-size: var(--font-size-sm); }
.text-lg { font-size: var(--font-size-lg); }
.font-semibold { font-weight: var(--font-weight-semibold); }

.spacing-sm { padding: var(--spacing-sm); }