/*!
 * Enhanced Form Styles for Telefonansagen.de
 * Optimized and cleaned up version
 * Version: 2.0
 */

/* ===== CSS CUSTOM PROPERTIES ===== */
:root {
  /* Tonwerk (cozy) palette */
  --twk-orange: #f97316;           /* primary */
  --twk-orange-dark: #ea580c;      /* primary dark */
  --twk-orange-soft: #fb923c;      /* accent */
  --twk-border: #f1e4d9;           /* warm border */
  --twk-surface: #fffdf9;          /* warm card */
  --twk-ring: rgba(249, 115, 22, 0.15);
  /* Neutral field look (as in screenshot) */
  --twk-field-bg: #eff4ff;               /* very light blue fill */
  --twk-field-border: #d9e3f8;           /* soft cool border */
  --twk-field-border-hover: #cfdcf7;     /* hover border */
  --twk-field-border-focus: #9ec5ff;     /* focus border */
  --twk-field-ring: rgba(59, 130, 246, 0.25); /* blue focus ring */
  --ta-primary-blue: #3b82f6;
  --ta-primary-blue-dark: #1d4ed8;
  --ta-secondary-blue: #2563eb;
  --ta-border-color: #e5e7eb;
  --ta-border-color-hover: #d1d5db;
  --ta-text-gray: #374151;
  --ta-text-gray-light: #6b7280;
  --ta-text-gray-dark: #1f2937;
  --ta-bg-gray-light: #f9fafb;
  --ta-bg-gray: #f3f4f6;
  --ta-success-green: #10b981;
  --ta-error-red: #ef4444;
  --ta-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --ta-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --ta-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --ta-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --ta-border-radius: 0.5rem;
  --ta-border-radius-lg: 0.75rem;
}

/* ===== LANGUAGE TILES STYLING ===== */
.language-tiles-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

.checkbox-tile {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80px;
  padding: 1rem;
  border: 2px solid var(--ta-border-color);
  border-radius: var(--ta-border-radius-lg);
  background: white;
  cursor: pointer;
  transition: var(--ta-transition);
  text-align: center;
  font-weight: 500;
  color: var(--ta-text-gray);
  box-shadow: var(--ta-shadow-sm);
  flex-direction: column;
  gap: 0.5rem;
}

.checkbox-tile:hover {
  border-color: var(--ta-primary-blue);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
  transform: translateY(-2px);
}

.checkbox-tile .tile-icon {
  font-size: 1.5rem;
  line-height: 1;
  opacity: 0.8;
}

/* Language tiles with icons */
.language-tile.checkbox-tile {
  min-height: 100px;
}

.language-tile .tile-icon {
  font-size: 1.75rem;
  line-height: 1;
}

