/**
 * Dealer Locator Frontend Styles
 * Ecotune Dark Theme
 *
 * @author Kile Thomson
 */

/* Container */
.tcl-dealer-locator {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--tcl-bg-dark);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 100%;
}

/* Logo spacing */
.tcl-locator-logo {
    padding: 20px 20px 0 20px;
}

.tcl-locator-logo img {
    max-height: 50px;
}

/* Search Bar */
.tcl-locator-search {
    padding: 16px 20px;
    background: var(--tcl-bg-card);
    border-bottom: 1px solid var(--tcl-bg-lighter);
}

.tcl-search-row {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.tcl-search-input-wrap {
    flex: 1;
    min-width: 200px;
    position: relative;
    display: flex;
    align-items: center;
}

.tcl-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--tcl-gray-light);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.tcl-search-input {
    width: 100%;
    padding: 12px 44px 12px 44px;
    background: var(--tcl-bg-dark) !important;
    border: 2px solid var(--tcl-bg-lighter);
    border-radius: 10px;
    color: var(--tcl-white) !important;
    font-size: 14px;
    transition: border-color 0.2s;
    -webkit-text-fill-color: var(--tcl-white) !important;
    position: relative;
    z-index: 1;
}

.tcl-search-input:focus {
    outline: none;
    border-color: var(--tcl-primary);
    background: var(--tcl-bg-dark) !important;
    color: var(--tcl-white) !important;
    -webkit-text-fill-color: var(--tcl-white) !important;
}

.tcl-search-input::placeholder {
    color: #b0b0b0 !important;
    -webkit-text-fill-color: #b0b0b0 !important;
    opacity: 1 !important;
    font-weight: 400;
}

/* Ensure search type input doesn't show browser clear button weirdly */
.tcl-search-input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
}

/* Override browser autofill styles */
.tcl-search-input:-webkit-autofill,
.tcl-search-input:-webkit-autofill:hover,
.tcl-search-input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--tcl-bg-dark) inset !important;
    -webkit-text-fill-color: var(--tcl-white) !important;
    background-color: var(--tcl-bg-dark) !important;
    color: var(--tcl-white) !important;
}

.tcl-search-btn {
    position: absolute;
    right: 4px;
    padding: 8px 12px;
    background: var(--tcl-primary);
    border: none;
    border-radius: 8px;
    color: var(--tcl-white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.tcl-search-btn:hover {
    background: var(--tcl-primary-dark);
}

.tcl-location-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--tcl-bg-lighter);
    border: 2px solid #4a4a4a;
    border-radius: 10px;
    color: var(--tcl-white);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.tcl-location-btn:hover {
    background: #4a4a4a;
    border-color: var(--tcl-primary);
}

.tcl-location-btn.loading {
    opacity: 0.7;
    pointer-events: none;
}

.tcl-location-btn svg {
    flex-shrink: 0;
}

.tcl-category-filter,
.tcl-radius-select {
    padding: 12px 16px;
    background: var(--tcl-bg-dark);
    border: 2px solid var(--tcl-bg-lighter);
    border-radius: 10px;
    color: var(--tcl-white);
    font-size: 13px;
    cursor: pointer;
    min-width: 100px;
}

.tcl-category-filter:focus,
.tcl-radius-select:focus {
    outline: none;
    border-color: var(--tcl-primary);
}

.tcl-keyword-wrap {
    flex: 0 0 180px;
}

.tcl-keyword-input {
    width: 100%;
    padding: 12px 14px;
    background: var(--tcl-bg-dark);
    border: 2px solid var(--tcl-bg-lighter);
    border-radius: 10px;
    color: var(--tcl-white);
    font-size: 14px;
    transition: border-color 0.2s;
}

.tcl-keyword-input:focus {
    outline: none;
    border-color: var(--tcl-primary);
}

.tcl-keyword-input::placeholder {
    color: var(--tcl-gray);
}

.tcl-reset-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 16px;
    background: #4a4a4a;
    border: 2px solid #5a5a5a;
    border-radius: 10px;
    color: var(--tcl-white);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.tcl-reset-btn:hover {
    background: #5a5a5a;
    border-color: var(--tcl-primary);
}

.tcl-reset-btn svg {
    flex-shrink: 0;
}

/* Map Container */
.tcl-locator-map-container {
    position: relative;
    background: var(--tcl-bg-dark);
}

.tcl-locator-map {
    width: 100%;
    min-height: 400px;
    background: var(--tcl-bg-dark);
}

.tcl-locator-error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 300px;
    background: var(--tcl-bg-card);
    color: var(--tcl-gray-light);
    text-align: center;
    padding: 20px;
}

/* Results List */
.tcl-locator-results {
    background: var(--tcl-bg-card);
}

.tcl-results-header {
    padding: 14px 20px;
    border-top: 1px solid var(--tcl-bg-lighter);
    border-bottom: 1px solid var(--tcl-bg-lighter);
}

