/**
 * Schweißnahttool - Form Extensions
 * Additional form components and wrappers for HTML structure compatibility
 * 
 * Contains:
 * - Input wrapper components
 * - Custom checkbox styling
 * - Form section headers
 * - Loading states and spinners
 */

/* ==============================================
   LEGACY FORM STRUCTURE SUPPORT
   ============================================== */

/* Main layout containers - keeping original structure */
.main-header {
    background: var(--primary);
    color: white;
    padding: 1rem 0;
    box-shadow: var(--shadow-md);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-title h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.subtitle {
    font-size: 0.9rem;
    opacity: 0.9;
    margin: 0.25rem 0 0 0;
}

.header-controls {
    display: flex;
    gap: 1rem;
}

.header-btn {
    padding: 0.6rem 1.2rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-md);
    color: white;
    cursor: pointer;
    transition: var(--transition-normal);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.header-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

/* Main content layout */
.main-content {
    min-height: calc(100vh - 120px);
    padding: 2rem 0;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Input sections */
.input-section {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border);
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
}

.section-controls {
    display: flex;
    gap: 1rem;
}

.example-buttons {
    display: flex;
    gap: 0.5rem;
}

/* Form structure */
.calculation-form {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.form-group-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.form-group-section h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
    margin: 0 0 1.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

/* Input wrappers and extensions */
.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper input {
    flex: 1;
    padding-right: 4rem; /* Make space for unit and status */
}

.input-unit {
    position: absolute;
    right: 3rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    pointer-events: none;
}

.input-status {
    position: absolute;
    right: 0.75rem;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.input-status::after {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    transition: var(--transition-normal);
}

.form-input:valid + .input-unit + .input-status::after {
    background: var(--success);
}

.form-input:invalid + .input-unit + .input-status::after {
    background: var(--error);
}

.required {
    color: var(--error);
    margin-left: 0.25rem;
}

/* Custom checkbox styling */
.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-normal);
    margin-bottom: 0.75rem;
}

.checkbox-item:hover {
    background: var(--surface-3);
}

.checkbox-item:last-child {
    margin-bottom: 0;
}

.checkbox-custom {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    position: relative;
    transition: var(--transition-normal);
}

.checkbox-item input[type="checkbox"] {
    opacity: 0;
    position: absolute;
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.checkbox-item input[type="checkbox"]:checked + label .checkbox-custom {
    background: var(--primary);
    border-color: var(--primary);
}

.checkbox-item input[type="checkbox"]:checked + label .checkbox-custom::after {
    content: '✓';
    position: absolute;
    color: white;
    font-size: 0.875rem;
    font-weight: bold;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

/* Form actions */
.form-actions {
    display: flex;
    justify-content: center;
    padding-top: 1rem;
    margin-top: 1rem;
    border-top: 1px solid var(--border);
}

/* Loading spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 0.5rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Results section */
.results-section {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
    animation: fadeIn 0.5s ease-out;
}

/* Footer */
.main-footer {
    background: var(--surface-3);
    border-top: 1px solid var(--border);
    padding: 2rem 0;
    margin-top: 2rem;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    text-align: center;
}

.footer-info p {
    color: var(--text-secondary);
    margin: 0.5rem 0;
    font-size: 0.9rem;
}

/* ==============================================
   ORIGINAL INPUT STRUCTURE STYLES
   ============================================== */

/* Form Labels with Icons */
.form-label {
    display: flex;
    align-items: center;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    gap: 0.5rem;
}

.form-label i {
    color: var(--primary);
    width: 1rem;
    text-align: center;
}

/* Tooltip System */
.tooltip-container {
    position: relative;
    display: inline-block;
    margin-left: auto;
}

.tooltip-container .tooltip {
    position: absolute;
    bottom: 125%;
    right: 0;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    width: 250px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
    z-index: 1000;
    line-height: 1.4;
}

.tooltip-container:hover .tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.tooltip-container .tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 1rem;
    border: 6px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
}

/* Form Inputs */
.form-input {
    width: 100%;
    padding: 0.75rem 4rem 0.75rem 1rem; /* Space for buttons */
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: var(--transition-normal);
    position: relative;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: var(--transition-normal);
    cursor: pointer;
}

.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Form Group Structure */
.form-group {
    margin-bottom: 1.5rem;
    position: relative;
}

.form-group.is-disabled {
    opacity: 0.55;
    filter: grayscale(20%);
}
.form-input.disabled,
.form-group.is-disabled .form-input {
    background: var(--surface-2);
    border-color: rgba(148,163,184,0.5);
    color: var(--text-secondary);
    cursor: not-allowed;
}

/* Compact range slider row under inputs */
.range-row {
    margin-top: 0.35rem;
}

.micro-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(148,163,184,0.45), rgba(148,163,184,0.25));
    outline: none;
}
.micro-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary, #2563eb);
    border: 2px solid white;
    box-shadow: 0 1px 4px rgba(0,0,0,0.25);
    cursor: pointer;
    transition: transform .12s ease;
}
.micro-range::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary, #2563eb);
    border: 2px solid white;
    box-shadow: 0 1px 4px rgba(0,0,0,0.25);
    cursor: pointer;
    transition: transform .12s ease;
}
.micro-range:active::-webkit-slider-thumb,
.micro-range:active::-moz-range-thumb {
    transform: scale(1.08);
}

