/**
 * Form Styles - Estilos para formularios dinámicos con secciones colapsables
 */

/* Form Container */
#form-container {
    padding: 0;
}

.form-header {
    margin-bottom: 1.0rem;
    padding: 1.5rem 1rem 1rem;
}

.form-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #333;
    text-align: center;
}

.form-description {
    font-size: 0.9rem;
    color: #666;
    text-align: center;
}

/* Form Loader */
.form-loader {
    text-align: center;
    padding: 3rem 1rem;
}

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

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

/* Form Sections */
.form-section {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 1rem;
    overflow: visible;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.form-section.collapsed {
    overflow: hidden;
}

.form-section.allow-overflow {
    overflow: visible;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 1;
    margin: 0;
    padding: 1rem 1.25rem;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
}

.form-section.collapsed .section-header {
    margin-bottom: -1px;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

.section-header:hover {
    background: #f34f3621;
}

.section-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #333;
}

.section-title-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.section-status-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.section-complete-icon {
    display: none;
    align-items: center;
    color: #28a745;
}

.section-complete-icon svg {
    width: 18px;
    height: 18px;
}

.form-section.is-complete .section-complete-icon {
    display: inline-flex;
}

.section-error-count {
    display: none;
    font-size: 0.9rem;
    font-weight: 600;
    color: #dc3545;
}

.section-error-count.is-visible {
    display: inline;
}

.section-toggle {
    transition: transform 0.3s ease;
    flex-shrink: 0;
    margin-left: 1rem;
}

.form-section.collapsed .section-toggle {
    transform: rotate(-90deg);
}

.section-content {
    padding: 0;
    border-top: 1px solid #e0e0e0;
    overflow: visible;
    position: relative;
    z-index: 2;
    opacity: 1;
    transform: translateY(0);
    transition: height 0.3s ease, opacity 0.2s ease, transform 0.3s ease;
}

.section-content.is-animating {
    overflow: hidden;
}

.form-section.collapsed .section-content {
    overflow: hidden;
    border-top-color: transparent;
}

.section-content.allow-overflow {
    overflow: visible;
}

.section-content-inner {
    padding: 1.5rem 1.25rem;
}

.form-section.collapsed .section-content {
    opacity: 0;
    transform: translateY(-6px);
}

/* Form Fields */
.form-field {
    margin-bottom: 1.25rem;
}

.form-field:last-child {
    margin-bottom: 0;
}

.form-field label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #333;
    font-size: 0.9375rem;
}

.form-field .checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-weight: 500;
    color: #333;
    font-size: 0.9375rem;
    cursor: pointer;
    margin-bottom: 0;
}

.checkbox-input {
    margin-top: 0.2rem;
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--primary-color);
}

.checkbox-text {
    line-height: 1.45;
}

.form-field label .required {
    color: #dc3545;
    font-weight: 600;
}

/* Input Styles */
.form-input,
.form-select {
    width: 100%;
    padding: 0.75rem 1rem;
    padding-right: 2.5rem;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 1rem;
    color: #495057;
    background-color: white;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-input.form-input-number {
    padding-right: 0.75rem;
}

.form-input.form-datepicker {
    padding-right: 0.75rem;
    padding-left: 0.75rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    display: block;
    min-width: 0;
    -webkit-appearance: none;
    appearance: none;
    min-height: 42px;
}

.form-input.form-datepicker::-webkit-date-and-time-value {
    text-align: left;
}

@supports (-webkit-touch-callout: none) {
    .form-input.form-datepicker {
        width: 100%;
        max-width: 100%;
        padding-right: 0.5rem;
        padding-left: 0.5rem;
    }
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236c757d' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.9rem center;
    background-size: 0.7rem;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--primary-color-rgb, 0, 123, 255), 0.1);
}

.form-input::placeholder {
    color: #6c757d;
}

.form-input:not(:placeholder-shown) {
    font-weight: 600;
}

.form-input.error,
.form-select.error {
    border-color: #dc3545;
}

.form-input.error:focus,
.form-select.error:focus {
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.field-error {
    display: none;
    margin-top: 0.2rem;
    font-size: 0.85rem;
    color: #dc3545;
}

.form-field.has-error .field-error {
    display: block;
}

/* Phone Input */
.phone-input-container {
    display: flex;
    gap: 0.5rem;
}

.number-with-units {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.number-unit-select {
    width: 8.5rem;
    flex-shrink: 0;
}

.country-prefix-select {
    width: 120px;
    padding: 0.75rem 0.5rem;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 1rem;
    color: #495057;
    background-color: white;
}

.phone-number-input {
    flex: 1;
}

/* Submit Button */
.submit-button {
    width: 100%;
    padding: 0.875rem 1.5rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    margin-top: 1.5rem;
}

.submit-button:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.submit-button:active {
    transform: translateY(0);
}

.submit-button:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
    transform: none;
}

.submit-error {
    margin-top: 0.75rem;
    font-size: 0.9rem;
    color: #dc3545;
    text-align: center;
}

/* Responsive Design */
@media (max-width: 768px) {
    .section-header {
        padding: 0.875rem 1rem;
    }

    .section-header h3 {
        font-size: 1rem;
    }

    .section-content {
        padding: 0;
    }

    .section-content-inner {
        padding: 1rem;
    }

    .form-field {
        margin-bottom: 1rem;
    }

    .form-input,
    .form-select {
        padding: 0.625rem 0.875rem;
        font-size: 1rem;
    }

    .phone-input-container {
        flex-direction: column;
        gap: 0.75rem;
    }

    .country-prefix-select {
        width: 100%;
    }

    .submit-button {
        padding: 0.75rem 1.25rem;
    }
}

/* Combobox Search Styles */
.combobox-search {
    position: relative;
}

.combobox-search .form-input {
    cursor: pointer;
    padding-right: 2.5rem;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236c757d' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.9rem center;
    background-size: 0.7rem;
}

.combobox-loader {
    display: none;
    position: absolute;
    right: 2.4rem;
    top: 50%;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    border: 2px solid #d7dbe0;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    pointer-events: none;
}

.combobox-search.is-loading .combobox-loader {
    display: block;
}

.combobox-dropdown {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 0.4rem);
    background: #fff;
    border: 1px solid #ced4da;
    border-radius: 8px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
    max-height: 240px;
    overflow-y: auto;
    z-index: 10;
}

.combobox-dropdown.is-open {
    display: block;
}

.combobox-option {
    width: 100%;
    padding: 0.6rem 0.9rem;
    border: none;
    background: transparent;
    text-align: left;
    font-weight: 600;
    font-size: 1rem;
    color: #333;
    cursor: pointer;
}

.combobox-option:hover {
    background: #f8f9fa;
}

.combobox-option-child {
    padding-left: 1.8rem;
}

.combobox-group-header {
    padding: 0.5rem 0.9rem;
    font-weight: 700;
    font-size: 0.85rem;
    color: #6c757d;
    text-transform: uppercase;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    cursor: default;
}

.combobox-empty {
    cursor: default;
    color: #6c757d;
    font-weight: 500;
}
