/**
 * Used Parts Quote Frontend Styles
 * 
 * Responsive, mobile-friendly styling for the quote request form
 */

/* Container and Form Layout */
.upq-form-container {
    width: 100%;
    max-width: none; /* Remove fixed max-width to be container responsive */
    margin: 0;
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    box-sizing: border-box;
}

.upq-form-title {
    margin: 0 0 30px 0;
    font-size: clamp(20px, 4vw, 28px); /* Responsive font size */
    font-weight: 600;
    color: #333;
    text-align: center;
    border-bottom: 3px solid #0073aa;
    padding-bottom: 15px;
}

.upq-form {
    width: 100%;
}

/* Form Rows and Groups */
.upq-form-row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -10px 20px -10px;
    width: 100%;
}

.upq-form-group {
    padding: 0 10px;
    margin-bottom: 20px;
    position: relative;
    box-sizing: border-box;
}

.upq-form-group.upq-half {
    flex: 1 1 300px; /* More flexible minimum width */
    min-width: 0; /* Allow shrinking */
}

.upq-form-group.upq-full {
    flex: 1 1 100%;
    width: 100%;
}

/* Labels */
.upq-form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.upq-form-group label .required {
    color: #d63638;
    margin-left: 3px;
}

/* Form Controls */
.upq-form input[type="text"],
.upq-form input[type="tel"],
.upq-form input[type="email"],
.upq-form select,
.upq-form textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: clamp(14px, 2vw, 16px); /* Responsive font size */
    line-height: 1.4;
    background-color: #fff;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    box-sizing: border-box;
}

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