/* Validation Messages */
.validation-message {
    font-size: 0.8rem;
    color: var(--error);
    margin-top: 0.25rem;
    min-height: 1.2rem;
}

.input-suggestions {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-top: 0.25rem;
    padding: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
    box-shadow: var(--shadow-md);
}

/* Custom Checkbox Styling from Original */
.custom-checkbox {
    position: relative;
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-right: 0.75rem;
    cursor: pointer;
}

.custom-checkbox input[type="checkbox"] {
    opacity: 0;
    position: absolute;
    width: 100%;
    height: 100%;
    cursor: pointer;
    margin: 0;
}

.checkmark {
    position: absolute;
    top: 0;
    left: 0;
    width: 20px;
    height: 20px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 4px;
    transition: var(--transition-normal);
}

.custom-checkbox input[type="checkbox"]:checked + .checkmark {
    background: var(--primary);
    border-color: var(--primary);
}

.checkmark::after {
    content: '';
    position: absolute;
    display: none;
    left: 6px;
    top: 2px;
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.custom-checkbox input[type="checkbox"]:checked + .checkmark::after {
    display: block;
}

/* Button Styling */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-normal);
    text-decoration: none;
    justify-content: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--success), #059669);
    color: white;
    box-shadow: var(--shadow-md);
}

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

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

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

/* Removed calculate button styles */

.loading {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 0.5rem;
}

/* Removed examples section styles */

/* ==============================================
   ADVANCED INPUT FEATURES
   ============================================== */

/* Smart Input Indicators */
.input-status {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  transition: var(--transition-normal);
}

.input-status.valid {
  background: var(--success);
  color: white;
}

.input-status.invalid {
  background: var(--error);
  color: white;
}

.input-status.warning {
  background: var(--warning);
  color: white;
}

/* Sichtbarkeits- und Pulse-Animation für Statusindikator */
.input-status.show {
    opacity: 1;
    transform: translateY(-50%) scale(1);
}

.input-status.valid,
.input-status.invalid,
.input-status.warning {
    animation: statusPulse 0.5s ease-out;
}

@keyframes statusPulse {
    0% { transform: translateY(-50%) scale(0.8); }
    50% { transform: translateY(-50%) scale(1.2); }
    100% { transform: translateY(-50%) scale(1); }
}

