/**
 * Component: Dynamic Form
 * Architecture: CSS Grid, Floating Labels (Animated), Custom Validation UI
 */

.tama-dynform-section { padding: 60px 0; width: 100%; text-align: start; } /* page body forces text-align:left, wrong in RTL */
.tama-dynform-container { width: 100%; max-width: 1320px; margin: 0 auto; padding: 0 15px; }

.tama-dynform-grid-main {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr; 
    gap: 60px;
    align-items: flex-start;
}

.tama-dynform-subtitle {
    font-family: "Titillium", sans-serif;
    font-size: 16px;
    color: var(--third-color, #1c2d00);
    margin-bottom: 12px;
    font-weight: 400;
}

.tama-dynform-title {
    font-family: "Titillium", sans-serif;
    font-size: 26px;
    font-weight: 700;
    color: var(--third-color, #1c2d00);
    margin-bottom: 30px;
    line-height: 1.2;
}

.tama-dynform-fields-wrapper {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 15px 15px; /* Added vertical gap to make room for error text */
    margin-bottom: 30px;
}
.tama-col-33 { grid-column: span 4; }
.tama-col-50 { grid-column: span 6; }
.tama-col-100 { grid-column: span 12; }

/* 5. Inputs & Floating Labels (Animated) */
.tama-input-container {
    position: relative;
    width: 100%;
}

.tama-internal-label {
    position: absolute;
    /* Default Resting State (Big & Centered vertically) */
    top: 50%;
    left: 16px;
    transform: translateY(-50%);
    font-size: 16px;
    color: rgb(107, 94, 86);
    pointer-events: none;
    font-family: "Titillium", sans-serif;
    z-index: 5;
    white-space: nowrap;
    transition: all 0.2s ease-out; /* Smooth float animation */
}

/* Float State (When Focused OR Has Value) - Exact settings requested */
.tama-input-container.is-active .tama-internal-label {
    top: 8px;
    left: 10px;
    transform: translateY(0);
    font-size: 12px;
    color: rgb(107, 94, 86);
    user-select: none;
    opacity: 0.8;
}

[dir="rtl"] .tama-internal-label, body.rtl .tama-internal-label { left: auto; right: 16px; }
[dir="rtl"] .tama-input-container.is-active .tama-internal-label, 
body.rtl .tama-input-container.is-active .tama-internal-label { left: auto; right: 10px; }

.tama-input {
    width: 100%;
    padding: 24px 16px 6px 16px;
    border: 1px solid #cdc3bb;
    border-radius: 12px 12px 12px 2px;
    font-family: "Titillium", sans-serif;
    font-size: 16px;
    color: #002B35;
    outline: none;
    transition: border-color 0.3s ease;
    background-color: #fff;
    box-sizing: border-box;
    height: 58px; /* Fixed height to match standard */
}
.tama-input:focus { border-color: var(--primary-color, #667f06); }

/* Textarea tweaks */
.tama-textarea {
    resize: vertical;
    min-height: 90px;
    height: auto;
}
.tama-textarea + .tama-internal-label { top: 22px; } /* Adjust resting state for textarea */
.tama-input-container.is-active .tama-textarea + .tama-internal-label { top: 8px; }

.tama-select-arrow {
    content: ''; position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
    width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 6px solid #002B35;
    pointer-events: none;
}
[dir="rtl"] .tama-select-arrow, body.rtl .tama-select-arrow { right: auto; left: 16px; }
.tama-select { appearance: none; -webkit-appearance: none; cursor: pointer; }

/* Searchable dropdown (long lists) - same look as the Contact Us dropdown panel */
.tama-select-arrow { transition: transform 250ms ease-in-out; }
.tama-input-container.is-open .tama-select-arrow { transform: translateY(-50%) rotate(180deg); }
.tama-input-container.is-open .tama-input { border-color: var(--primary-color, #667f06); }
.tama-dd {
    position: absolute; inset-inline: 0; top: calc(100% + 5px); z-index: 105;
    background: #fff; border-radius: 2px 8px 8px 8px;
    box-shadow: 0 4px 20px 0 rgba(0, 0, 0, 0.3);
    font-family: "Titillium", sans-serif; overflow: hidden;
}
[dir="rtl"] .tama-dd, body.rtl .tama-dd { border-radius: 8px 2px 8px 8px; }
.tama-dd-search {
    display: block; width: 100%; box-sizing: border-box; height: 44px;
    padding: 0 40px 0 16px; margin: 0; border: 0; border-bottom: 1px solid #cdc3bb; border-radius: 0;
    outline: none; box-shadow: none; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%236b5e56' stroke-width='1.6' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='M11 11l3.5 3.5'/%3E%3C/svg%3E") no-repeat right 14px center;
    font-family: inherit; font-size: 16px; color: #002B35;
}
[dir="rtl"] .tama-dd-search, body.rtl .tama-dd-search { padding: 0 16px 0 40px; background-position: left 14px center; }
.tama-dd-search:focus { border-bottom-color: var(--primary-color, #667f06); }
.tama-dd-list { max-height: 175px; overflow-y: auto; }
.tama-dd-option { padding: 8px 16px; cursor: pointer; font-size: 16px; color: #002B35; text-align: start; }
.tama-dd-option.is-active { background-color: #f3f3ee; }
.tama-dd-option.is-selected { font-weight: 700; }
.tama-dd-empty { padding: 12px 16px; font-size: 14px; color: rgb(107, 94, 86); text-align: start; }

/* Validation Error Styles (Tama Standard) */
.tama-input.is-error {
    border-color: #ff0000;
    padding-inline-end: 44px; /* Space for the error icon */
}

.tama-error-icon {
    position: absolute;
    inset-inline-end: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background: url('../../../images/field-error.svg') no-repeat center / contain;
    display: none; /* Hidden by default */
    pointer-events: none;
}
/* Select: keep the icon clear of the dropdown arrow */
.tama-select ~ .tama-error-icon { inset-inline-end: 38px; }
.tama-select.is-error { padding-inline-end: 66px; }

.tama-input-container.has-error .tama-error-icon { display: block; }
.tama-error-text { color: #ff0000; font-size: 12px; margin-top: 4px; padding-inline-start: 16px; font-family: "Titillium", sans-serif; }

/* Checkbox: one per row, box next to its text (the shared .tama-input class must not size it) */
.tama-checkbox-label { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; font-size: 14px; color: rgb(107, 94, 86); margin: 0; font-family: "Titillium", sans-serif; text-align: start; }
.tama-input.tama-checkbox {
    -webkit-appearance: none; appearance: none;
    flex: 0 0 18px; width: 18px; min-width: 18px; height: 18px; margin: 2px 0 0; padding: 0;
    border: 1px solid rgb(107, 94, 86); border-radius: 3px; background-color: #fff;
    background-repeat: no-repeat; background-position: center; background-size: 12px;
    cursor: pointer; outline: none;
}
.tama-input.tama-checkbox:checked {
    background-color: var(--primary-color, #667f06); border-color: var(--primary-color, #667f06);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2 6.5l2.5 2.5L10 3.5' fill='none' stroke='%23fff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.tama-input.tama-checkbox:focus { border-color: var(--primary-color, #667f06); }
.tama-input.tama-checkbox.is-error { border-color: #ff0000; }

/* Free text note (not a field) */
.tama-form-note { margin: 0; font-family: "Titillium", sans-serif; font-size: 16px; color: var(--third-color, #1c2d00); }
.tama-checkbox-text { flex: 1 1 auto; }
.tama-checkbox-label + .tama-error-text { padding-inline-start: 30px; }

/* Button */
.tama-submit-btn {
    width: max-content; padding: 12px 32px; color: #fff; font-weight: 600;
    background-color: var(--primary-color, #667f06); border: 2px solid var(--primary-color, #667f06); font-size: 16px; font-family: "Titillium", sans-serif;
    border-radius: 12px 12px 12px 2px; transition: all 0.3s ease; cursor: pointer;
}
.tama-submit-btn:focus, .tama-submit-btn:active { outline: none; box-shadow: none; border-color: var(--primary-color, #667f06); }
.tama-submit-btn:focus-visible { outline: 2px solid var(--third-color, #1c2d00); outline-offset: 2px; }
.tama-submit-btn:hover, .tama-submit-btn:focus:hover { background-color: var(--third-color, #1c2d00); border-color: var(--third-color, #1c2d00); color: #fff; }

/* Media / Images & Feedback */
.tama-dynform-picture { width: 100%; display: flex; justify-content: flex-end; }
.tama-dynform-img { max-width: 100%; height: auto; border-radius: 16px; object-fit: cover; }
/* Thank You / Oops - same look as the footer form messages, self-contained in the component */
.tama-dynform-feedback {
    position: relative; background-color: #fff; padding: 40px 24px; border-radius: 24px;
    text-align: center; border: 1px solid #eaeaea; font-family: "Titillium", sans-serif;
}
.tama-feedback-icon { display: block; margin: 0 auto 12px; height: 40px; width: auto; }
.tama-feedback-title { font-size: 20px; font-weight: 700; line-height: 1.3; }
.tama-dynform-feedback--success .tama-feedback-title,
.tama-dynform-feedback--success .tama-feedback-sub { color: var(--primary-color, #667f06); }
.tama-dynform-feedback--error .tama-feedback-title { color: #ff0000; }
.tama-feedback-sub { font-size: 18px; margin-top: 6px; color: var(--third-color, #1c2d00); }
.tama-feedback-content { margin-top: 10px; font-size: 16px; color: rgb(107, 94, 86); }
.tama-feedback-close {
    position: absolute; inset-block-start: 16px; inset-inline-end: 16px;
    background: none; border: 0; padding: 0; width: 15px; height: 15px; cursor: pointer; line-height: 0;
}

@media (max-width: 992px) {
    .tama-dynform-grid-main { grid-template-columns: 1fr; }
    .tama-dynform-media { order: -1; margin-bottom: 20px; }
    .tama-dynform-picture { justify-content: center; }
    .tama-col-33, .tama-col-50 { grid-column: span 12; }
}