/* Selected state styling */
.tile-styled-checkbox:checked + .checkbox-tile,
.checkbox-tile:has(.tile-styled-checkbox:checked) {
  border-color: var(--ta-primary-blue);
  background: linear-gradient(135deg, var(--ta-primary-blue) 0%, var(--ta-primary-blue-dark) 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
  transform: translateY(-2px);
}

/* Checkmark for selected tiles */
.tile-styled-checkbox:checked + .checkbox-tile::after,
.checkbox-tile:has(.tile-styled-checkbox:checked)::after {
  content: '✓';
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: bold;
}

.tile-styled-checkbox:checked + .checkbox-tile .tile-icon,
.checkbox-tile:has(.tile-styled-checkbox:checked) .tile-icon {
  opacity: 1;
}

/* Fallback for browsers without :has() support */
.checkbox-tile.checked {
  border-color: var(--ta-primary-blue);
  background: linear-gradient(135deg, var(--ta-primary-blue) 0%, var(--ta-primary-blue-dark) 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
  transform: translateY(-2px);
}

.checkbox-tile.checked::after {
  content: '✓';
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: bold;
}

.checkbox-tile.checked .tile-icon {
  opacity: 1;
}

/* ===== MODERN INPUT FIELDS ===== */
.modern-input-group {
  position: relative;
  margin-bottom: 1.5rem;
}

.modern-input,
.modern-textarea,
.modern-select {
  width: 100%;
  padding: 1rem 0.75rem 0.5rem;
  border: 2px solid var(--ta-border-color);
  border-radius: var(--ta-border-radius);
  background: white;
  font-size: 1rem;
  font-weight: 500;
  color: var(--ta-text-gray);
  transition: var(--ta-transition);
  outline: none;
  font-family: inherit;
}

.modern-input:focus,
.modern-textarea:focus,
.modern-select:focus {
  border-color: var(--ta-primary-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.modern-label {
  position: absolute;
  left: 0.75rem;
  top: 1rem;
  color: var(--ta-text-gray-light);
  font-size: 1rem;
  font-weight: 500;
  transition: var(--ta-transition);
  pointer-events: none;
  transform-origin: left top;
  background: white;
  padding: 0 0.25rem;
}

.modern-input:focus + .modern-label,
.modern-input:not(:placeholder-shown) + .modern-label,
.modern-textarea:focus + .modern-label,
.modern-textarea:not(:placeholder-shown) + .modern-label,
.modern-select:focus + .modern-label,
.modern-select:not([value=""]) + .modern-label {
  transform: translateY(-1.5rem) scale(0.85);
  color: var(--ta-primary-blue);
}

.modern-textarea {
  min-height: 120px;
  resize: vertical;
}

/* ===== TONWERK MODERN FIELDS (Reusable) ===== */
/* Base field styles (apply to text inputs, selects, textareas) */
.tonwerk-input,
.tonwerk-form input:not([type="checkbox"]):not([type="radio"]),
.tonwerk-form textarea,
.tonwerk-form select {
  width: 100%;
  height: 48px;
  padding: 0 0.95rem;
  border: 1.25px solid var(--twk-field-border);
  border-radius: 12px;
  background: var(--twk-field-bg);
  color: var(--ta-text-gray-dark);
  font-size: 0.95rem;
  line-height: 1.25rem;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,.015);
}

/* Taller for textareas */
.tonwerk-input[type="textarea"],
.tonwerk-form textarea {
  min-height: 120px;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  line-height: 1.45;
}

/* Hover + focus rings */
.tonwerk-input:hover,
.tonwerk-form input:hover:not([type="checkbox"]):not([type="radio"]),
.tonwerk-form textarea:hover,
.tonwerk-form select:hover {
  border-color: var(--twk-field-border-hover);
}

.tonwerk-input:focus,
.tonwerk-form input:focus:not([type="checkbox"]):not([type="radio"]),
.tonwerk-form textarea:focus,
.tonwerk-form select:focus {
  border-color: var(--twk-field-border-focus);
  box-shadow: 0 0 0 3px var(--twk-field-ring);
  background: #ffffff;
}

.tonwerk-input::placeholder,
.tonwerk-form input::placeholder,
.tonwerk-form textarea::placeholder {
  color: #9ca3af;
  font-weight: 600;
  opacity: 1;
}

/* Native select polish */
.tonwerk-select,
.tonwerk-form select {
  appearance: none;
  background-color: var(--twk-field-bg);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='none'%3e%3cpath d='M6 8l4 4 4-4' stroke='%239ca3af' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px 16px;
  padding-right: 2.25rem; /* space for arrow */
}

/* Disabled state */
.tonwerk-input:disabled,
.tonwerk-form input:disabled,
.tonwerk-form textarea:disabled,
.tonwerk-form select:disabled {
  background: #f5f7ff;
  color: #9aa0a6;
  cursor: not-allowed;
  opacity: .85;
}

/* Error helper class (can be added by validators) */
.tonwerk-error,
.tonwerk-form .has-errors .tonwerk-input,
.tonwerk-form .has-errors select,
.tonwerk-form .has-errors textarea {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239,68,68,.15) !important;
}

/* Cozy variant surface alignment */
/* Cozy pages keep the same neutral field visuals */
.cozy-warm .tonwerk-input,
.cozy-warm .tonwerk-form input:not([type="checkbox"]):not([type="radio"]),
.cozy-warm .tonwerk-form textarea,
.cozy-warm .tonwerk-form select {
  background: var(--twk-field-bg);
  border-color: var(--twk-field-border);
}

/* When used with older simple classes, map them to Tonwerk visuals */
.tonwerk-form .simple-input { all: unset; }
.tonwerk-form .simple-input { display: block; }
.tonwerk-form .simple-input { /* reapply tonwerk-input */
  width: 100%;
  height: 48px;
  padding: 0 0.95rem;
  border: 1.25px solid var(--twk-field-border);
  border-radius: 12px;
  background: var(--twk-field-bg);
  color: var(--ta-text-gray-dark);
  font-size: 0.95rem;
  line-height: 1.25rem;
  box-shadow: 0 1px 2px rgba(0,0,0,.015);
  transition: border-color .18s ease, box-shadow .18s ease;
}

.tonwerk-form .simple-input:focus {
  outline: none;
  border-color: var(--twk-field-border-focus);
  box-shadow: 0 0 0 3px var(--twk-field-ring);
}

.tonwerk-form .simple-select { appearance: none; }
.tonwerk-form .simple-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='none'%3e%3cpath d='M6 8l4 4 4-4' stroke='%239ca3af' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px 16px;
  padding-right: 2.25rem;
}

/* ===== MERKZETTEL STYLING ===== */
.merkzettel-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  border: 1px solid var(--ta-border-color);
  border-radius: var(--ta-border-radius);
  background: var(--ta-bg-gray-light);
  margin-bottom: 0.5rem;
  transition: var(--ta-transition);
}

.merkzettel-item:hover {
  background: var(--ta-bg-gray);
  border-color: var(--ta-border-color-hover);
}

.merkzettel-item-content {
  display: flex;
  align-items: center;
  flex: 1;
}

.merkzettel-item-icon {
  font-size: 1.125rem;
  margin-right: 0.75rem;
  color: var(--ta-text-gray-light);
}

.merkzettel-item-text {
  flex: 1;
}