/* Target 95% Optimization Buttons - Professioneller Glow-Effekt */
.target-button {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.95), rgba(99, 102, 241, 0.92));
  color: white;
  border: 1px solid rgba(59, 130, 246, 0.4);
  border-radius: 8px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .35s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 
    0 2px 8px rgba(59, 130, 246, 0.2), 
    0 1px 2px rgba(59, 130, 246, 0.3),
    0 0 0 0 rgba(59, 130, 246, 0.4),
    inset 0 1px 0 rgba(255,255,255,0.2);
  -webkit-backdrop-filter: saturate(1.2) blur(6px);
  backdrop-filter: saturate(1.2) blur(6px);
  z-index: 5;
  overflow: hidden;
  animation: none;
  will-change: box-shadow, border-color;
}

.target-button::before {
  /* Font Awesome bullseye icon */
  content: '\f140';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  font-size: 1rem;
  line-height: 1;
  z-index: 2;
  position: relative;
}

/* Ripple effect */
.target-button::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
  z-index: 1;
}

.target-button:hover {
  background: linear-gradient(135deg, rgba(251, 146, 60, 0.98), rgba(245, 158, 11, 0.96));
  color: white;
  border-color: rgba(251, 146, 60, 0.6);
  box-shadow: 
    0 4px 20px rgba(251, 146, 60, 0.45), 
    0 2px 8px rgba(251, 146, 60, 0.5),
    0 0 0 3px rgba(251, 146, 60, 0.2),
    0 0 20px rgba(251, 146, 60, 0.3),
    inset 0 1px 0 rgba(255,255,255,0.25);
  transform: translateY(-50%) scale(1.08);
  animation: none; /* Stop default animation on hover */
}

.target-button:active {
  transform: translateY(-50%) scale(0.95);
  transition: all .1s ease;
}

.target-button:active::after {
  width: 40px;
  height: 40px;
  transition: width .2s, height .2s;
}

.target-button:focus-visible {
  outline: none;
  box-shadow: 
    0 0 0 3px rgba(59, 130, 246, 0.3), 
    0 4px 16px rgba(59, 130, 246, 0.35), 
    0 2px 4px rgba(59, 130, 246, 0.4),
    inset 0 1px 0 rgba(255,255,255,0.25);
}

/* Optimizing state with enhanced animation */
.target-button.optimizing {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.95), rgba(217, 119, 6, 0.92));
  animation: optimizePulse 1.5s ease-in-out infinite, optimizeGlow 2s ease-in-out infinite alternate;
}

@keyframes optimizePulse {
  0%, 100% { transform: translateY(-50%) scale(1); }
  50% { transform: translateY(-50%) scale(1.1); }
}

@keyframes optimizeGlow {
  0% { 
    box-shadow: 
      0 2px 8px rgba(245, 158, 11, 0.3), 
      0 1px 2px rgba(245, 158, 11, 0.4);
  }
  100% { 
    box-shadow: 
      0 4px 20px rgba(245, 158, 11, 0.5), 
      0 2px 8px rgba(245, 158, 11, 0.6),
      0 0 0 4px rgba(245, 158, 11, 0.1);
  }
}

/* Dezente Aufmerksamkeits-Animation: Subtiler Blau→Orange Fade über Glow */
@keyframes attentionGlow {
  0%, 100% {
    box-shadow:
      0 2px 8px rgba(59, 130, 246, 0.25),
      0 1px 2px rgba(59, 130, 246, 0.35),
      0 0 0 0 rgba(59, 130, 246, 0.00),
      inset 0 1px 0 rgba(255,255,255,0.20);
    border-color: rgba(59, 130, 246, 0.45);
  }

  50% {
    box-shadow:
      0 3px 12px rgba(251, 146, 60, 0.28),
      0 2px 6px rgba(251, 146, 60, 0.32),
      0 0 0 2px rgba(251, 146, 60, 0.12),
      inset 0 1px 0 rgba(255,255,255,0.22);
    border-color: rgba(251, 146, 60, 0.35);
  }
}



.target-button.loading {
  animation: targetBtnSpin 0.8s linear infinite;
}

@keyframes targetBtnSpin {
  to { transform: translateY(-50%) rotate(360deg); }
}

/* Tooltip (nutzt title) */
/* Entfernt: zusätzliches Pseudo-Tooltip für 95%-Buttons (title → ::after) */