.upq-form select {
    background-image: url('data:image/svg+xml;charset=US-ASCII,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><path fill="%23666" d="M5 8l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 16px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding-right: 50px;
}

.upq-form select:disabled {
    background-color: #f7f7f7;
    color: #666;
    cursor: not-allowed;
}

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

/* Placeholders */
.upq-form input::placeholder,
.upq-form textarea::placeholder {
    color: #999;
    opacity: 1;
}

/* Loading Indicator */
.upq-loading {
    display: none;
    padding: 8px 0;
    color: #666;
    font-size: 14px;
    font-style: italic;
    text-align: center;
}

.upq-loading:before {
    content: "";
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #ddd;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: upq-spin 1s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

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

/* Submit Button */
.upq-submit-btn {
    display: inline-block;
    width: 100%;
    padding: 16px 24px;
    background: linear-gradient(135deg, #0073aa 0%, #005a87 100%);
    border: none;
    border-radius: 6px;
    color: #fff;
    font-size: clamp(16px, 2.5vw, 18px); /* Responsive font size */
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    min-height: 56px;
    box-sizing: border-box;
}

.upq-submit-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #005a87 0%, #004466 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.3);
}

.upq-submit-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.upq-submit-loading {
    display: none;
    position: relative;
}

.upq-submit-loading:before {
    content: "";
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid #fff;
    border-radius: 50%;
    animation: upq-spin 1s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

/* Messages */
.upq-messages {
    margin: 20px 0;
    padding: 15px 20px;
    border-radius: 6px;
    font-size: clamp(14px, 2vw, 16px); /* Responsive font size */
    line-height: 1.5;
}

.upq-messages.upq-message-success {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.upq-messages.upq-message-error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.upq-messages.upq-message-warning {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
}

.upq-messages.upq-message-info {
    background-color: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

.upq-messages p {
    margin: 0;
}

/* Field Validation */
.upq-form input.upq-error,
.upq-form select.upq-error,
.upq-form textarea.upq-error {
    border-color: #d63638;
    box-shadow: 0 0 0 3px rgba(214, 54, 56, 0.1);
}

.upq-field-error {
    display: block;
    margin-top: 5px;
    color: #d63638;
    font-size: 14px;
    font-weight: 500;
}

/* Success Animation */
.upq-messages.upq-message-success {
    animation: upq-slideIn 0.5s ease-out;
}

@keyframes upq-slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .upq-form-container {
        padding: 15px;
        border-radius: 6px;
    }
    
    .upq-form-title {
        margin-bottom: 20px;
    }
    
    .upq-form-row {
        flex-direction: column;
        margin: 0 0 15px 0;
    }
    
    .upq-form-group {
        padding: 0;
        margin-bottom: 15px;
    }
    
    .upq-form-group.upq-half {
        flex: 1 1 100%;
    }
    
    .upq-form input[type="text"],
    .upq-form input[type="tel"],
    .upq-form input[type="email"],
    .upq-form select,
    .upq-form textarea {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .upq-submit-btn {
        padding: 14px 20px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .upq-form-container {
        padding: 10px;
    }
    
    .upq-form-title {
        margin-bottom: 15px;
    }
    
    .upq-form input[type="text"],
    .upq-form input[type="tel"],
    .upq-form input[type="email"],
    .upq-form select,
    .upq-form textarea {
        padding: 10px 12px;
    }
    
    .upq-submit-btn {
        padding: 12px 16px;
    }
}

/* Container Queries Support (for modern browsers) */
@container (max-width: 600px) {
    .upq-form-row {
        flex-direction: column;
    }
    
    .upq-form-group.upq-half {
        flex: 1 1 100%;
    }
}

/* Accessibility Improvements */
.upq-form input:focus,
.upq-form select:focus,
.upq-form textarea:focus,
.upq-submit-btn:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .upq-form input[type="text"],
    .upq-form input[type="tel"],
    .upq-form input[type="email"],
    .upq-form select,
    .upq-form textarea {
        border-width: 3px;
    }
    
    .upq-submit-btn {
        border: 2px solid #000;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .upq-form input[type="text"],
    .upq-form input[type="tel"],
    .upq-form input[type="email"],
    .upq-form select,
    .upq-form textarea,
    .upq-submit-btn {
        transition: none;
    }
    
    @keyframes upq-spin {
        0% { transform: rotate(0deg); }
        100% { transform: rotate(0deg); }
    }
}

/* Print Styles */
@media print {
    .upq-form-container {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .upq-submit-btn {
        display: none;
    }
    
    .upq-loading {
        display: none;
    }
}

/* Dark Theme Support */
@media (prefers-color-scheme: dark) {
    .upq-form-container {
        background: #1a1a1a;
        color: #e0e0e0;
    }
    
    .upq-form-title {
        color: #e0e0e0;
        border-bottom-color: #0073aa;
    }
    
    .upq-form-group label {
        color: #e0e0e0;
    }
    
    .upq-form input[type="text"],
    .upq-form input[type="tel"],
    .upq-form input[type="email"],
    .upq-form select,
    .upq-form textarea {
        background-color: #2a2a2a;
        border-color: #444;
        color: #e0e0e0;
    }
    
    .upq-form input[type="text"]:focus,
    .upq-form input[type="tel"]:focus,
    .upq-form input[type="email"]:focus,
    .upq-form select:focus,
    .upq-form textarea:focus {
        border-color: #0073aa;
        box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.3);
    }
    
    .upq-form select:disabled {
        background-color: #1a1a1a;
        color: #666;
    }
    
    .upq-form input::placeholder,
    .upq-form textarea::placeholder {
        color: #999;
    }

    /* Choices.js Dark Theme Adjustments */
    .upq-choices-container .choices__inner {
        background-color: #2a2a2a !important;
        border-color: #444 !important;
        color: #e0e0e0 !important;
    }
    .upq-choices-container .choices__placeholder {
        color: #999 !important;
    }
    .upq-choices-container.is-open .choices__inner {
        border-color: var(--upq-primary-color, #0073aa) !important;
    }
    .upq-choices-container .choices__list--dropdown, 
    .upq-choices-container .choices__list[aria-expanded] {
        background-color: #2a2a2a !important;
        border-color: #444 !important;
    }
    .upq-choices-container .choices__list--dropdown .choices__item--selectable.is-highlighted, 
    .upq-choices-container .choices__list[aria-expanded] .choices__item--selectable.is-highlighted {
        background-color: var(--upq-primary-color, #0073aa) !important;
        color: white !important;
    }
    .upq-choices-container .choices__list--dropdown .choices__item, 
    .upq-choices-container .choices__list[aria-expanded] .choices__item {
        color: #e0e0e0 !important;
    }
    .upq-choices-container .choices__input {
        background-color: #333 !important; /* Darker search input background */
        color: #e0e0e0 !important;
        border-color: #555 !important;
    }
}

/* Choices.js Custom Styling to Match Original Form Fields */
.upq-choices-container {
    width: 100% !important;
    position: relative; 
    font-size: clamp(14px, 2vw, 16px); 
}

.upq-choices-inner {
    background-color: #fff;
    border: 2px solid #ddd;
    border-radius: 6px;
    padding: 0;
    width: 100%;
    min-height: 48px;
    overflow: hidden; 
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    position: relative;
}

.upq-choices-list-single .upq-choices-item,
.upq-choices-placeholder {
    padding: 12px 40px 12px 16px;
    width: 100%;
    color: #333;
    line-height: 1.4; 
    box-sizing: border-box;
    margin: 0; 
    opacity: 1; 
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.upq-choices-placeholder {
     color: #999; 
}

/* Custom Dropdown Arrow */
.upq-choices-inner::after {
    content: '';
    background-image: url('data:image/svg+xml;charset=US-ASCII,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><path fill="%23666" d="M5 8l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: center center;
    background-size: 16px;
    width: 24px;
    height: 100%;
    position: absolute;
    right: 8px;
    top: 0;
    pointer-events: none; 
    transition: transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upq-choices-container.upq-is-open .upq-choices-inner::after {
    transform: rotate(180deg);
}

/* Focus State */
.upq-choices-container.upq-is-focused .upq-choices-inner,
.upq-choices-container.upq-is-open .upq-choices-inner {
    border-color: var(--upq-primary-color, #0073aa) !important;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1) !important; 
    outline: none !important;
}

/* Dropdown List Panel */
.upq-choices-list-dropdown {
    display: none !important; /* CRITICAL: Ensure hidden by default, overriding others */
    position: absolute; 
    background-color: #fff;
    border: 2px solid var(--upq-primary-color, #0073aa);
    border-top: none; 
    border-radius: 0 0 6px 6px;
    left: 0;
    right: 0;
    top: 100%; 
    z-index: 100; 
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    max-height: 250px; 
    overflow-y: auto;
}

.upq-choices-container.upq-is-open .upq-choices-list-dropdown {
    display: block !important; /* CRITICAL: Show when open state is active, overriding others */
}

/* Search Input within Dropdown */
.upq-choices-list-dropdown .upq-choices-input {
    display: block !important; 
    visibility: visible !important; 
    opacity: 1 !important; 
    border: 1px solid #ddd !important; 
    background-color: #fff !important; 
    color: #333 !important; 
    padding: 10px 12px !important;
    margin: 8px !important; 
    width: calc(100% - 16px) !important; 
    min-height: auto !important; 
    height: auto !important; 
    line-height: normal !important; 
    font-size: 14px !important; 
    border-radius: 4px !important;
    box-sizing: border-box !important;
    position: static !important; 
    transform: none !important;
}

.upq-choices-list-dropdown .upq-choices-input:focus {
    border-color: var(--upq-primary-color, #0073aa) !important;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.1) !important; 
    outline: none !important;
}

/* Dropdown Items */
.upq-choices-list-dropdown .upq-choices-item,
.upq-choices-list-dropdown .upq-choices-item-selectable {
    padding: 10px 16px !important;
    color: #333;
}

.upq-choices-list-dropdown .upq-choices-item-selectable.upq-is-highlighted {
    background-color: var(--upq-primary-color, #0073aa) !important;
    color: white !important;
}

/* Loader and messages */
.upq-choices-container.upq-is-loading .upq-choices-inner::after {
    display: none; 
}
.upq-choices-container.upq-is-loading .upq-choices-list-single .upq-choices-item {
    opacity: 0.5;
}

/* Dark Theme Adjustments */
@media (prefers-color-scheme: dark) {
    .upq-choices-inner { 
        background-color: #2a2a2a !important;
        border-color: #444 !important;
        color: #e0e0e0 !important;
    }
    .upq-choices-inner::after {
         background-image: url('data:image/svg+xml;charset=US-ASCII,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><path fill="%23999" d="M5 8l5 5 5-5z"/></svg>') !important;
    }
    .upq-choices-placeholder {
        color: #999 !important;
    }
    .upq-choices-list-single .upq-choices-item,
    .upq-choices-placeholder {
        color: #e0e0e0 !important;
    }
    .upq-choices-container.upq-is-open .upq-choices-inner,
    .upq-choices-container.upq-is-focused .upq-choices-inner {
        border-color: var(--upq-primary-color, #0073aa) !important;
    }
    .upq-choices-list-dropdown {
        background-color: #2a2a2a !important;
        border-color: var(--upq-primary-color, #444) !important; 
        box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    }
    .upq-choices-list-dropdown .upq-choices-item-selectable.upq-is-highlighted {
        background-color: var(--upq-primary-color, #0073aa) !important;
        color: white !important;
    }
    .upq-choices-list-dropdown .upq-choices-item,
    .upq-choices-list-dropdown .upq-choices-item-selectable {
        color: #e0e0e0 !important;
    }
    .upq-choices-list-dropdown .upq-choices-input {
        background-color: #333 !important; 
        color: #e0e0e0 !important;
        border-color: #555 !important;
    }
} 