/**
 * Trafic Forms — Frontend Styles (Figma-matched)
 *
 * Brand colors:
 *   Blue:   #2B4678
 *   Yellow: #F7CA39
 *   Black:  #242526
 *
 * @package Trafic_Forms
 * @since   1.0.1
 */

/* =======================================================================
   WRAPPER
   ======================================================================= */

.trf-form-wrapper {
    max-width: 551px;
    margin: 0 auto;
    font-family: 'Roboto', sans-serif;
}

/* =======================================================================
   FORM LAYOUT
   ======================================================================= */

.trf-form {
    display: inline-flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-end;
    gap: 36px;
    width: 100%;
}

.trf-fields-block {
    align-self: stretch;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 14px;
}

.trf-bottom-block {
    align-self: stretch;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    gap: 24px;
}

.trf-row {
    display: inline-flex;
    justify-content: flex-start;
    align-items: center;
    gap: 14px;
    align-self: stretch;
}

.trf-row-full {
    align-self: stretch;
}

.trf-field {
    flex: 1;
}

/* =======================================================================
   INPUTS (placeholder-as-label style)
   ======================================================================= */

.trf-form-wrapper .trf-input,
.trf-form-wrapper .trf-textarea,
.trf-form-wrapper input[type="text"].trf-input,
.trf-form-wrapper input[type="email"].trf-input,
.trf-form-wrapper input[type="tel"].trf-input,
.trf-form-wrapper textarea.trf-textarea {
    width: 100%;
    height: 44px;
    padding: 12px 15px;
    background: #F8F8F8;
    border: none !important;
    border-radius: 14px !important;
    color: #333;
    font-size: 16px;
    font-family: 'Roboto', sans-serif;
    font-style: italic;
    font-weight: 400;
    line-height: 20.8px;
    word-wrap: break-word;
    transition: box-shadow 0.3s ease;
    box-sizing: border-box;
}

.trf-form-wrapper .trf-textarea,
.trf-form-wrapper textarea.trf-textarea {
    height: 150px;
    resize: vertical;
}

.trf-form-wrapper .trf-input::placeholder,
.trf-form-wrapper .trf-textarea::placeholder {
    color: #8C8C8C;
    font-size: 16px;
    font-family: 'Roboto', sans-serif;
    font-style: italic;
    font-weight: 400;
    line-height: 20.8px;
}

.trf-form-wrapper .trf-input:focus,
.trf-form-wrapper .trf-textarea:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(43, 70, 120, 0.3);
}

/* Invalid field highlight */
.trf-form-wrapper .trf-input.trf-invalid,
.trf-form-wrapper .trf-textarea.trf-invalid {
    box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.5);
}

.trf-form-wrapper .trf-input.trf-invalid:focus,
.trf-form-wrapper .trf-textarea.trf-invalid:focus {
    box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.7);
}

/* =======================================================================
   HONEYPOT (hidden from humans)
   ======================================================================= */

.trf-honey {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
}

/* =======================================================================
   POW CHECKBOX
   ======================================================================= */

.trf-row-pow {
    align-self: stretch;
}

.trf-pow-wrapper {
    display: flex;
    align-items: center;
}

.trf-pow-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: #242526;
    user-select: none;
}

.trf-pow-checkbox {
    display: none;
}

.trf-pow-checkmark {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    background: #F8F8F8;
    border: none;
    border-radius: 14px;
    position: relative;
    transition: background 0.3s ease;
}

.trf-pow-checkbox:checked + .trf-pow-checkmark {
    background: #2B4678;
}

.trf-pow-checkbox:checked + .trf-pow-checkmark::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.trf-pow-text {
    font-weight: 500;
}

.trf-pow-loading {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #2B4678;
    font-weight: 500;
}

.trf-pow-verified {
    font-size: 14px;
    font-weight: 600;
    color: #27ae60;
}

/* Spinner animation */
.trf-spinner {
    animation: trf-spin 0.8s linear infinite;
}

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

/* =======================================================================
   RGPD CHECKBOX
   ======================================================================= */

.trf-row-rgpd {
    align-self: stretch;
}

.trf-rgpd-wrapper {
    display: flex;
    align-items: flex-start;
}

.trf-rgpd-label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.trf-rgpd-checkbox {
    display: none;
}

.trf-rgpd-checkmark {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin-top: 1px;
    background: #F8F8F8;
    border: none;
    border-radius: 14px;
    position: relative;
    transition: background 0.3s ease;
}

.trf-rgpd-checkbox:checked + .trf-rgpd-checkmark {
    background: #2B4678;
}

