/**
 * Leadio Forms - Frontend Styles
 * Version: 2.0.0
 */

/* ==========================================================================
   RESET & BASE STYLES
   ========================================================================== */

.leadio-form {
    box-sizing: border-box;
    font-family: inherit;
    line-height: 1.5;
    color: inherit;
}

.leadio-form *,
.leadio-form *::before,
.leadio-form *::after {
    box-sizing: inherit;
}

/* ==========================================================================
   FORM CONTAINER
   ========================================================================== */

.leadio-form-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: relative;
}

.leadio-form-container.inline-form {
    background: transparent;
    box-shadow: none;
    padding: 0;
}

.leadio-form-container.popup-form {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

/* Form Header */
.leadio-form-header {
    margin-bottom: 30px;
    text-align: center;
}

.leadio-form-title {
    font-size: 28px;
    font-weight: bold;
    margin: 0 0 15px 0;
    color: inherit;
    line-height: 1.3;
}

.leadio-form-description {
    font-size: 16px;
    color: #666;
    margin: 0;
    line-height: 1.5;
}

/* ==========================================================================
   FORM FIELDS
   ========================================================================== */

.leadio-field {
    margin-bottom: 25px;
    position: relative;
}

.leadio-field:last-child {
    margin-bottom: 0;
}

/* Field Labels */
.leadio-field label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: inherit;
    font-size: 14px;
    line-height: 1.4;
}

.leadio-field label.required::after {
    content: " *";
    color: #e74c3c;
    font-weight: bold;
}

/* Input Fields */
.leadio-field input[type="text"],
.leadio-field input[type="email"],
.leadio-field input[type="tel"],
.leadio-field input[type="url"],
.leadio-field input[type="number"],
.leadio-field textarea,
.leadio-field select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    font-size: 16px;
    font-family: inherit;
    line-height: 1.5;
    background-color: #ffffff;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    -webkit-appearance: none;
    appearance: none;
}

.leadio-field input[type="text"]:focus,
.leadio-field input[type="email"]:focus,
.leadio-field input[type="tel"]:focus,
.leadio-field input[type="url"]:focus,
.leadio-field input[type="number"]:focus,
.leadio-field textarea:focus,
.leadio-field select:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.1);
}

/* Textarea specific */
.leadio-field textarea {
    min-height: 100px;
    resize: vertical;
}

/* Select dropdown */
.leadio-field select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
}

/* Checkbox and Radio */
.leadio-field input[type="checkbox"],
.leadio-field input[type="radio"] {
    width: auto;
    margin-right: 8px;
    vertical-align: middle;
}

.leadio-field .checkbox-group,
.leadio-field .radio-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.leadio-field .checkbox-option,
.leadio-field .radio-option {
    display: flex;
    align-items: center;
    padding: 8px 0;
}

.leadio-field .checkbox-option label,
.leadio-field .radio-option label {
    margin: 0;
    font-weight: normal;
    cursor: pointer;
    flex: 1;
}

.leadio-field .checkbox-option input,
.leadio-field .radio-option input {
    margin: 0 10px 0 0;
    flex-shrink: 0;
}

/* ==========================================================================
   FIELD VALIDATION STATES
   ========================================================================== */

.leadio-field .field-error {
    display: block;
    color: #e74c3c;
    font-size: 13px;
    margin-top: 5px;
    line-height: 1.4;
}

.leadio-field input.error,
.leadio-field textarea.error,
.leadio-field select.error {
    border-color: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
}

.leadio-field input.success,
.leadio-field textarea.success,
.leadio-field select.success {
    border-color: #27ae60;
    box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.1);
}

/* ==========================================================================
   SUBMIT BUTTON
   ========================================================================== */

.leadio-submit-container {
    margin-top: 30px;
    text-align: center;
}

.leadio-submit-btn {
    background-color: #007cba;
    color: #ffffff;
    border: none;
    padding: 15px 30px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    min-width: 150px;
    position: relative;
    overflow: hidden;
}

.leadio-submit-btn:hover:not(:disabled) {
    background-color: #005a87;
    transform: translateY(-1px);
}

.leadio-submit-btn:active {
    transform: translateY(0);
}