/* Preset button for test pressure */
.preset-button {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  height: 30px;
  padding: 0 0.6rem;
  border-radius: 8px;
  border: 1px solid rgba(148,163,184,0.35);
  background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(248,250,252,0.92));
  color: var(--primary, #2563eb);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: box-shadow .2s ease, transform .12s ease, background-color .2s ease, color .2s ease, border-color .2s ease;
  box-shadow: 0 4px 12px rgba(17,24,39,0.08), inset 0 1px 0 rgba(255,255,255,0.6);
  -webkit-backdrop-filter: saturate(1.2) blur(6px);
  backdrop-filter: saturate(1.2) blur(6px);
}

.preset-button:hover {
  background: linear-gradient(180deg, rgba(245,249,255,0.98), rgba(234,241,255,0.96));
  color: var(--primary, #2563eb);
  border-color: rgba(37,99,235,0.45);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.18), 0 0 0 2px rgba(37,99,235,0.12);
}

/* Export Controls */
.export-controls {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.export-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition-normal);
  font-size: 0.875rem;
  font-weight: 500;
}

.export-btn:hover {
  background: var(--surface-3);
  transform: translateY(-1px);
}

.export-btn i {
  font-size: 1rem;
}

/* Comparison Mode */
.comparison-mode {
  background: var(--surface-2);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin: 1rem 0;
  border: 1px solid var(--border);
}

.comparison-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.comparison-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}

.comparison-item {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 1rem;
  border: 1px solid var(--border);
}

.comparison-label {
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.comparison-value {
  font-family: var(--font-family-mono);
  font-size: 1.1rem;
  color: var(--text-secondary);
}

/* ==============================================
   RESPONSIVE EXTENSIONS
   ============================================== */

@media (max-width: 768px) {
    .header-content {
        padding: 0 1rem;
        flex-direction: column;
        gap: 1rem;
    }
    
    .container {
        padding: 0 1rem;
    }
    
    .input-section,
    .results-section {
        padding: 1.5rem;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .form-group-section {
        padding: 1rem;
    }
    
    .target-button {
        width: 28px;
        height: 28px;
    }
    
    .target-button::before {
        font-size: 0.6rem;
    }
    
    .comparison-grid {
        grid-template-columns: 1fr;
    }
    
    .export-controls {
        justify-content: center;
    }
    
    .export-btn {
        padding: 0.6rem 1rem;
        font-size: 0.8rem;
    }
}

/* Additional Mobile Optimizations */
@media (max-width: 480px) {
    .target-button {
        width: 24px;
        height: 24px;
    }
    
    .target-button::before {
        font-size: 0.55rem;
    }
    
    .input-status {
        width: 16px;
        height: 16px;
        font-size: 0.7rem;
        right: 0.5rem;
    }
    
    .comparison-mode {
        padding: 1rem;
    }
    
    .export-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }
}

/* Segmented control for Nachweistyp */
.segmented-control {
    display: inline-flex;
    align-items: stretch;
    border: none; /* remove outer white border */
    border-radius: 10px;
    background: transparent; /* avoid white capsule background */
    overflow: hidden;
}
.segmented-control .seg-btn {
    appearance: none;
    border: none;
    background: transparent;
    color: var(--text-primary);
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}
.segmented-control .seg-btn:hover { background: var(--surface-2); }
.segmented-control .seg-btn.active {
    background: var(--primary);
    color: #fff;
}
.segmented-control .seg-split { width: 1px; background: transparent; }

/* Ensure rounded outer corners are filled by button backgrounds */
.segmented-control .seg-btn:first-child {
    border-top-left-radius: 10px;
    border-bottom-left-radius: 10px;
}
.segmented-control .seg-btn:last-child {
    border-top-right-radius: 10px;
    border-bottom-right-radius: 10px;
}

/* Lock state for Eingabeparameter panel */
.input-panel.locked {
    position: relative;
    pointer-events: none;
    opacity: 0.5;
    filter: grayscale(25%);
}
.input-panel.locked::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.12);
    border-radius: var(--radius-lg, 12px);
}