.tcl-results-count {
    color: var(--tcl-gray-light);
    font-size: 13px;
    font-weight: 500;
}

.tcl-results-list {
    max-height: min(400px, 60vh);
    overflow-y: auto;
}

.tcl-results-list::-webkit-scrollbar {
    width: 8px;
}

.tcl-results-list::-webkit-scrollbar-track {
    background: var(--tcl-bg-dark);
}

.tcl-results-list::-webkit-scrollbar-thumb {
    background: #4a4a4a;
    border-radius: 4px;
}

.tcl-results-list::-webkit-scrollbar-thumb:hover {
    background: #5a5a5a;
}

/* Dealer Card */
.tcl-dealer-card {
    display: flex;
    gap: 16px;
    padding: 20px;
    border-bottom: 1px solid var(--tcl-bg-lighter);
    cursor: pointer;
    transition: background-color 0.2s;
}

.tcl-dealer-card:hover,
.tcl-dealer-card.active {
    background: var(--tcl-bg-lighter);
}

.tcl-dealer-card:last-child {
    border-bottom: none;
}

.tcl-dealer-logo {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    border-radius: 10px;
    background: var(--tcl-bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.tcl-dealer-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tcl-dealer-logo-placeholder {
    width: 28px;
    height: 28px;
    color: #4a4a4a;
}

.tcl-dealer-info {
    flex: 1;
    min-width: 0;
}

.tcl-dealer-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 6px;
}

.tcl-dealer-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--tcl-white);
    margin: 0;
}

.tcl-dealer-distance {
    font-size: 12px;
    color: var(--tcl-success);
    font-weight: 600;
    white-space: nowrap;
    background: rgba(16, 185, 129, 0.15);
    padding: 4px 10px;
    border-radius: 20px;
}

.tcl-dealer-address {
    font-size: 13px;
    color: var(--tcl-gray-light);
    margin: 0 0 10px;
    line-height: 1.4;
}

.tcl-dealer-contact {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
}

.tcl-dealer-contact a {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--tcl-gray-light);
    text-decoration: none;
    transition: color 0.2s;
}

.tcl-dealer-contact a:hover {
    color: var(--tcl-primary);
}

.tcl-dealer-contact svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.tcl-dealer-actions {
    display: flex;
    gap: 10px;
}

.tcl-dealer-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
}

.tcl-dealer-btn-directions {
    background: var(--tcl-primary);
    color: var(--tcl-white);
}

.tcl-dealer-btn-directions:hover {
    background: var(--tcl-primary-dark);
    color: var(--tcl-white);
}

.tcl-dealer-btn-website {
    background: #3a3a3a;
    color: var(--tcl-white);
    border: 1px solid #4a4a4a;
}

.tcl-dealer-btn-website:hover {
    background: #4a4a4a;
    color: var(--tcl-white);
}

.tcl-dealer-btn-call {
    background: var(--tcl-success);
    color: var(--tcl-white);
}

.tcl-dealer-btn-call:hover {
    background: #059669;
    color: var(--tcl-white);
}

.tcl-dealer-btn-email {
    background: #3b82f6;
    color: var(--tcl-white);
}

.tcl-dealer-btn-email:hover {
    background: #2563eb;
    color: var(--tcl-white);
}

.tcl-dealer-btn-store {
    background: #8b5cf6;
    color: var(--tcl-white);
}

.tcl-dealer-btn-store:hover {
    background: #7c3aed;
    color: var(--tcl-white);
}

.tcl-dealer-btn svg {
    width: 14px;
    height: 14px;
}

.tcl-dealer-description {
    font-size: 13px;
    color: var(--tcl-gray-light);
    margin: 8px 0 0 0;
    line-height: 1.5;
}

.tcl-dealer-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.tcl-dealer-category {
    display: inline-block;
    padding: 4px 10px;
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    border-radius: 4px;
}

/* Info window description */
.tcl-info-description {
    font-size: 12px;
    color: var(--tcl-gray-light);
    margin: 8px 0;
    line-height: 1.4;
}

/* Empty State */
.tcl-no-results {
    text-align: center;
    padding: 40px 20px;
    color: var(--tcl-gray);
}

.tcl-no-results svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.tcl-no-results h4 {
    color: var(--tcl-gray-light);
    margin: 0 0 8px;
}

.tcl-no-results p {
    margin: 0;
    font-size: 13px;
}

/* Map Info Window - Dark Ecotune Theme */
.gm-style .gm-style-iw-c {
    background: var(--tcl-bg-dark) !important;
    border-radius: 12px !important;
    padding: 0 !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5) !important;
}

.gm-style .gm-style-iw-d {
    overflow: auto !important;
}

.gm-style .gm-style-iw-tc::after {
    background: var(--tcl-bg-dark) !important;
}

/* Close button styling */
.gm-style .gm-style-iw-c button[aria-label="Close"] {
    top: 8px !important;
    right: 8px !important;
    width: 28px !important;
    height: 28px !important;
    background: var(--tcl-bg-card) !important;
    border-radius: 50% !important;
    opacity: 1 !important;
}

