/**
 * Newsletter Form Styles
 * AL Homes Real Estate Theme
 * 
 * Includes:
 * - Base form styles
 * - Validation states (error, valid)
 * - Error icon and message
 * - Loading spinner
 * - Success state
 * 
 * @package ALHomes
 * @since 1.0.0
 */

/* ==========================================================================
   NEWSLETTER FORM BASE STYLES
   ========================================================================== */

.alhomes-newsletter-form {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    max-width: 400px;
}

.alhomes-newsletter-form input[type="email"] {
    flex: 1;
    height: 44px;
    padding: 0 40px 0 16px; /* Extra right padding for error icon */
    border: 1.5px solid #CCC8C0;
    border-radius: 32px;
    font-size: 14px;
    font-family: inherit;
    color: #5A4F42;
    background-color: #FFFFFF;
    transition: all 0.25s ease;
    outline: none;
}

.alhomes-newsletter-form input[type="email"]::placeholder {
    color: #928A80;
}

.alhomes-newsletter-form input[type="email"]:focus {
    border-color: #5A4F42;
    box-shadow: 0 0 0 3px rgba(90, 79, 66, 0.1);
}

/* ==========================================================================
   SUBMIT BUTTON
   ========================================================================== */

.alhomes-newsletter-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    padding: 0 !important;
    background-color: #5A4F42 !important;
    border: none !important;
    border-radius: 50% !important;
    cursor: pointer;
    transition: all 0.25s ease;
    flex-shrink: 0;
}

.alhomes-newsletter-btn:hover {
    background-color: #483F35 !important;
    transform: scale(1.05);
}

.alhomes-newsletter-btn:active {
    transform: scale(0.95);
}

.alhomes-newsletter-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.alhomes-newsletter-btn svg {
    width: 14px;
    height: 14px;
}

/* ==========================================================================
   ERROR STATE - RED BORDER WITH ! ICON
   ========================================================================== */

/* Invalid input - red border */
.alhomes-newsletter-form input[type="email"].is-invalid {
    border-color: #DC3545 !important;
    background-color: #FFF5F5;
    animation: shake 0.4s ease;
}

.alhomes-newsletter-form input[type="email"].is-invalid:focus {
    border-color: #DC3545 !important;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.15);
}

/* Error icon (!) inside input */
.newsletter-error-icon {
    position: absolute;
    right: 56px; /* Position before submit button */
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background-color: #DC3545;
    color: #FFFFFF;
    font-weight: 700;
    font-size: 14px;
    line-height: 20px;
    text-align: center;
    border-radius: 50%;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
    pointer-events: none;
    z-index: 2;
}

.newsletter-error-icon.visible {
    opacity: 1;
    visibility: visible;
}

/* Error message below input */
.newsletter-error-message {
    position: absolute;
    bottom: -24px;
    left: 16px;
    font-size: 12px;
    color: #DC3545;
    font-weight: 500;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.newsletter-error-message.visible {
    opacity: 1;
    visibility: visible;
}

/* Form error state */
.alhomes-newsletter-form.form-error {
    margin-bottom: 20px; /* Space for error message */
}

/* ==========================================================================
   VALID STATE - GREEN CHECK
   ========================================================================== */

.alhomes-newsletter-form input[type="email"].is-valid {
    border-color: #28A745;
    background-color: #F5FFF7;
}

.alhomes-newsletter-form input[type="email"].is-valid:focus {
    border-color: #28A745;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.15);
}

/* Valid checkmark icon (optional - can add) */
.alhomes-newsletter-form input[type="email"].is-valid + .newsletter-valid-icon {
    position: absolute;
    right: 56px;
    top: 50%;
    transform: translateY(-50%);
    color: #28A745;
    font-size: 16px;
}

/* ==========================================================================
   LOADING STATE
   ========================================================================== */

.alhomes-newsletter-form.form-loading input[type="email"] {
    opacity: 0.7;
    pointer-events: none;
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #FFFFFF;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ==========================================================================
   SUCCESS STATE
   ========================================================================== */

.alhomes-newsletter-form.form-success input[type="email"] {
    border-color: #28A745;
    background-color: #F5FFF7;
}

.newsletter-success-message {
    position: absolute;
    bottom: -28px;
    left: 0;
    right: 0;
    font-size: 13px;
    color: #28A745;
    font-weight: 500;
    text-align: left;
    padding-left: 16px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.newsletter-success-message.visible {
    opacity: 1;
    visibility: visible;
}

.newsletter-success-message .success-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background-color: #28A745;
    color: #FFFFFF;
    border-radius: 50%;
    font-size: 12px;
    margin-right: 6px;
    vertical-align: middle;
}

.alhomes-newsletter-form.form-success {
    margin-bottom: 24px;
}

/* ==========================================================================
   SHAKE ANIMATION
   ========================================================================== */

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-4px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(4px);
    }
}

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

@media (max-width: 768px) {
    .alhomes-newsletter-form {
        max-width: 100%;
    }
    
    .alhomes-newsletter-form input[type="email"] {
        height: 48px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .newsletter-error-message {
        font-size: 11px;
        bottom: -22px;
    }
    
    .newsletter-success-message {
        font-size: 12px;
        bottom: -26px;
    }
}

/* ==========================================================================
   DARK BACKGROUND VARIANT (Footer)
   ========================================================================== */

.site-footer .alhomes-newsletter-form input[type="email"] {
    background-color: #FFFFFF;
}

.site-footer .alhomes-newsletter-form input[type="email"].is-invalid {
    background-color: #FFF5F5;
}

.site-footer .alhomes-newsletter-form input[type="email"].is-valid {
    background-color: #F5FFF7;
}

/* ==========================================================================
   ACCESSIBILITY
   ========================================================================== */

/* Focus visible for keyboard users */
.alhomes-newsletter-form input[type="email"]:focus-visible {
    outline: 2px solid #5A4F42;
    outline-offset: 2px;
}

.alhomes-newsletter-btn:focus-visible {
    outline: 2px solid #FFFFFF;
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .alhomes-newsletter-form input[type="email"].is-invalid {
        animation: none;
    }
    
    .spinner {
        animation: none;
        border-top-color: transparent;
    }
    
    .alhomes-newsletter-form *,
    .newsletter-error-icon,
    .newsletter-error-message,
    .newsletter-success-message {
        transition: none !important;
    }
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
    .alhomes-newsletter-form {
        display: none;
    }
}