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

:root {
  --primary: #e60023;
  --primary-dark: #c0001d;
  --primary-light: #ff1a40;
  --bg: #f5f5f5;
  --card-bg: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --border-focus: #e60023;
  --success: #10b981;
  --error: #ef4444;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Header */
.site-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  padding: 2rem 0;
  text-align: center;
}

.site-header h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.site-header .tagline {
  font-size: 1rem;
  opacity: 0.9;
}

/* Ad Slots */
.ad-banner {
  display: flex;
  justify-content: center;
  margin: 1.5rem 0;
  min-height: 90px;
}

.ad-inline {
  display: flex;
  justify-content: center;
  margin: 1.5rem 0;
}

.ad-sidebar {
  display: flex;
  justify-content: center;
  margin: 1.5rem 0;
}

/* Main Layout */
.main-layout {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 1.5rem;
  padding: 1.5rem 1rem;
  align-items: start;
}

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--primary);
}

/* Toggle Group */
.toggle-group {
  display: flex;
  gap: 0;
  margin-bottom: 1.5rem;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid var(--primary);
}

.toggle-btn {
  flex: 1;
  padding: 0.75rem 1.5rem;
  border: none;
  background: var(--card-bg);
  color: var(--primary);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.toggle-btn.active {
  background: var(--primary);
  color: #fff;
}

.toggle-btn:hover:not(.active) {
  background: var(--primary-light);
  color: #fff;
}

/* Form */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.375rem;
  font-size: 0.875rem;
}

.form-group .required {
  color: var(--error);
}

.form-group small {
  display: block;
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 0.25rem;
}

.form-group input[type="text"],
.form-group input[type="tel"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--card-bg);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(230, 0, 35, 0.1);
}

.form-group input.invalid {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-group input.valid {
  border-color: var(--success);
}

.form-group input[readonly] {
  background: var(--bg);
  cursor: not-allowed;
}

.hidden {
  display: none !important;
}

/* Color Input */
.color-input-group {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.color-input-group input[type="color"] {
  width: 48px;
  height: 40px;
  padding: 2px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  background: none;
}

.color-hex {
  flex: 1;
  font-family: monospace;
  text-transform: uppercase;
}

/* Range Input */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  transition: transform 0.15s ease;
}

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

input[type="range"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* File Input */
input[type="file"] {
  width: 100%;
  padding: 0.5rem;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  cursor: pointer;
}

input[type="file"]:hover {
  border-color: var(--primary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: var(--shadow-lg);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1.5px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}

.btn-outline:hover {
  background: var(--primary);
  color: #fff;
}

.btn-small {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

.btn-full {
  width: 100%;
  margin-top: 0.5rem;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* QR Output */
.qr-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 250px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  margin-bottom: 1rem;
  overflow: auto;
  max-width: 100%;
}

.qr-placeholder canvas {
  max-width: 100%;
  max-height: 60vh;
  display: block;
  margin: auto;
}

.qr-placeholder p {
  color: var(--text-muted);
  font-size: 0.9375rem;
}

.qr-placeholder canvas {
  border-radius: 4px;
}

.qr-actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.qr-actions .btn {
  flex: 1;
  font-size: 0.875rem;
  padding: 0.625rem 1rem;
}

.qr-data-preview {
  margin-top: 1rem;
}

.qr-data-preview h3 {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.qr-data-preview textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: monospace;
  font-size: 0.75rem;
  resize: none;
  background: var(--bg);
  color: var(--text);
  margin-bottom: 0.5rem;
}

/* Footer */
.site-footer {
  background: var(--text);
  color: #fff;
  padding: 1.5rem 0;
  text-align: center;
  margin-top: 2rem;
}

.site-footer p {
  font-size: 0.8125rem;
  opacity: 0.8;
  margin-bottom: 0.25rem;
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 1000;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.success {
  background: var(--success);
}

.toast.error {
  background: var(--error);
}

/* Responsive */
@media (max-width: 900px) {
  .main-layout {
    grid-template-columns: 1fr;
  }

  .result-section {
    order: -1;
  }

  .ad-sidebar {
    display: none;
  }
}

@media (max-width: 480px) {
  .site-header h1 {
    font-size: 1.5rem;
  }

  .card {
    padding: 1rem;
  }

  .toggle-btn {
    padding: 0.625rem 1rem;
    font-size: 0.9375rem;
  }

  .qr-actions {
    flex-direction: column;
  }
}