.gm-style .gm-style-iw-c button[aria-label="Close"] span {
    background-color: var(--tcl-gray-light) !important;
}

.gm-style .gm-style-iw-c button[aria-label="Close"]:hover {
    background: var(--tcl-bg-lighter) !important;
}

.gm-style .gm-style-iw-c button[aria-label="Close"]:hover span {
    background-color: var(--tcl-white) !important;
}

.tcl-info-window {
    max-width: 300px;
    padding: 16px;
    background: var(--tcl-bg-dark);
}

.tcl-info-logo {
    margin-bottom: 12px;
    text-align: center;
}

.tcl-info-logo img {
    max-width: 120px;
    max-height: 60px;
    object-fit: contain;
    border-radius: 6px;
}

.tcl-info-window h4 {
    margin: 0 0 10px;
    font-size: 16px;
    font-weight: 600;
    color: var(--tcl-white);
}

.tcl-info-window p {
    margin: 0 0 10px;
    font-size: 13px;
    color: var(--tcl-gray-light);
    line-height: 1.5;
}

.tcl-info-window .tcl-info-contact {
    font-size: 13px;
    color: var(--tcl-gray);
    margin-bottom: 12px;
}

.tcl-info-window .tcl-info-contact a {
    color: var(--tcl-primary);
    text-decoration: none;
    transition: color 0.2s;
}

.tcl-info-window .tcl-info-contact a:hover {
    color: var(--tcl-primary-light);
}

.tcl-info-window .tcl-info-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.tcl-info-window .tcl-info-btn {
    display: inline-block;
    padding: 8px 14px;
    background: var(--tcl-primary);
    color: var(--tcl-white);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.2s;
}

.tcl-info-window .tcl-info-btn:hover {
    background: var(--tcl-primary-dark);
    color: var(--tcl-white);
}

.tcl-info-window .tcl-info-btn-directions {
    background: var(--tcl-primary);
}

.tcl-info-window .tcl-info-btn-website {
    background: #3b82f6;
}

.tcl-info-window .tcl-info-btn-website:hover {
    background: #2563eb;
}

.tcl-info-window .tcl-info-btn-store {
    background: var(--tcl-success);
}

.tcl-info-window .tcl-info-btn-store:hover {
    background: #059669;
}

.tcl-info-window .tcl-info-btn-call {
    background: var(--tcl-success);
}

.tcl-info-window .tcl-info-btn-call:hover {
    background: #059669;
}

/* Loading State */
.tcl-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px;
    color: var(--tcl-gray-light);
}

.tcl-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--tcl-bg-lighter);
    border-top-color: var(--tcl-primary);
    border-radius: 50%;
    animation: tcl-spin 0.8s linear infinite;
}

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

/* Responsive */
@media (max-width: 768px) {
    .tcl-dealer-locator {
        border-radius: 0;
        margin-left: calc(-1 * (100vw - 100%) / 2);
        margin-right: calc(-1 * (100vw - 100%) / 2);
        width: 100vw;
        max-width: 100vw;
    }

    .tcl-search-row {
        flex-direction: column;
    }

    .tcl-search-input-wrap {
        width: 100%;
        min-width: 0;
    }

    .tcl-location-btn {
        width: 100%;
        justify-content: center;
    }

    .tcl-location-btn span {
        display: inline;
    }

    .tcl-radius-select {
        width: 100%;
    }

    .tcl-dealer-card {
        flex-direction: column;
    }

    .tcl-dealer-logo {
        width: 50px;
        height: 50px;
    }

    .tcl-dealer-header {
        flex-direction: column;
        gap: 8px;
    }

    .tcl-dealer-actions {
        flex-direction: column;
    }

    .tcl-dealer-btn {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .tcl-locator-search {
        padding: 12px 16px;
    }

    .tcl-dealer-card {
        padding: 16px;
        gap: 12px;
    }

    .tcl-results-list {
        max-height: min(300px, 50vh);
    }
}

/* Footer / Cross-page Links */
.tcl-locator-footer {
    padding: 16px 20px;
    background: var(--tcl-bg-dark);
    border-top: 1px solid var(--tcl-bg-lighter);
    text-align: center;
}

.tcl-tuning-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 24px;
    background: linear-gradient(135deg, var(--tcl-primary) 0%, var(--tcl-primary-dark) 100%);
    border-radius: 10px;
    color: var(--tcl-white);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.tcl-tuning-link:hover {
    background: linear-gradient(135deg, var(--tcl-primary-light) 0%, var(--tcl-primary) 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(220, 38, 38, 0.4);
    color: var(--tcl-white);
}

.tcl-tuning-link svg {
    flex-shrink: 0;
}

.tcl-tuning-link svg:last-child {
    transition: transform 0.2s ease;
}

.tcl-tuning-link:hover svg:last-child {
    transform: translateX(4px);
}
