/**
 * Widget Styles - Komplett-Redesign
 * 
 * Transparentes Design mit Floating Labels
 * Mobile First, kompakte Felder
 */

/* =============================================================================
   CSS Variables (vom Server injiziert)
   ============================================================================= */

:root {
  --primary: #1976d2;
  --secondary: #4A5568;
  --text: #1A202C;
  --text-muted: #718096;
  --background: transparent;
  --card-bg: rgba(255, 255, 255, 0.95);
  --border: #E2E8F0;
  --error: #E53E3E;
  --success: #38A169;
  --radius: 12px;
}

/* =============================================================================
   Base & Reset
   ============================================================================= */

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

body,
.widget-root,
.widget-container {
  background: transparent !important;
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
}

.widget-root {
  position: relative;
}

.tenant-badge {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 10px;
  color: #999;
  opacity: 0.6;
  z-index: 10;
  pointer-events: none;
}

.widget-container {
  max-width: 100%;
  padding: 1rem;
}

/* =============================================================================
   Header
   ============================================================================= */

.widget-header {
  margin-bottom: 1.5rem;
}

.tenant-name {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
}

.widget-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

/* =============================================================================
   Card / Container
   ============================================================================= */

.widget-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.widget-card-centered {
  text-align: center;
  padding: 2rem 1.5rem;
}

/* =============================================================================
   Sections (State Management)
   ============================================================================= */

.section {
  display: block;
}

.section.hidden {
  display: none;
}

/* =============================================================================
   Form Grid (Mobile First)
   ============================================================================= */

.widget-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.widget-form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

/* Desktop: 2 Spalten */
@media (min-width: 480px) {
  .widget-form-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .field-full {
    grid-column: 1 / -1;
  }
  
  /* PLZ + Stadt: 40/60 Split */
  .field-plz {
    grid-column: 1;
  }
  
  .field-city {
    grid-column: 2;
  }
}

/* PLZ + Stadt: 40/60 Split bei größeren Bildschirmen */
@media (min-width: 600px) {
  .widget-form-grid {
    grid-template-columns: repeat(5, 1fr);
  }
  
  .field-plz {
    grid-column: span 2; /* 40% */
  }
  
  .field-city {
    grid-column: span 3; /* 60% */
  }
  
  .field-full {
    grid-column: 1 / -1;
  }
}

/* =============================================================================
   Floating Label Fields
   ============================================================================= */

.field {
  position: relative;
}

.field input,
.field textarea {
  width: 100%;
  padding: 20px 14px 6px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  height: 54px;
  box-sizing: border-box;
}

.field textarea {
  resize: vertical;
  min-height: 100px;
  padding-top: 12px;
}

.field input:focus,
.field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
}

.field label {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--text-muted);
  pointer-events: none;
  transition: all 0.2s ease;
  background: var(--card-bg);
  padding: 0 4px;
}

.field textarea + label {
  top: 12px;
  transform: none;
}

.field input:focus + label,
.field input:not(:placeholder-shown) + label,
.field textarea:focus + label,
.field textarea:not(:placeholder-shown) + label {
  top: 0;
  font-size: 11px;
  color: var(--primary);
  transform: translateY(-50%);
}

.field textarea:focus + label,
.field textarea:not(:placeholder-shown) + label {
  top: -6px;
  transform: none;
}

/* Required Field Indicator */
.field input[required] + label::after,
.field textarea[required] + label::after {
  content: ' *';
  color: var(--error);
}

/* =============================================================================
   Error Messages
   ============================================================================= */

.error-message {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--error);
  min-height: 16px;
}

.error-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: rgba(229, 62, 62, 0.1);
  border: 1px solid var(--error);
  border-radius: var(--radius);
  color: var(--error);
  font-size: 14px;
}

.error-icon {
  font-size: 1.2rem;
}

/* =============================================================================
   Buttons
   ============================================================================= */

.widget-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
  min-height: 44px;
}

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

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

.widget-btn-primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--primary) 90%, black);
}

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

.widget-btn-secondary {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.widget-btn-secondary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--primary) 10%, transparent);
}

.widget-actions {
  margin-top: 1rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

@media (max-width: 480px) {
  .widget-actions {
    flex-direction: column;
  }
  
  .widget-btn {
    width: 100%;
  }
}

/* =============================================================================
   Loading Spinner & Progress Bar
   ============================================================================= */

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Progress Bar (Wartebalken) */
.loading-progress {
  width: 100%;
  max-width: 300px;
  margin: 0 auto 1.5rem;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  animation: progress-animation 2s ease-in-out infinite;
  transform-origin: left;
}

@keyframes progress-animation {
  0% {
    transform: scaleX(0);
    transform-origin: left;
  }
  50% {
    transform: scaleX(0.7);
    transform-origin: left;
  }
  100% {
    transform: scaleX(1);
    transform-origin: left;
  }
}

.loading-text {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text);
  min-height: 1.5rem;
}

.loading-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0;
}

/* Input Preview Toggle */
.input-preview-toggle {
  display: flex;
  justify-content: center;
}

.input-preview-toggle label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

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

.input-preview {
  animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =============================================================================
   Questions (Step 2)
   ============================================================================= */

.questions-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1rem;
}

.question-item {
  padding: 1rem;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.question-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.question-type-hint {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  background: rgba(113, 128, 150, 0.1);
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.question-input {
  width: 100%;
  padding: 12px 14px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.question-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.1);
}

/* Boolean (Ja/Nein) Radio Buttons */
.question-boolean {
  display: flex;
  gap: 1.5rem;
  margin-top: 0.5rem;
}

.question-boolean label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
}

.question-boolean input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* =============================================================================
   Offer Display (Step 3)
   ============================================================================= */

.offer-container {
  margin: 1.5rem 0;
}

.offer-text {
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  max-height: 400px;
  overflow-y: auto;
  color: var(--text);
}

.offer-total {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 2px solid var(--border);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--primary);
}

.offer-notes {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.offer-notes-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
}

.offer-notes-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.offer-notes-list li {
  padding: 0.5rem 0;
  font-size: 14px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.offer-notes-list li:last-child {
  border-bottom: none;
}

/* =============================================================================
   Disclaimer
   ============================================================================= */

.disclaimer {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1rem;
  margin-bottom: 0;
}

/* =============================================================================
   Responsive
   ============================================================================= */

@media (max-width: 480px) {
  .widget-container {
    padding: 0.75rem;
  }
  
  .widget-card {
    padding: 1rem;
    border-radius: calc(var(--radius) * 0.75);
  }
  
  .widget-header h1 {
    font-size: 1.25rem;
  }
  
  .widget-form-grid {
    grid-template-columns: 1fr;
  }
  
  .field-plz,
  .field-city {
    grid-column: 1;
  }
}

/* PLZ und Stadt auf einer Zeile, eng zusammen */
.field-plz {
  flex: 0 0 90px;
  max-width: 90px;
}

.field-city {
  flex: 1 1 200px;
  min-width: 150px;
}

/* Grid Gap für die PLZ/Stadt Zeile reduzieren - optional */
@media (min-width: 480px) {
  .field-plz + .field-city {
    margin-left: -0.5rem;
  }
}

/* Hint Text in Labels */
.field-hint {
  font-weight: 400;
  font-size: 0.7rem;
  color: var(--text-muted);
  opacity: 0.7;
}

