/* Anotik Form Frontend Styles */

/* ==========================================================================
   BEM Class Structure:
   .anotik-form                    - Main container
   .anotik-form__title             - Form title
   .anotik-form__description       - Form description
   .anotik-form__form              - Form element
   .anotik-form__fields            - Fields wrapper
   .anotik-form__row               - Row container
   .anotik-form__row--2col         - 2 column row
   .anotik-form__row--3col         - 3 column row
   .anotik-form__column            - Column in row
   .anotik-form__group             - Conditional group
   .anotik-form__field             - Field wrapper
   .anotik-form__field--text       - Text field
   .anotik-form__field--email      - Email field
   .anotik-form__field--textarea   - Textarea field
   .anotik-form__field--select     - Select field
   .anotik-form__field--checkbox   - Checkbox field
   .anotik-form__field--radio      - Radio field
   .anotik-form__field--required   - Required field
   .anotik-form__field--inline     - Inline layout
   .anotik-form__label             - Field label
   .anotik-form__input             - Input element
   .anotik-form__textarea          - Textarea element
   .anotik-form__select            - Select element
   .anotik-form__checkbox          - Checkbox input
   .anotik-form__checkbox-label    - Checkbox label wrapper
   .anotik-form__radio             - Radio input
   .anotik-form__radio-label       - Radio label wrapper
   .anotik-form__radio-group       - Radio options container
   .anotik-form__radio-text        - Radio option text
   .anotik-form__submit            - Submit button wrapper
   .anotik-form__submit-btn        - Submit button
   .anotik-form__message           - Form message (success/error)
   ========================================================================== */

.anotik-form,
.anotik-custom-form-container {
    max-width: 800px;
    margin: 0 auto;
}

.anotik-form__title,
.anotik-form-title {
    margin: 0 0 10px;
    font-size: 24px;
    font-weight: 600;
}

.anotik-form__description,
.anotik-form-description {
    margin: 0 0 20px;
    color: #666;
}

.anotik-form__form,
.anotik-custom-form {
    background: transparent;
}

.anotik-form__field,
.anotik-form-field {
    margin-bottom: 20px;
}

.anotik-form__label,
.anotik-form-field label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}

.anotik-form__label .required,
.anotik-form-field label .required {
    color: #dc3545;
}

.anotik-form__input,
.anotik-form-field input[type="text"],
.anotik-form-field input[type="email"],
.anotik-form-field input[type="tel"],
.anotik-form-field input[type="number"],
.anotik-form-field input[type="date"],
.anotik-form-field input[type="url"],
.anotik-form-field select,
.anotik-form-field textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 15px;
    color: inherit;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
    background: #fff;
}

.anotik-form__input:focus,
.anotik-form-field input:focus,
.anotik-form-field select:focus,
.anotik-form-field textarea:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.1);
}

.anotik-form__textarea,
.anotik-form-field textarea {
    min-height: 120px;
    resize: vertical;
}

.anotik-form__select,
.anotik-form-field select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 35px;
}

/* Radio and Checkbox - inherit theme styles */
.anotik-form__radio-label,
.anotik-form__checkbox-label,
.anotik-radio-label,
.anotik-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: normal !important;
    cursor: pointer;
}

.anotik-form__radio,
.anotik-form__checkbox,
.anotik-radio-label input[type="radio"],
.anotik-checkbox-label input[type="checkbox"] {
    /* Let theme styles apply - minimal overrides */
    margin: 0;
    cursor: pointer;
}

/* Radio group */
.anotik-form__radio-group,
.anotik-radio-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Inline Layout for Radio/Checkbox */
.anotik-form__field--inline .anotik-form__radio-group,
.anotik-field-inline .anotik-radio-group,
.anotik-field-inline .anotik-checkbox-group {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 20px;
}

.anotik-form__field--inline .anotik-form__radio-label,
.anotik-field-inline .anotik-radio-label,
.anotik-field-inline .anotik-checkbox-label {
    flex: 0 0 auto;
}