.merkzettel-item-name {
  font-weight: 600;
  color: var(--ta-text-gray-dark);
  margin-bottom: 0.125rem;
}

.merkzettel-item-type {
  font-size: 0.875rem;
  color: var(--ta-text-gray-light);
}

/* ===== UNIVERSAL TOGGLE STYLING ===== */
.multipage-contact-form input[type="checkbox"]:not(.no-toggle),
.multipage-contact-form input[type="radio"]:not(.no-toggle) {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 2.7rem;
  height: 1.5rem;
  border-radius: 9999px;
  background: #d1d5db;
  position: relative;
  cursor: pointer;
  outline: none;
  transition: background 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
  margin-right: 0.75rem;
  flex-shrink: 0;
  vertical-align: middle;
  border: none;
}

.multipage-contact-form input[type="checkbox"]:not(.no-toggle)::before,
.multipage-contact-form input[type="radio"]:not(.no-toggle)::before {
  content: "";
  position: absolute;
  top: calc((1.5rem - 1.2rem) / 2);
  left: calc((1.5rem - 1.2rem) / 2);
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 9999px;
  background: white;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease-in-out;
}

.multipage-contact-form input[type="checkbox"]:not(.no-toggle):checked,
.multipage-contact-form input[type="radio"]:not(.no-toggle):checked {
  background: var(--ta-secondary-blue);
}

.multipage-contact-form input[type="checkbox"]:not(.no-toggle):checked::before,
.multipage-contact-form input[type="radio"]:not(.no-toggle):checked::before {
  transform: translateX(calc(2.7rem - 1.2rem - (1.5rem - 1.2rem)));
}

.multipage-contact-form input[type="checkbox"]:not(.no-toggle):focus,
.multipage-contact-form input[type="radio"]:not(.no-toggle):focus {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.35);
}

/* ===== FORM LAYOUT ===== */
.multipage-contact-form .ff-checkbox-group,
.multipage-contact-form .ff-radio-group {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.multipage-contact-form label:has(input[type="checkbox"]:not(.no-toggle)),
.multipage-contact-form label:has(input[type="radio"]:not(.no-toggle)),
.multipage-contact-form .ff-option:has(input[type="checkbox"]:not(.no-toggle)),
.multipage-contact-form .ff-option:has(input[type="radio"]:not(.no-toggle)),
.multipage-contact-form .checkbox:has(input[type="checkbox"]:not(.no-toggle)),
.multipage-contact-form .radio:has(input[type="radio"]:not(.no-toggle)) {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  line-height: 1.35;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--ta-text-gray-dark);
}

/* ===== ANIMATIONS ===== */
@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translate3d(0, 100%, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translate3d(100%, 0, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.animate-slide-up {
  animation: slideInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.animate-fade-in {
  animation: fadeIn 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.animate-slide-right {
  animation: slideInRight 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.animate-scale-in {
  animation: scaleIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== FORM PROGRESS INDICATOR ===== */
.form-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--ta-border-color);
  z-index: 1000;
}

.form-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--ta-primary-blue), var(--ta-primary-blue-dark));
  width: 0%;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== PAGE TRANSITION ===== */
.page-transition {
  opacity: 0;
  transform: translateY(20px);
  transition: var(--ta-transition);
}

.page-transition.active {
  opacity: 1;
  transform: translateY(0);
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
  .language-tiles-container {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
  }
  
  .checkbox-tile {
    min-height: 70px;
    padding: 0.75rem 0.5rem;
    font-size: 0.875rem;
  }
  
  .language-tile.checkbox-tile {
    min-height: 80px;
  }
  
  .tile-icon {
    font-size: 1.25rem !important;
  }
  
  .modern-input,
  .modern-textarea,
  .modern-select {
    padding: 0.875rem 0.625rem 0.375rem;
  }
  
  .modern-label {
    left: 0.625rem;
    top: 0.875rem;
  }
}

@media (max-width: 480px) {
  .language-tiles-container {
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 0.5rem;
  }
  
  .checkbox-tile {
    min-height: 60px;
    padding: 0.5rem;
    font-size: 0.8rem;
  }
  
  .tile-icon {
    font-size: 1.1rem !important;
  }
}

/* ===== UTILITY CLASSES ===== */
.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===== TOOLTIP STYLING ===== */
.ta-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 9999px;
  background: var(--ta-border-color);
  color: var(--ta-text-gray);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.75rem;
  transition: var(--ta-transition);
}

.ta-tip:hover {
  background: #dbeafe;
  color: var(--ta-primary-blue-dark);
}

.ta-tip::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: 150%;
  transform: translateX(-50%);
  background: var(--ta-text-gray-dark);
  color: white;
  padding: 0.5rem 0.625rem;
  border-radius: var(--ta-border-radius);
  font-size: 0.75rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 1000;
}

.ta-tip::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 135%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--ta-text-gray-dark);
  opacity: 0;
  transition: opacity 0.2s;
}

.ta-tip:hover::after,
.ta-tip:hover::before {
  opacity: 0.95;
}
