/**
 * Gawistik Forms Enhancer - Frontend Styles
 * Multi-step form styling
 */

/* ====================
   STEP INDICATOR STYLES
   ==================== */

.gawistik-step-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 2rem 0;
    padding: 1rem 0;
    position: relative;
}

/* Circles with Lines Style (Default) */
.gawistik-step-indicator--circles {
    align-items: flex-start;
}

.gawistik-step-indicator--circles .gawistik-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    flex: 1;
    max-width: 200px;
    text-align: center;
}

.gawistik-step-indicator--circles .gawistik-step:not(:last-child) {
    margin-right: 2rem;
}

/* Step Circle */
.gawistik-step-circle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: #e5e7eb;
    border: 3px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
    transition: all 0.3s ease;
    cursor: pointer;
}

.gawistik-step-number {
    font-weight: 600;
    font-size: 1.1rem;
    color: #6b7280;
    transition: color 0.3s ease;
}

/* Step Lines */
.gawistik-step-line {
    position: absolute;
    top: 25px;
    height: 3px;
    background-color: #e5e7eb;
    transition: background-color 0.3s ease;
    z-index: 1;
}

.gawistik-step-line--before {
    left: -50%;
    width: 50%;
}

.gawistik-step-line--after {
    right: -50%;
    width: 50%;
}

/* Step Text */
.gawistik-step-title {
    margin-top: 0.75rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: #374151;
    transition: color 0.3s ease;
}

.gawistik-step-description {
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: #6b7280;
    line-height: 1.4;
}

/* ====================
   STEP STATES
   ==================== */

