/* ===== VARIABILI CSS ===== */
:root {
  /* Palette Moderna */
  --primary-dark: #1a1a1a;
  --primary-darker: #0d0d0d;
  --primary-gray: #2d2d2d;
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-green: #10b981;
  --accent-orange: #f59e0b;
  --text-light: #f8fafc;
  --text-gray: #94a3b8;
  --surface: #1e293b;
  --surface-light: #334155;
  
  /* Tipografia */
  --font-body: 'Inter', sans-serif;
  
  /* Spaziatura */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-xxl: 48px;
  
  /* Bordi */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  /* Ombre */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
}

/* ===== RESET E BASE ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background: linear-gradient(135deg, var(--primary-darker) 0%, var(--primary-dark) 100%);
  color: var(--text-light);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== LAYOUT PRINCIPALE ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-xl);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.title {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 700;
  text-align: center;
  background: linear-gradient(135deg, #d4af37, #f4e4a6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--space-md);
}

.subtitle {
  text-align: center;
  color: var(--text-gray);
  margin-bottom: var(--space-xl);
  font-size: 1.1rem;
  font-weight: 400;
}

.main-content {
  display: grid;
  gap: var(--space-xxl);
  grid-template-columns: 420px 1fr;
  align-items: start;
  flex: 1;
  margin-bottom: var(--space-xl);
}

@media (max-width: 1024px) {
  .main-content {
    grid-template-columns: 1fr;
    gap: var(--space-xl);
  }
}

/* ===== CARD ===== */
.card {
  background: linear-gradient(145deg, var(--surface), rgba(30, 41, 59, 0.8));
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: var(--shadow-xl);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  height: fit-content;
  transition: all 0.3s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.settings-card {
  position: sticky;
  top: var(--space-lg);
  max-height: calc(100vh - 2 * var(--space-lg));
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-blue) transparent;
}

.settings-card::-webkit-scrollbar {
  width: 6px;
}

.settings-card::-webkit-scrollbar-track {
  background: transparent;
}

.settings-card::-webkit-scrollbar-thumb {
  background: var(--accent-blue);
  border-radius: 3px;
}

.preview-card {
  min-height: 650px;
  display: flex;
  flex-direction: column;
}

.card-header h2 {
  color: var(--text-light);
  margin-bottom: var(--space-xl);
  font-size: 1.4rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding-bottom: var(--space-md);
  border-bottom: 2px solid rgba(59, 130, 246, 0.2);
}

/* ===== SEZIONI ===== */
.section {
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
}

.section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
}

.section-title {
  color: var(--accent-blue);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 0.85rem;
}

/* ===== FORM CONTROLS ===== */
.label {
  display: block;
  margin-bottom: var(--space-sm);
  font-weight: 500;
  color: var(--text-light);
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.label input[type="checkbox"] {
  width: auto;
  margin: 0;
}

textarea, select, input[type="text"], input[type="color"] {
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  background: rgba(13, 13, 13, 0.8);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  color: var(--text-light);
  font-size: 1rem;
  transition: all 0.3s ease;
  font-family: var(--font-body);
  backdrop-filter: blur(5px);
}

textarea {
  resize: vertical;
  min-height: 90px;
  line-height: 1.5;
}

textarea:focus, select:focus, input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
  background: rgba(13, 13, 13, 0.95);
}

/* Range Sliders */
input[type="range"] {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, rgba(59, 130, 246, 0.3), rgba(139, 92, 246, 0.3));
  outline: none;
  margin: var(--space-md) 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
  transition: all 0.2s ease;
  border: 2px solid white;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
}

/* Density Labels */
.density-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-gray);
  margin-top: var(--space-sm);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== CONTROLS GRID ===== */
