/**
 * Freight Quote Modal and Banner Styles
 *
 * Custom styles for the WooCommerce freight shipping quote system.
 * Used on cart and checkout pages when freight items are present.
 *
 * @package     JT Custom Trailers
 * @subpackage  WooCommerce Customizations
 * @version     1.4.0
 *
 * .NOTES
 *     Author: John O'Neill Sr.
 *     Company: Azure Innovators
 *     Create Date: 12/01/2025
 *     Version: 1.4.0
 *     Change Date: 12/01/2025
 *     Change Purpose: Fixed modal scrolling, added select dropdown styling
 *
 * .CHANGELOG
 *     1.0.0 - Initial creation
 *     1.1.0 - 12/01/2025 - Added fadeInOverlay, fadeOutOverlay, fadeInContent,
 *                          fadeOutContent keyframe animations. Added responsive
 *                          breakpoints. Improved focus states for accessibility.
 *     1.2.0 - 12/01/2025 - Added .freight-form-row styles for Contact Form 7
 *                          integration. Added explicit submit button styling
 *                          with visibility overrides to fix hidden button issue.
 *     1.3.0 - 12/01/2025 - Added two column form layout.
 *     1.4.0 - 12/01/2025 - Fixed modal scrolling issue by changing alignment
 *                          and overflow properties. Added select dropdown
 *                          styling with custom arrow. Added h3 section headers.
 *
 * File location: /wp-content/themes/astra-child/css/freight_quote_styles.css
 */

/* ============================================================================
   FREIGHT BANNER STYLES
   ============================================================================ */

.freight-banner {
    background: linear-gradient(135deg, #0073aa 0%, #005a87 100%);
    color: #fff;
    padding: 18px 25px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 25px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.3);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.freight-banner-icon {
    font-size: 24px;
}

.freight-banner-text {
    flex: 1;
    min-width: 200px;
}

.freight-banner a.freight-quote-trigger,
a.freight-quote-trigger {
    background: #fff;
    color: #0073aa;
    padding: 12px 24px;
    text-decoration: none;
    font-weight: 700;
    border-radius: 6px;
    display: inline-block;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    cursor: pointer;
}

.freight-banner a.freight-quote-trigger:hover,
a.freight-quote-trigger:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.freight-banner a.freight-quote-trigger:focus,
a.freight-quote-trigger:focus {
    outline: none;
    border-color: #ffcc00;
    box-shadow: 0 0 0 3px rgba(255, 204, 0, 0.5);
}

/* Link style trigger for use in tables */
.freight-quote-link {
    background: transparent !important;
    color: #0073aa !important;
    padding: 0 !important;
    text-decoration: underline !important;
    font-weight: 600 !important;
}

.freight-quote-link:hover {
    color: #005a87 !important;
    transform: none !important;
    box-shadow: none !important;
}

/* ============================================================================
   MODAL OVERLAY STYLES - FIXED FOR SCROLLING
   ============================================================================ */

.freight-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    justify-content: flex-start;
    align-items: flex-start;
    z-index: 999999;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto !important;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* ============================================================================
   MODAL CONTENT STYLES - FIXED FOR SCROLLING
   ============================================================================ */

.freight-modal-content {
    background: #fff;
    padding: 35px 40px;
    border-radius: 12px;
    width: 100%;
    max-width: 550px;
    margin: 20px auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-height: none;
    overflow: visible;
}

.freight-modal-content h2 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 28px;
    font-weight: 700;
    padding-right: 40px; /* Space for close button */
}

.freight-modal-content h3 {
    margin: 25px 0 15px 0;
    color: #333;
    font-size: 16px;
    font-weight: 700;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 8px;
}

.freight-modal-description {
    color: #666;
    margin-bottom: 25px;
    font-size: 15px;
    line-height: 1.6;
}

/* ============================================================================
   CLOSE BUTTON STYLES
   ============================================================================ */

.freight-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 32px;
    font-weight: 300;
    cursor: pointer;
    color: #999;
    line-height: 1;
    transition: all 0.2s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.freight-close:hover {
    color: #333;
    background: #f0f0f0;
}

.freight-close:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* ============================================================================
   CONTACT FORM 7 FORM ROW STYLES
   ============================================================================ */

.freight-form-row {
    margin-bottom: 18px;
}

.freight-form-row:last-child {
    margin-bottom: 0;
}

.freight-form-row label {
    display: block;
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
    font-size: 14px;
}

