/**
 * Tire Finder CSS
 * Styles for the tire finder form and components
 */

/* Container Styles */
.tire-finder-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background-color: #f8f8f8;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s;
    position: relative;
}

.tire-finder-container:hover {
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.tire-finder-container::before {
    content: "";
    display: block;
    height: 4px;
    width: 100%;
    background-color: #ad2f2f;
    position: absolute;
    top: 0;
    left: 0;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

/* Form Layout */
.tire-finder-form {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
    justify-content: space-between;
}

/* Dropdown Wrapper */
.tire-finder-dropdown-wrapper {
    flex: 1 1 0;
    min-width: 150px;
    position: relative;
    width: calc(33.33% - 10px);
}

.tire-finder-dropdown-wrapper label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
    transition: color 0.2s;
}

.tire-finder-dropdown-wrapper:focus-within label {
    color: #ad2f2f;
}

/* Dropdown Select */
.tire-finder-dropdown {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #fff;
    font-size: 16px;
    color: #333;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="6" viewBox="0 0 12 6"><path d="M0 0l6 6 6-6z" fill="%23ad2f2f"/></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    cursor: pointer;
}

.tire-finder-dropdown:hover:not(:disabled) {
    border-color: #ad2f2f;
}

.tire-finder-dropdown:focus {
    outline: 0;
    border-color: #ad2f2f;
    box-shadow: 0 0 0 3px rgba(173, 47, 47, 0.2);
}

.tire-finder-dropdown:disabled {
    background-color: #f5f5f5;
    color: #999;
    cursor: not-allowed;
}

/* Button Styling */
.tire-finder-button {
    padding: 12px 24px;
    background-color: #ad2f2f;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 4px rgba(173, 47, 47, 0.2);
    text-align: center;
}

.tire-finder-button:hover {
    background-color: #901f1f;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(173, 47, 47, 0.3);
}

.tire-finder-button:focus {
    outline: 0;
    box-shadow: 0 0 0 3px rgba(173, 47, 47, 0.3);
}

.tire-finder-button:active {
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(173, 47, 47, 0.3);
}

.tire-finder-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Override theme styling for all button states */
button.tire-finder-button,
.button.tire-finder-button,
.wp-block-button__link.tire-finder-button,
.wp-element-button.tire-finder-button,
input[type="button"].tire-finder-button,
input[type="reset"].tire-finder-button,
input[type="submit"].tire-finder-button,
.tire-finder-button:active,
.tire-finder-button:focus,
.tire-finder-button:visited,
.tire-finder-button:focus-visible,
.tire-finder-button:focus-within,
.tire-finder-button:target,
.tire-finder-button:link:active {
    background: #901f1f !important;
    background-color: #901f1f !important;
    outline: none !important;
    box-shadow: none !important;
    color: white !important;
    border-color: transparent !important;
    --global-palette-btn-bg: #901f1f !important;
}

/* Loader Animation */
.tire-finder-loader {
    display: inline-block;
    width: 20px;
    height: 20px;
    position: absolute;
    right: 40px;
    top: 50%;
    margin-top: -2px;
    border: 2px solid rgba(173, 47, 47, 0.2);
    border-top-color: #ad2f2f;
    border-radius: 50%;
    animation: tire-finder-spin 1s linear infinite;
}

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

/* Message Styling */
.tire-finder-message {
    width: 100%;
    margin-top: 15px;
    padding: 10px 15px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tire-finder-message.error {
    background-color: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

.tire-finder-message.success {
    background-color: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

/* Custom Select Styling */
.tire-finder-custom-select {
    position: relative;
    width: 100%;
    user-select: none;
}

.tire-finder-custom-select-trigger {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    font-size: 16px;
    color: #333;
    background: #ffffff;
    cursor: pointer;
    border: 1px solid #ddd;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.tire-finder-custom-select-trigger:hover {
    border-color: #ad2f2f;
}

.tire-finder-custom-select-trigger:after {
    content: '';
    position: relative;
    width: 10px;
    height: 10px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="6" viewBox="0 0 12 6"><path d="M0 0l6 6 6-6z" fill="%23ad2f2f"/></svg>');
    background-repeat: no-repeat;
    background-position: center;
    transition: transform 0.3s ease;
}

.tire-finder-custom-select.open .tire-finder-custom-select-trigger:after {
    transform: rotate(180deg);
}

.tire-finder-custom-options {
    position: absolute;
    display: block;
    top: 100%;
    left: 0;
    right: 0;
    border: 1px solid #ddd;
    border-top: 0;
    background: #fff;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: 2;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
    max-height: 300px;
    overflow-y: auto;
    transform: translateY(-10px);
    transition: all 0.2s ease-in-out;
}

.tire-finder-custom-select.open .tire-finder-custom-options {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
    transform: translateY(0);
}

.tire-finder-custom-option {
    position: relative;
    display: block;
    padding: 12px 15px;
    font-size: 16px;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tire-finder-custom-option:hover {
    background: #f8f8f8;
    color: #ad2f2f;
}

.tire-finder-custom-option.selected {
    background: #f0f0f0;
    color: #ad2f2f;
    font-weight: 600;
}

.tire-finder-custom-option.disabled {
    color: #ccc;
    cursor: not-allowed;
}

/* Animation for dropdown */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tire-finder-custom-select.open .tire-finder-custom-options {
    animation: fadeInDown 0.3s ease-in-out;
}

/* Responsive Styles */
@media (max-width: 768px) {
    .tire-finder-container {
        border-radius: 4px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        background-color: #f8f8f8;
        padding: 20px 15px;
        margin: 0 auto;
        max-width: 100%;
        width: 100%;
    }
    
    .tire-finder-container::before {
        border-radius: 4px 4px 0 0;
    }
    
    .tire-finder-form {
        flex-direction: column;
        gap: 10px;
        align-items: center;
        width: 100%;
    }
    
    .tire-finder-dropdown-wrapper {
        width: 100%;
        min-width: 100%;
        position: relative;
        margin-bottom: 15px;
    }
    
    .tire-finder-dropdown-wrapper label {
        font-size: 16px;
        margin-bottom: 10px;
        font-weight: 600;
    }
    
    .tire-finder-dropdown {
        height: 48px;
        padding: 0 15px;
        font-size: 16px;
        background-size: 14px;
        background-position: right 15px center;
    }
    
    .tire-finder-custom-select-trigger {
        padding: 15px;
        font-size: 16px;
        height: 48px;
    }
    
    .tire-finder-custom-options {
        max-height: 50vh;
    }
    
    .tire-finder-custom-option {
        padding: 16px 15px;
        font-size: 16px;
    }
    
    .tire-finder-button {
        width: 100%;
        margin: 5px auto 5px;
        padding: 15px 20px;
        border-radius: 6px;
        font-size: 18px;
        letter-spacing: 0.5px;
        box-shadow: 0 4px 6px rgba(173, 47, 47, 0.25);
        text-transform: uppercase;
        text-align: center;
        display: block;
        height: 52px;
    }
    
    .tire-finder-button:active {
        transform: translateY(2px);
        box-shadow: 0 1px 2px rgba(173, 47, 47, 0.2);
    }
    
    .tire-finder-loader {
        right: 30px;
        width: 24px;
        height: 24px;
    }
    
    .tire-finder-message {
        margin-top: 20px;
        padding: 15px;
        border-radius: 8px;
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    .tire-finder-container {
        width: 100%;
        padding: 30px 15px;
        margin: 0 auto;
        border-radius: 4px;
        max-width: 100%;
    }
    
    .tire-finder-dropdown-wrapper {
        margin-bottom: 15px;
    }
    
    .tire-finder-dropdown-wrapper label {
        font-size: 16px;
        margin-bottom: 10px;
        font-weight: 600;
    }
    
    .tire-finder-dropdown {
        height: 52px;
        padding: 0 15px;
        font-size: 17px;
    }
    
    .tire-finder-button {
        margin-top: 5px;
        margin-bottom: 5px;
        padding: 16px;
        font-size: 18px;
        border-radius: 8px;
        height: 56px;
    }
    
    /* Increase the size of the dropdown arrow for better visibility */
    .tire-finder-dropdown {
        background-size: 16px;
        background-position: right 15px center;
    }
}