.controls-grid {
  display: grid;
  gap: var(--space-lg);
  grid-template-columns: 1fr 1fr;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

/* Logo Controls */
.logo-controls {
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* ===== TEMPLATE BUTTONS ===== */
.templates-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
}

.template-btn {
  background: rgba(13, 13, 13, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  color: var(--text-light);
  font-size: 0.9rem;
  font-weight: 500;
  backdrop-filter: blur(5px);
}

.template-btn:hover, .template-btn.active {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15), 0 8px 25px rgba(59, 130, 246, 0.2);
  transform: translateY(-3px);
  background: rgba(59, 130, 246, 0.1);
}

.template-preview {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  margin: 0 auto var(--space-sm);
  box-shadow: var(--shadow-md);
}

.classic-preview {
  background: repeating-conic-gradient(#000 0% 25%, #fff 0% 50%) 50% / 8px 8px;
}

.rounded-preview {
  background: radial-gradient(circle at 25% 25%, #3b82f6 2px, transparent 2px),
              radial-gradient(circle at 75% 25%, #3b82f6 2px, transparent 2px),
              radial-gradient(circle at 25% 75%, #3b82f6 2px, transparent 2px),
              radial-gradient(circle at 75% 75%, #3b82f6 2px, transparent 2px);
  background-size: 8px 8px;
  background-color: #f1f5f9;
}

.dots-preview {
  background: radial-gradient(circle, #8b5cf6 30%, transparent 30%);
  background-size: 6px 6px;
  background-color: #faf5ff;
}

.professional-preview {
  background: linear-gradient(45deg, #f59e0b 25%, transparent 25%),
              linear-gradient(-45deg, #f59e0b 25%, transparent 25%),
              linear-gradient(45deg, transparent 75%, #f59e0b 75%),
              linear-gradient(-45deg, transparent 75%, #f59e0b 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0px;
  background-color: #1f2937;
}

/* ===== BUTTONS ===== */
.btn-primary, .btn-secondary {
  padding: var(--space-md) var(--space-lg);
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1rem;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  font-family: var(--font-body);
  min-height: 48px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background: var(--surface-light);
  color: var(--text-light);
  border: 1px solid var(--surface-light);
}

.btn-secondary:hover {
  background: var(--primary-gray);
  border-color: var(--accent-blue);
}

.button-group {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.action-buttons {
  display: flex;
  justify-content: center;
}

/* ===== QR PREVIEW ===== */
.qr-preview {
  text-align: center;
  margin-bottom: var(--space-lg);
  padding: var(--space-xxl);
  background: rgba(13, 13, 13, 0.4);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(5px);
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

#qr-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 350px;
  width: 100%;
}

#qr-container canvas,
#qr-container svg {
  max-width: 100%;
  max-height: 400px;
  height: auto;
  border-radius: var(--radius-md);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

/* ===== LOGO PREVIEW ===== */
.logo-preview-container {
  margin-top: var(--space-sm);
  padding: var(--space-md);
  background: rgba(13, 13, 13, 0.6);
  border-radius: var(--radius-md);
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(5px);
}

.no-logo-text {
  color: var(--text-gray);
  font-size: 0.85rem;
  font-style: italic;
}

.logo-preview-container img {
  max-width: 90px;
  max-height: 70px;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.remove-logo-btn {
  margin-left: 10px;
  padding: 5px 10px;
  font-size: 0.8rem;
  min-height: auto;
}

/* ===== SCAN STATUS ===== */
.scan-status {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-lg);
  font-weight: 500;
  backdrop-filter: blur(10px);
}

.scan-status.success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.scan-status.error {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.scan-status.warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-orange);
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.status-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

/* ===== FOOTER ===== */
.footer {
  margin-top: auto;
  padding-top: var(--space-lg);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
  color: var(--text-gray);
  font-size: 0.85rem;
  font-weight: 400;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .container {
    padding: var(--space-lg);
  }
  
  .card {
    padding: var(--space-xl);
  }
  
  .settings-card {
    position: static;
    max-height: none;
  }
  
  .button-group {
    flex-direction: column;
  }
  
  .templates-grid {
    grid-template-columns: 1fr 1fr;
  }
  
  .controls-grid {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }
  
  .qr-preview {
    padding: var(--space-lg);
  }
}

@media (max-width: 640px) {
  .container {
    padding: var(--space-md);
  }
  
  .card {
    padding: var(--space-lg);
  }
  
  .templates-grid {
    grid-template-columns: 1fr;
    gap: var(--space-sm);
  }
  
  .template-btn {
    padding: var(--space-md);
  }
  
  .template-preview {
    width: 40px;
    height: 40px;
  }
}

/* ===== ACCESSIBILITÀ ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

button:focus, input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

/* ===== ANIMAZIONI ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  animation: fadeIn 0.5s ease-out;
}