.freight-form-row input[type="text"],
.freight-form-row input[type="email"],
.freight-form-row input[type="tel"],
.freight-form-row textarea,
.freight-form-row select {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 15px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    box-sizing: border-box;
    background: #fff;
}

.freight-form-row input[type="text"]:focus,
.freight-form-row input[type="email"]:focus,
.freight-form-row input[type="tel"]:focus,
.freight-form-row textarea:focus,
.freight-form-row select:focus {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.15);
}

.freight-form-row textarea {
    min-height: 100px;
    resize: vertical;
}

/* Select dropdown specific styling */
.freight-form-row select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
    cursor: pointer;
}

/* Fix for Contact Form 7 select wrapper */
.freight-form-row .wpcf7-form-control-wrap select {
    width: 100%;
}

/* Turnstile CAPTCHA container */
.freight-form-turnstile {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

/* Submit button row */
.freight-form-submit {
    margin-top: 20px;
    margin-bottom: 0;
}

.freight-form-submit input[type="submit"],
input.freight-submit-btn,
.freight-modal-content .wpcf7-form input[type="submit"] {
    background: linear-gradient(135deg, #0073aa 0%, #005a87 100%) !important;
    color: #fff !important;
    padding: 16px 32px !important;
    border: none !important;
    cursor: pointer !important;
    border-radius: 8px !important;
    font-size: 18px !important;
    font-weight: 700 !important;
    width: 100% !important;
    transition: all 0.3s ease !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin-top: 10px;
    -webkit-appearance: none;
    appearance: none;
}

.freight-form-submit input[type="submit"]:hover,
input.freight-submit-btn:hover,
.freight-modal-content .wpcf7-form input[type="submit"]:hover {
    background: linear-gradient(135deg, #005a87 0%, #004568 100%) !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 115, 170, 0.4);
}

.freight-form-submit input[type="submit"]:focus,
input.freight-submit-btn:focus,
.freight-modal-content .wpcf7-form input[type="submit"]:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(0, 115, 170, 0.4);
}

/* Ensure submit wrapper is visible */
.freight-modal-content .wpcf7-form p:last-of-type,
.freight-modal-content .wpcf7-form .freight-form-submit {
    display: block !important;
    visibility: visible !important;
}

/* ============================================================================
   LEGACY FORM STYLES (fallback for non-row structure)
   ============================================================================ */

.freight-form input,
.freight-form textarea {
    width: 100%;
    padding: 14px 16px;
    margin-bottom: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    box-sizing: border-box;
}

.freight-form input:focus,
.freight-form textarea:focus {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 0 4px rgba(0, 115, 170, 0.15);
}

.freight-form textarea {
    min-height: 120px;
    resize: vertical;
}

.freight-form button {
    background: linear-gradient(135deg, #0073aa 0%, #005a87 100%);
    color: #fff;
    padding: 16px 32px;
    border: none;
    cursor: pointer;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 700;
    width: 100%;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.freight-form button:hover {
    background: linear-gradient(135deg, #005a87 0%, #004568 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 115, 170, 0.4);
}

.freight-form button:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(0, 115, 170, 0.4);
}

/* ============================================================================
   CONTACT FORM 7 RESPONSE MESSAGES
   ============================================================================ */

.freight-modal-content .wpcf7-response-output {
    margin: 15px 0 0 0 !important;
    padding: 15px !important;
    border-radius: 8px !important;
    font-size: 14px;
    text-align: center;
}

.freight-modal-content .wpcf7-form.sent .wpcf7-response-output {
    background: #d4edda !important;
    border-color: #28a745 !important;
    color: #155724 !important;
}

.freight-modal-content .wpcf7-form.failed .wpcf7-response-output,
.freight-modal-content .wpcf7-form.aborted .wpcf7-response-output {
    background: #f8d7da !important;
    border-color: #dc3545 !important;
    color: #721c24 !important;
}

.freight-modal-content .wpcf7-form.invalid .wpcf7-response-output {
    background: #fff3cd !important;
    border-color: #ffc107 !important;
    color: #856404 !important;
}

/* Validation error styling */
.freight-modal-content .wpcf7-not-valid-tip {
    color: #dc3545;
    font-size: 13px;
    margin-top: 5px;
    display: block;
}

.freight-modal-content .wpcf7-not-valid {
    border-color: #dc3545 !important;
}

/* Spinner during submission */
.freight-modal-content .wpcf7-spinner {
    margin: 15px auto 0;
    display: block;
}

/* ============================================================================
   SHIPPING NOTICE IN TOTALS TABLE
   ============================================================================ */

.freight-shipping-notice th,
.freight-shipping-notice td {
    background: #fff8e1 !important;
    border-color: #ffcc00 !important;
}

.freight-shipping-notice td a {
    color: #0073aa;
    font-weight: 600;
}

/* ============================================================================
   PRODUCT PAGE SHIPPING CLASS DISPLAY
   ============================================================================ */

.product-shipping-class {
    margin: 15px 0;
    padding: 10px 15px;
    background: #f8f9fa;
    border-left: 4px solid #0073aa;
    border-radius: 0 4px 4px 0;
}

.product-shipping-class .freight-notice {
    color: #d63638;
    font-weight: 600;
    font-size: 0.9em;
}

/* ============================================================================
   BODY CLASS OVERRIDES (when freight item in cart)
   ============================================================================ */

/* Hide shipping row when freight is present */
body.has-freight-item .woocommerce-shipping-totals {
    display: none !important;
}

/* Hide shipping calculator */
body.has-freight-item .shipping-calculator-form,
body.has-freight-item .woocommerce-shipping-calculator {
    display: none !important;
}

/* Hide "Shipping will be calculated" message */
body.has-freight-item .woocommerce-shipping-destination {
    display: none !important;
}

/* ============================================================================
   ANIMATION KEYFRAMES
   ============================================================================ */

/* Overlay fade in */
@keyframes fadeInOverlay {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Overlay fade out */
@keyframes fadeOutOverlay {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* Content fade in with scale */
@keyframes fadeInContent {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Content fade out with scale */
@keyframes fadeOutContent {
    from {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    to {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
}

/* Legacy fadeIn for compatibility */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

@media screen and (max-width: 768px) {
    .freight-banner {
        flex-direction: column;
        padding: 20px;
        gap: 12px;
    }

    .freight-banner-text {
        min-width: auto;
    }

    .freight-banner a.freight-quote-trigger {
        width: 100%;
        text-align: center;
    }

    .freight-modal {
        padding: 10px;
    }

    .freight-modal-content {
        padding: 25px 20px;
        margin: 10px auto;
    }

    .freight-modal-content h2 {
        font-size: 22px;
    }

    .freight-close {
        top: 10px;
        right: 10px;
        font-size: 28px;
    }

    .freight-form-row input[type="text"],
    .freight-form-row input[type="email"],
    .freight-form-row input[type="tel"],
    .freight-form-row textarea,
    .freight-form-row select {
        padding: 10px 12px;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    .freight-form-submit input[type="submit"],
    input.freight-submit-btn,
    .freight-modal-content .wpcf7-form input[type="submit"] {
        padding: 14px 24px !important;
        font-size: 16px !important;
    }
}

@media screen and (max-width: 480px) {
    .freight-modal {
        padding: 5px;
    }

    .freight-modal-content {
        padding: 20px 15px;
        margin: 5px auto;
    }

    .freight-modal-content h2 {
        font-size: 20px;
        padding-right: 35px;
    }

    .freight-form-row {
        margin-bottom: 14px;
    }

    .freight-form-row-half {
        flex-direction: column;
        gap: 0;
    }

    .freight-form-row-half .freight-form-col {
        margin-bottom: 14px;
    }

    .freight-form-turnstile {
        margin: 15px 0;
    }

    .freight-form-turnstile iframe {
        transform: scale(0.9);
        transform-origin: center;
    }
}

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

@media print {
    .freight-banner,
    .freight-modal {
        display: none !important;
    }
}
/* ============================================================================
   TWO-COLUMN FORM LAYOUT
   ============================================================================ */

.freight-form-row-half {
    display: flex;
    gap: 15px;
}

.freight-form-row-half .freight-form-col {
    flex: 1;
}

.freight-form-row-half .freight-form-col label {
    display: block;
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
    font-size: 14px;
}

.freight-form-row-half .freight-form-col input,
.freight-form-row-half .freight-form-col select {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 15px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    box-sizing: border-box;
}

.freight-form-row-half .freight-form-col input:focus,
.freight-form-row-half .freight-form-col select:focus {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.15);
}

/* ============================================================================
   MODAL SCROLL FIX - OVERRIDE
   ============================================================================ */

.freight-modal {
    display: none;
}

.freight-modal[style*="display: flex"],
.freight-modal[style*="display:flex"] {
    display: flex !important;
    flex-direction: column !important;
    overflow-y: scroll !important;
    -webkit-overflow-scrolling: touch !important;
}

.freight-modal-content {
    flex-shrink: 0 !important;
    margin: 40px auto !important;
}