/* Active Step */
.gawistik-step--active .gawistik-step-circle {
    background-color: #3b82f6;
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.gawistik-step--active .gawistik-step-number {
    color: white;
}

.gawistik-step--active .gawistik-step-title {
    color: #3b82f6;
}

/* Completed Step */
.gawistik-step--completed .gawistik-step-circle {
    background-color: #10b981;
    border-color: #10b981;
}

.gawistik-step--completed .gawistik-step-number {
    color: white;
}

.gawistik-step--completed .gawistik-step-title {
    color: #10b981;
}

.gawistik-step--completed .gawistik-step-line--after {
    background-color: #10b981;
}

/* Clickable Step */
.gawistik-step--clickable {
    cursor: pointer;
}

.gawistik-step--clickable:hover .gawistik-step-circle {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ====================
   FORM STEP CONTENT
   ==================== */

/* Hide all form fields by default */
.gawistik-multistep-form .bricks-field {
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* Show active step fields */
.gawistik-multistep-form .gawistik-step-active {
    display: block !important;
    opacity: 1;
}

/* Step animation */
@keyframes gawistikStepFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gawistik-step-active {
    animation: gawistikStepFadeIn 0.3s ease forwards;
}

/* ====================
   NAVIGATION BUTTONS
   ==================== */

.gawistik-step-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e5e7eb;
}

.gawistik-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
    min-width: 120px;
}

.gawistik-btn--previous {
    background-color: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.gawistik-btn--previous:hover {
    background-color: #e5e7eb;
    border-color: #9ca3af;
}

.gawistik-btn--next {
    background-color: #3b82f6;
    color: white;
    margin-left: auto;
}

.gawistik-btn--next:hover {
    background-color: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.gawistik-btn--submit {
    background-color: #10b981;
}

.gawistik-btn--submit:hover {
    background-color: #059669;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* ====================
   VALIDATION STYLES
   ==================== */

.gawistik-field-error {
    position: relative;
}

.gawistik-field-error input,
.gawistik-field-error textarea,
.gawistik-field-error select {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}

.gawistik-field-error-message {
    color: #ef4444;
    font-size: 0.8rem;
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
}

.gawistik-field-error-message:before {
    content: "⚠";
    margin-right: 0.25rem;
}

.gawistik-step-error {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    color: #dc2626;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
}

.gawistik-step-error:before {
    content: "⚠";
    margin-right: 0.5rem;
    font-size: 1.1rem;
}

/* ====================
   ALTERNATIVE STYLES
   ==================== */

/* Tab Style */
.gawistik-step-indicator--tabs {
    background-color: #f8fafc;
    border-radius: 0.5rem;
    padding: 0.5rem;
    border: 1px solid #e2e8f0;
}

.gawistik-step-indicator--tabs .gawistik-step {
    flex: 1;
    padding: 0.75rem 1rem;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.gawistik-step-indicator--tabs .gawistik-step--active {
    background-color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Progress Bar Style */
.gawistik-step-indicator--progress {
    flex-direction: column;
}

.gawistik-progress-bar {
    width: 100%;
    height: 8px;
    background-color: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.gawistik-progress-fill {
    height: 100%;
    background-color: #3b82f6;
    transition: width 0.3s ease;
    border-radius: 4px;
}

.gawistik-progress-text {
    text-align: center;
    font-size: 0.9rem;
    color: #6b7280;
}

/* ====================
   RESPONSIVE DESIGN
   ==================== */

@media (max-width: 768px) {
    .gawistik-step-indicator--circles {
        flex-direction: column;
        align-items: stretch;
    }
    
    .gawistik-step-indicator--circles .gawistik-step {
        max-width: none;
        margin-right: 0;
        margin-bottom: 1.5rem;
        flex-direction: row;
        text-align: left;
    }
    
    .gawistik-step-indicator--circles .gawistik-step:not(:last-child) {
        margin-right: 0;
    }
    
    .gawistik-step-circle {
        width: 40px;
        height: 40px;
        margin-right: 1rem;
        flex-shrink: 0;
    }
    
    .gawistik-step-number {
        font-size: 1rem;
    }
    
    .gawistik-step-title {
        margin-top: 0;
        margin-bottom: 0.25rem;
    }
    
    .gawistik-step-line {
        display: none;
    }
    
    .gawistik-step-navigation {
        flex-direction: column;
        gap: 1rem;
    }
    
    .gawistik-btn {
        width: 100%;
        margin-left: 0 !important;
    }
}

/* ====================
   INTEGRATION WITH BRICKS
   ==================== */

/* Ensure compatibility with Bricks form styles */
.bricks-form .gawistik-step-indicator {
    font-family: inherit;
}

/* Hide original submit button when multi-step is active */
.bricks-form[data-multistep="true"] .bricks-form-submit {
    display: none !important;
}

/* Ensure proper spacing in Bricks containers */
.brxe-form .gawistik-step-indicator {
    margin-left: 0;
    margin-right: 0;
}

/* ====================
   BUILDER PREVIEW MODE
   ==================== */

/* In builder: show all fields but style them to show step organization */
.gawistik-builder-preview .gawistik-step-2,
.gawistik-builder-preview .gawistik-step-3,
.gawistik-builder-preview .gawistik-step-4,
.gawistik-builder-preview .gawistik-step-5 {
    opacity: 0.6;
    border-left: 3px solid #e5e7eb;
    padding-left: 1rem;
    margin-left: 1rem;
}

/* Add step labels in builder */
.gawistik-builder-preview .gawistik-step-2:before,
.gawistik-builder-preview .gawistik-step-3:before,
.gawistik-builder-preview .gawistik-step-4:before,
.gawistik-builder-preview .gawistik-step-5:before {
    content: "Step " attr(data-step);
    display: block;
    font-size: 0.8rem;
    color: #6b7280;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

/* Disable navigation in builder */
.gawistik-builder-preview .gawistik-step-navigation {
    pointer-events: none;
    opacity: 0.7;
}

.gawistik-builder-preview .gawistik-step-navigation:after {
    content: "Preview only - navigation disabled in builder";
    display: block;
    font-size: 0.8rem;
    color: #6b7280;
    text-align: center;
    margin-top: 0.5rem;
}

/* ====================
   ACCESSIBILITY
   ==================== */

.gawistik-step-circle:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.gawistik-btn:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Screen reader only content */
.gawistik-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;
}

/* ====================
   DARK MODE SUPPORT
   ==================== */

@media (prefers-color-scheme: dark) {
    .gawistik-step-indicator {
        color: #f9fafb;
    }
    
    .gawistik-step-circle {
        background-color: #374151;
        border-color: #374151;
    }
    
    .gawistik-step-number {
        color: #d1d5db;
    }
    
    .gawistik-step-title {
        color: #f9fafb;
    }
    
    .gawistik-step-description {
        color: #9ca3af;
    }
    
    .gawistik-step-line {
        background-color: #374151;
    }
    
    .gawistik-step-navigation {
        border-top-color: #374151;
    }
    
    .gawistik-btn--previous {
        background-color: #374151;
        color: #f9fafb;
        border-color: #4b5563;
    }
    
    .gawistik-step-error {
        background-color: #1f2937;
        border-color: #374151;
        color: #f87171;
    }
}