.leadio-submit-btn:disabled,
.leadio-submit-btn.submitting {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.leadio-submit-btn.submitting::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top: 2px solid #ffffff;
    border-radius: 50%;
    animation: leadio-spinner 1s linear infinite;
}

@keyframes leadio-spinner {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==========================================================================
   MESSAGES
   ========================================================================== */

.leadio-messages {
    margin-bottom: 20px;
}

.leadio-message {
    padding: 15px 20px;
    border-radius: 6px;
    margin-bottom: 15px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    line-height: 1.5;
}

.leadio-message-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.leadio-message-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.leadio-message-warning {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.leadio-message-info {
    background-color: #cce7ff;
    color: #004085;
    border: 1px solid #b3d7ff;
}

.message-close {
    background: none;
    border: none;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
    margin-left: 15px;
    padding: 0;
    line-height: 1;
}

.message-close:hover {
    opacity: 1;
}

/* Verification Notice */
.verification-notice {
    margin-top: 15px;
    padding: 15px;
    background-color: #e3f2fd;
    border-left: 4px solid #2196f3;
    border-radius: 0 4px 4px 0;
}

.verification-notice p {
    margin: 0;
    font-size: 14px;
    color: #1565c0;
}

.resend-verification {
    color: #1976d2;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
}

.resend-verification:hover {
    text-decoration: underline;
}

.resend-verification.sending {
    opacity: 0.6;
    cursor: not-allowed;
}

.resend-verification.sent {
    color: #388e3c;
}

.resend-verification.error {
    color: #d32f2f;
}

/* ==========================================================================
   RECAPTCHA
   ========================================================================== */

.leadio-recaptcha {
    margin: 20px 0;
    text-align: center;
}

.leadio-recaptcha .g-recaptcha {
    display: inline-block;
}

/* ==========================================================================
   POPUP STYLES
   ========================================================================== */

.leadio-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(2px);
}

.leadio-popup-overlay.active {
    opacity: 1;
    visibility: visible;
}

.leadio-popup-container {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    overflow: hidden;
    transform: scale(0.8);
    transition: transform 0.3s ease;
}

.leadio-popup-overlay.active .leadio-popup-container {
    transform: scale(1);
}

.leadio-popup-content {
    position: relative;
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

.leadio-popup-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    z-index: 10;
    transition: background-color 0.2s ease;
}

.leadio-popup-close:hover {
    background: rgba(0, 0, 0, 0.7);
}

.leadio-popup-close span {
    font-weight: bold;
    margin-top: -2px;
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */

/* Tablet */
@media (max-width: 768px) {
    .leadio-form-container {
        padding: 15px;
        margin: 10px;
    }
    
    .leadio-form-title {
        font-size: 24px;
    }
    
    .leadio-field {
        margin-bottom: 20px;
    }
    
    .leadio-field input[type="text"],
    .leadio-field input[type="email"],
    .leadio-field input[type="tel"],
    .leadio-field input[type="url"],
    .leadio-field input[type="number"],
    .leadio-field textarea,
    .leadio-field select {
        padding: 12px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .leadio-submit-btn {
        padding: 12px 25px;
        font-size: 15px;
    }
    
    .leadio-popup-container {
        max-width: 95%;
        margin: 20px;
    }
}

/* Mobile */
@media (max-width: 480px) {
    .leadio-form-container {
        padding: 15px;
        margin: 5px;
        border-radius: 4px;
    }
    
    .leadio-form-container.popup-form {
        margin: 10px;
        max-width: calc(100% - 20px);
    }
    
    .leadio-form-title {
        font-size: 20px;
        margin-bottom: 10px;
    }
    
    .leadio-form-description {
        font-size: 14px;
    }
    
    .leadio-field {
        margin-bottom: 18px;
    }
    
    .leadio-field label {
        font-size: 13px;
        margin-bottom: 6px;
    }
    
    .leadio-field input[type="text"],
    .leadio-field input[type="email"],
    .leadio-field input[type="tel"],
    .leadio-field input[type="url"],
    .leadio-field input[type="number"],
    .leadio-field textarea,
    .leadio-field select {
        padding: 10px;
        font-size: 16px;
    }
    
    .leadio-submit-btn {
        width: 100%;
        padding: 15px;
        font-size: 16px;
    }
    
    .leadio-message {
        padding: 12px 15px;
        font-size: 13px;
    }
    
    .leadio-popup-close {
        top: 10px;
        right: 10px;
        width: 28px;
        height: 28px;
        font-size: 16px;
    }
    
    /* Stack checkbox/radio options vertically on mobile */
    .leadio-field .checkbox-group,
    .leadio-field .radio-group {
        gap: 8px;
    }
    
    .leadio-field .checkbox-option,
    .leadio-field .radio-option {
        padding: 6px 0;
    }
}

/* ==========================================================================
   ACCESSIBILITY
   ========================================================================== */

/* Focus indicators */
.leadio-form input:focus,
.leadio-form textarea:focus,
.leadio-form select:focus,
.leadio-form button:focus {
    outline: 2px solid #005fcc;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .leadio-field input[type="text"],
    .leadio-field input[type="email"],
    .leadio-field input[type="tel"],
    .leadio-field input[type="url"],
    .leadio-field input[type="number"],
    .leadio-field textarea,
    .leadio-field select {
        border-width: 2px;
    }
    
    .leadio-submit-btn {
        border: 2px solid transparent;
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .leadio-form *,
    .leadio-popup-overlay,
    .leadio-popup-container {
        transition: none !important;
        animation: none !important;
    }
}

/* Print styles */
@media print {
    .leadio-popup-overlay {
        position: static;
        background: none;
        backdrop-filter: none;
    }
    
    .leadio-popup-close {
        display: none;
    }
    
    .leadio-submit-btn {
        display: none;
    }
    
    .leadio-messages {
        display: none;
    }
}

/* ==========================================================================
   DARK MODE SUPPORT
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .leadio-form-container:not(.custom-colors) {
        background-color: #2d3748;
        color: #e2e8f0;
    }
    
    .leadio-form-container:not(.custom-colors) .leadio-form-description {
        color: #a0aec0;
    }
    
    .leadio-form-container:not(.custom-colors) input[type="text"],
    .leadio-form-container:not(.custom-colors) input[type="email"],
    .leadio-form-container:not(.custom-colors) input[type="tel"],
    .leadio-form-container:not(.custom-colors) input[type="url"],
    .leadio-form-container:not(.custom-colors) input[type="number"],
    .leadio-form-container:not(.custom-colors) textarea,
    .leadio-form-container:not(.custom-colors) select {
        background-color: #4a5568;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .leadio-form-container:not(.custom-colors) input::placeholder,
    .leadio-form-container:not(.custom-colors) textarea::placeholder {
        color: #a0aec0;
    }
}

/* ==========================================================================
   UTILITY CLASSES
   ========================================================================== */

.leadio-hidden {
    display: none !important;
}

.leadio-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.leadio-text-center {
    text-align: center;
}

.leadio-text-left {
    text-align: left;
}

.leadio-text-right {
    text-align: right;
}

.leadio-mb-0 {
    margin-bottom: 0 !important;
}

.leadio-mt-20 {
    margin-top: 20px !important;
}

/* ==========================================================================
   CUSTOM THEME OVERRIDES
   ========================================================================== */

/* Allow themes to override specific styles */
.leadio-form-container.theme-override {
    /* Placeholder for theme-specific overrides */
}

/* ==========================================================================
   LOADING STATES
   ========================================================================== */

.leadio-form.loading {
    pointer-events: none;
    opacity: 0.6;
}

.leadio-form.loading::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

/* ==========================================================================
   FORM ALIGNMENT CLASSES
   ========================================================================== */

.leadio-form-container.align-center {
    text-align: center;
}

.leadio-form-container.align-center .leadio-field label {
    text-align: center;
}

.leadio-form-container.align-center .leadio-field .checkbox-group,
.leadio-form-container.align-center .leadio-field .radio-group {
    align-items: center;
}

.leadio-form-container.align-right {
    text-align: right;
}

.leadio-form-container.align-right .leadio-field label {
    text-align: right;
}

.leadio-form-container.align-right .leadio-field .checkbox-group,
.leadio-form-container.align-right .leadio-field .radio-group {
    align-items: flex-end;
}