/* =================================
------------------------------------
  Enhanced Form Styles
  Professional & Responsive Forms
 ------------------------------------ 
 ====================================*/

/* Form Container */
.form-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 2rem;
    background: var(--bg-primary);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    position: relative;
    overflow: hidden;
}

.form-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--bg-gradient);
}

/* Form Header */
.form-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.form-header h2 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.form-header p {
    color: var(--text-secondary);
    margin-bottom: 0;
}

/* Form Grid */
.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.form-grid.two-column {
    grid-template-columns: 1fr 1fr;
}

.form-grid.three-column {
    grid-template-columns: 1fr 1fr 1fr;
}

/* Form Group Enhanced */
.form-group {
    position: relative;
    margin-bottom: 1.5rem;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

/* Floating Labels */
.form-group.floating-label {
    position: relative;
}

.form-group.floating-label .form-control {
    padding: 1rem 1rem 0.5rem;
    height: auto;
}

.form-group.floating-label .form-label {
    position: absolute;
    top: 1rem;
    left: 1rem;
    font-size: 1rem;
    color: var(--text-light);
    pointer-events: none;
    transition: var(--transition);
    background: var(--bg-primary);
    padding: 0 0.25rem;
}

.form-group.floating-label .form-control:focus + .form-label,
.form-group.floating-label .form-control:not(:placeholder-shown) + .form-label {
    top: -0.5rem;
    left: 0.75rem;
    font-size: 0.75rem;
    color: var(--primary-color);
    font-weight: 500;
}

/* Enhanced Form Controls */
.form-control {
    position: relative;
    background-color: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 0.875rem 1rem;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--text-primary);
    transition: var(--transition);
    width: 100%;
    min-height: 48px;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    outline: none;
}

.form-control:hover {
    border-color: var(--primary-color);
}

.form-control::placeholder {
    color: var(--text-light);
    opacity: 1;
}

/* Input States */
.form-control.is-valid {
    border-color: var(--success-color);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%234CAF50' d='m2.3 6.73.94-.94 2.94 2.94L8.5 6.4l.94.94L6.5 10.27z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
    padding-right: 2.5rem;
}

.form-control.is-invalid {
    border-color: var(--error-color);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23f44336'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath d='m5.5 5.5 1 1m0-1-1 1'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
    padding-right: 2.5rem;
}

/* Input Groups */
.input-group {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    width: 100%;
}

.input-group .form-control {
    position: relative;
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
}

.input-group-prepend,
.input-group-append {
    display: flex;
}

.input-group-text {
    display: flex;
    align-items: center;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--text-secondary);
    text-align: center;
    white-space: nowrap;
    background-color: var(--bg-secondary);
    border: 2px solid var(--border-color);
}

.input-group-prepend .input-group-text {
    border-right: 0;
    border-radius: var(--border-radius-sm) 0 0 var(--border-radius-sm);
}

.input-group-append .input-group-text {
    border-left: 0;
    border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
}

.input-group-prepend + .form-control {
    border-left: 0;
    border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
}

.form-control + .input-group-append {
    border-left: 0;
}

/* Select Styling */
.form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23667eea' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m1 6 7 7 7-7'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
    padding-right: 2.5rem;
    appearance: none;
}

/* Checkbox and Radio */
.form-check {
    position: relative;
    display: block;
    padding-left: 1.75rem;
    margin-bottom: 0.5rem;
}

.form-check-input {
    position: absolute;
    top: 0.25rem;
    left: 0;
    width: 1.25rem;
    height: 1.25rem;
    margin: 0;
    cursor: pointer;
    background-color: var(--bg-primary);
    border: 2px solid var(--border-color);
    appearance: none;
    transition: var(--transition);
}

.form-check-input[type="checkbox"] {
    border-radius: var(--border-radius-sm);
}

.form-check-input[type="radio"] {
    border-radius: 50%;
}

.form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.form-check-input:checked[type="checkbox"] {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3e%3c/svg%3e");
}

.form-check-input:checked[type="radio"] {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='2' fill='%23fff'/%3e%3c/svg%3e");
}