/* Row layouts */
.anotik-form__row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
}

.anotik-form__row--2col .anotik-form__column {
    flex: 1 1 calc(50% - 10px);
    min-width: 200px;
}

.anotik-form__row--3col .anotik-form__column {
    flex: 1 1 calc(33.333% - 14px);
    min-width: 150px;
}

/* Conditional Fields and Groups - Hidden by default when conditional */
.anotik-form-field[data-conditional="1"],
.anotik-form-group[data-conditional="1"] {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    margin-bottom: 0;
    transform: translateY(-10px);
    transition:
        max-height 0.4s ease-out,
        opacity 0.3s ease-out,
        transform 0.3s ease-out,
        margin-bottom 0.3s ease-out;
}

.anotik-form-field[data-conditional="1"].anotik-conditional-visible,
.anotik-form-group[data-conditional="1"].anotik-conditional-visible {
    max-height: 1000px;
    opacity: 1;
    transform: translateY(0);
    margin-bottom: 20px;
    transition:
        max-height 0.5s ease-in,
        opacity 0.4s ease-in 0.1s,
        transform 0.4s ease-in 0.1s,
        margin-bottom 0.3s ease-in;
}

/* Conditional Group Styling */
.anotik-form-group {
    margin-bottom: 20px;
}

/* File Upload */
.anotik-field-file input[type="file"] {
    padding: 10px;
    border: 2px dashed #ddd;
    border-radius: 4px;
    background: #fafafa;
    cursor: pointer;
    width: 100%;
}

.anotik-field-file input[type="file"]:hover {
    border-color: #0073aa;
    background: #f0f6fc;
}

/* Captcha */
.anotik-captcha {
    margin-bottom: 20px;
}

/* Submit Button */
.anotik-form-submit {
    margin-top: 25px;
}

.anotik-submit-btn {
    display: inline-block;
    padding: 14px 30px;
    background: #0073aa;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.anotik-submit-btn:hover {
    background: #005a87;
}

.anotik-submit-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.anotik-submit-btn.loading {
    position: relative;
    color: transparent;
}

.anotik-submit-btn.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: anotik-spin 0.8s linear infinite;
}

@keyframes anotik-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Form Messages */
.anotik-form-message {
    padding: 15px 20px;
    border-radius: 4px;
    margin-top: 20px;
    font-size: 14px;
}

.anotik-form-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.anotik-form-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Form Error State */
.anotik-form-field.has-error input,
.anotik-form-field.has-error select,
.anotik-form-field.has-error textarea {
    border-color: #dc3545;
}

.anotik-field-error {
    color: #dc3545;
    font-size: 13px;
    margin-top: 5px;
}

/* Form Not Available */
.anotik-form-error {
    padding: 20px;
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    text-align: center;
}

/* Row Layout - Fields in same row */
.anotik-form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.anotik-form-row-2 .anotik-form-column {
    flex: 1;
    min-width: 0;
}

.anotik-form-row-3 .anotik-form-column {
    flex: 1;
    min-width: 0;
}

.anotik-form-column .anotik-form-field {
    margin-bottom: 15px;
}

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

/* Dark Theme Support */
@media (prefers-color-scheme: dark) {
    .anotik-custom-form-container {
        color: #e0e0e0;
    }

    .anotik-form-field label {
        color: #e0e0e0;
    }

    .anotik-form-description {
        color: #aaa;
    }
}

/* Responsive */
@media screen and (max-width: 600px) {
    .anotik-custom-form-container {
        padding: 0 15px;
    }

    .anotik-form-field input,
    .anotik-form-field select,
    .anotik-form-field textarea {
        padding: 10px 12px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .anotik-submit-btn {
        width: 100%;
        padding: 15px;
    }

    /* Stack row columns on mobile */
    .anotik-form-row {
        flex-direction: column;
        gap: 0;
    }

    .anotik-form-column .anotik-form-field {
        margin-bottom: 20px;
    }
}