.trf-rgpd-checkbox:checked + .trf-rgpd-checkmark::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.trf-rgpd-text {
    color: #8C8C8C;
    font-size: 13px;
    font-family: 'Roboto', sans-serif;
    font-style: italic;
    font-weight: 400;
    line-height: 16.9px;
    word-wrap: break-word;
}

.trf-rgpd-text a {
    color: #2B4678;
    text-decoration: underline;
}

.trf-rgpd-text a:hover {
    color: #1a2f54;
}

/* =======================================================================
   SUBMIT BUTTON (aligned right per Figma)
   ======================================================================= */

.trf-row-submit {
    align-self: flex-end;
}

.trf-form-wrapper .trf-submit-btn {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center;
    gap: 10px;
    height: 44px;
    padding: 2px 8px 2px 20px;
    background: #2B4678;
    color: #FAFAFA;
    font-size: 14px;
    font-weight: 600;
    font-family: 'Roboto', sans-serif;
    line-height: 17.64px;
    word-wrap: break-word;
    border: 1px solid #2B4678 !important;
    border-radius: 30px !important;
    cursor: pointer;
    transition: all 0.3s ease;
}

/* Hover: inversion fond/texte + icone */
.trf-form-wrapper .trf-submit-btn:hover {
    background: #F8F8F8;
    color: #2B4678;
    border-color: #2B4678;
}

.trf-form-wrapper .trf-submit-btn:hover .trf-submit-icon-circle {
    fill: #2B4678;
}

.trf-form-wrapper .trf-submit-btn:hover .trf-submit-icon-arrow {
    fill: #F8F8F8;
}

.trf-form-wrapper .trf-submit-btn:active {
    transform: scale(0.97);
}

.trf-form-wrapper .trf-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.trf-form-wrapper .trf-submit-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.trf-form-wrapper .trf-submit-icon svg {
    display: block;
    border-radius: 50%;
}

.trf-form-wrapper .trf-submit-icon-circle,
.trf-form-wrapper .trf-submit-icon-arrow {
    transition: fill 0.3s ease;
}

.trf-submit-loading {
    display: flex;
    align-items: center;
}

/* =======================================================================
   MESSAGES (success / error)
   ======================================================================= */

.trf-messages {
    align-self: stretch;
}

.trf-message {
    padding: 14px 18px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.5;
    font-weight: 500;
}

.trf-msg-success {
    background: #eafaf1;
    color: #27ae60;
    border: 1px solid #a3d9a5;
}

.trf-msg-error {
    background: #fdeded;
    color: #c0392b;
    border: 1px solid #f5c6cb;
}

/* =======================================================================
   FLOATING LABELS
   ======================================================================= */

.trf-field.trf-float {
    position: relative;
}

/* Inputs need more top padding to make room for the floating label */
.trf-field.trf-float .trf-input,
.trf-field.trf-float .trf-textarea {
    padding-top: 12px;
    padding-bottom: 12px;
}

.trf-float-label {
    position: absolute;
    top: 50%;
    left: 15px;
    transform: translateY(-50%);
    color: #8C8C8C;
    font-size: 16px;
    font-family: 'Roboto', sans-serif;
    font-style: italic;
    font-weight: 400;
    line-height: 1;
    pointer-events: none;
    transition: all 0.2s ease;
    padding: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 30px);
}

/* Textarea: label at top instead of center */
.trf-field.trf-float .trf-textarea ~ .trf-float-label {
    top: 16px;
    transform: none;
}

/* Float up when focused or has content — stays INSIDE the field */
.trf-field.trf-float .trf-input:focus ~ .trf-float-label,
.trf-field.trf-float .trf-input:not(:placeholder-shown) ~ .trf-float-label,
.trf-field.trf-float .trf-textarea:focus ~ .trf-float-label,
.trf-field.trf-float .trf-textarea:not(:placeholder-shown) ~ .trf-float-label {
    top: 4px;
    transform: none;
    font-size: 11px;
    font-style: normal;
    font-weight: 500;
    color: #2B4678;
    background: transparent;
}

/* Push input text down when label is floating */
.trf-field.trf-float .trf-input:focus,
.trf-field.trf-float .trf-input:not(:placeholder-shown) {
    padding-top: 24px;
    padding-bottom: 2px;
    font-style: normal;
}
.trf-field.trf-float .trf-textarea:focus,
.trf-field.trf-float .trf-textarea:not(:placeholder-shown) {
    padding-top: 26px;
    font-style: normal;
}

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

@media (max-width: 768px) {
    .trf-form-wrapper {
        max-width: 100%;
        padding: 0 16px;
    }

    .trf-row {
        flex-direction: column;
        gap: 14px;
    }

    .trf-field {
        width: 100%;
    }

    .trf-row-submit {
        align-self: stretch;
    }

    .trf-submit-btn {
        width: 100%;
        justify-content: center;
    }
}