.form-check-label {
    color: var(--text-primary);
    cursor: pointer;
    font-weight: 400;
}

/* File Input */
.form-file {
    position: relative;
    display: inline-block;
    width: 100%;
}

.form-file-input {
    position: relative;
    z-index: 2;
    width: 100%;
    height: calc(2.25rem + 2px);
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.form-file-label {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    z-index: 1;
    height: calc(2.25rem + 2px);
    padding: 0.875rem 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--text-secondary);
    background-color: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
}

.form-file-label::after {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 3;
    display: block;
    height: calc(2.25rem);
    padding: 0.875rem 1rem;
    line-height: 1.5;
    color: var(--text-secondary);
    content: "Browse";
    background-color: var(--bg-secondary);
    border-left: 2px solid var(--border-color);
    border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
}

/* Form Validation */
.valid-feedback {
    display: none;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: var(--success-color);
}

.invalid-feedback {
    display: none;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: var(--error-color);
}

.form-control.is-valid ~ .valid-feedback {
    display: block;
}

.form-control.is-invalid ~ .invalid-feedback {
    display: block;
}

/* Password Strength Indicator */
.password-strength {
    margin-top: 0.5rem;
    height: 4px;
    background-color: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
}

.password-strength-bar {
    height: 100%;
    width: 0%;
    transition: var(--transition);
    border-radius: 2px;
}

.password-strength-bar.weak {
    width: 25%;
    background-color: var(--error-color);
}

.password-strength-bar.fair {
    width: 50%;
    background-color: var(--warning-color);
}

.password-strength-bar.good {
    width: 75%;
    background-color: var(--info-color);
}

.password-strength-bar.strong {
    width: 100%;
    background-color: var(--success-color);
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.form-actions .btn {
    min-width: 120px;
}

/* Progress Steps */
.form-steps {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2rem;
    position: relative;
}

.form-steps::before {
    content: '';
    position: absolute;
    top: 1rem;
    left: 0;
    right: 0;
    height: 2px;
    background-color: var(--border-color);
    z-index: 1;
}

.form-step {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: var(--bg-primary);
    padding: 0 1rem;
}

.form-step-number {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background-color: var(--border-color);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-bottom: 0.5rem;
    transition: var(--transition);
}

.form-step.active .form-step-number {
    background-color: var(--primary-color);
    color: var(--text-white);
}

.form-step.completed .form-step-number {
    background-color: var(--success-color);
    color: var(--text-white);
}

.form-step-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
}

.form-step.active .form-step-label {
    color: var(--primary-color);
    font-weight: 500;
}

/* Responsive Form Design */
@media (max-width: 768px) {
    .form-container {
        margin: 1rem;
        padding: 1.5rem;
    }
    
    .form-grid.two-column,
    .form-grid.three-column {
        grid-template-columns: 1fr;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        width: 100%;
    }
    
    .form-steps {
        flex-direction: column;
        gap: 1rem;
    }
    
    .form-steps::before {
        display: none;
    }
    
    .form-step {
        flex-direction: row;
        justify-content: flex-start;
        text-align: left;
        padding: 0;
    }
    
    .form-step-number {
        margin-right: 1rem;
        margin-bottom: 0;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .form-container {
        background-color: #1a1a1a;
        color: #ffffff;
    }
    
    .form-control {
        background-color: #2a2a2a;
        border-color: #404040;
        color: #ffffff;
    }
    
    .form-control:focus {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
    }
}

/* Animation for form elements */
.form-group {
    animation: slideUp 0.3s ease-out;
}

.form-group:nth-child(1) { animation-delay: 0.1s; }
.form-group:nth-child(2) { animation-delay: 0.2s; }
.form-group:nth-child(3) { animation-delay: 0.3s; }
.form-group:nth-child(4) { animation-delay: 0.4s; }
.form-group:nth-child(5) { animation-delay: 0.5s; }

/* Focus management for accessibility */
.form-control:focus,
.form-check-input:focus,
.btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .form-control {
        border-width: 3px;
    }
    
    .form-control:focus {
        border-color: #000000;
        box-shadow: none;
    }
}