/**
 * WooCommerce Google Maps Route Widget
 * Frontend Styles
 */

/* Container */
.wc-gmaps-route-container {
    position: relative;
    font-family: inherit;
    box-sizing: border-box;
}

.wc-gmaps-route-container *,
.wc-gmaps-route-container *::before,
.wc-gmaps-route-container *::after {
    box-sizing: border-box;
}

/* Title and Description */
.wc-gmaps-route-title {
    margin: 0 0 10px 0;
    font-size: 1.5em;
    font-weight: 600;
}

.wc-gmaps-route-description {
    margin: 0 0 20px 0;
    color: #666;
}

/* Main Wrapper - 70/30 split */
.wc-gmaps-route-wrapper {
    display: flex;
    gap: 20px;
    min-height: 500px;
}

.wc-gmaps-route-map-section {
    flex: 0 0 70%;
    display: flex;
    flex-direction: column;
}

.wc-gmaps-route-sidebar {
    flex: 0 0 30%;
    min-width: 280px;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    overflow-y: auto;
    max-height: 600px;
}

/* Input Panel */
.wc-gmaps-route-inputs {
    margin-bottom: 15px;
}

.wc-gmaps-route-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    position: relative;
}

.wc-gmaps-route-input-icon {
    flex-shrink: 0;
}

.wc-gmaps-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
}

.wc-gmaps-marker-start {
    background: #34a853;
}

.wc-gmaps-marker-end {
    background: #ea4335;
}

.wc-gmaps-marker-stop {
    background: #4285f4;
}

.wc-gmaps-route-input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.wc-gmaps-route-input:focus {
    border-color: #4285f4;
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.15);
}

/* Input Wrapper for PlaceAutocompleteElement */
.wc-gmaps-route-input-wrapper {
    flex: 1;
    position: relative;
}

/* PlaceAutocompleteElement Styling */
.wc-gmaps-route-input-wrapper gmp-place-autocomplete {
    width: 100%;
    display: block;
}

.wc-gmaps-route-input-wrapper gmp-place-autocomplete::part(input) {
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
}

.wc-gmaps-route-input-wrapper gmp-place-autocomplete::part(input):focus {
    border-color: #4285f4;
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.15);
}

/* Legacy input styling when wrapper is present */
.wc-gmaps-route-input-wrapper .wc-gmaps-route-input {
    width: 100%;
}

.wc-gmaps-route-remove-stop {
    background: transparent;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 5px;
    font-size: 20px;
    line-height: 1;
    transition: color 0.2s;
}

.wc-gmaps-route-remove-stop:hover {
    color: #ea4335;
}

/* Stops Container */
.wc-gmaps-route-stops-container {
    margin-left: 38px;
    border-left: 2px dashed #ddd;
    padding-left: 10px;
    margin-bottom: -10px;
}

.wc-gmaps-route-stops-container:empty {
    display: none;
}

.wc-gmaps-route-stops-container .wc-gmaps-route-input-row {
    margin-left: -48px;
}

/* Actions */
.wc-gmaps-route-actions {
    margin: 10px 0 15px 38px;
}

.wc-gmaps-route-add-stop-btn {
    background: transparent;
    border: 1px dashed #4285f4;
    color: #4285f4;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s, color 0.2s;
}

.wc-gmaps-route-add-stop-btn:hover {
    background: rgba(66, 133, 244, 0.1);
}

/* Calculate Button */
.wc-gmaps-route-calculate-btn {
    width: 100%;
    padding: 14px 20px;
    background: #4285f4;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.wc-gmaps-route-calculate-btn:hover {
    background: #3367d6;
}

.wc-gmaps-route-calculate-btn:active {
    transform: scale(0.98);
}

/* Map Container */
.wc-gmaps-route-map {
    flex: 1;
    min-height: 400px;
    border-radius: 8px;
    overflow: hidden;
    background: #e5e3df;
}

/* Route Info */
.wc-gmaps-route-info {
    display: flex;
    gap: 30px;
    padding: 15px 0;
    border-top: 1px solid #eee;
    margin-top: 15px;
}

.wc-gmaps-route-info-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.wc-gmaps-route-info-label {
    color: #666;
    font-size: 14px;
}

.wc-gmaps-route-info-value {
    font-weight: 600;
    font-size: 16px;
}

/* Unit Toggle */
.wc-gmaps-route-unit-toggle {
    display: inline-flex;
    background: #eee;
    border: none;
    border-radius: 4px;
    padding: 2px;
    cursor: pointer;
    margin-left: 5px;
}

.wc-gmaps-route-unit-toggle span {
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 3px;
    transition: background 0.2s, color 0.2s;
}

.wc-gmaps-route-unit-toggle span.active {
    background: #4285f4;
    color: #fff;
}

/* Sidebar */
.wc-gmaps-route-sidebar-placeholder {
    text-align: center;
    color: #888;
    padding: 40px 20px;
}

.wc-gmaps-route-sidebar-placeholder p {
    margin: 0;
}

.wc-gmaps-route-results-title {
    margin: 0 0 15px 0;
    font-size: 16px;
    font-weight: 600;
}

/* Country Items */
.wc-gmaps-route-country-item {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e5e5e5;
}

.wc-gmaps-route-country-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.wc-gmaps-route-country-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.wc-gmaps-route-country-flag {
    font-size: 24px;
    line-height: 1;
}

.wc-gmaps-route-country-name {
    font-weight: 600;
    font-size: 15px;
}

/* Product Items */
.wc-gmaps-route-product {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: #fff;
    border-radius: 6px;
    margin-bottom: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.wc-gmaps-route-product:last-child {
    margin-bottom: 0;
}

.wc-gmaps-route-product-image {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.wc-gmaps-route-product-info {
    flex: 1;
    min-width: 0;
}

.wc-gmaps-route-product-name {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wc-gmaps-route-product-price {
    display: block;
    font-size: 13px;
    color: #666;
    margin-top: 2px;
}

.wc-gmaps-route-product-link {
    flex-shrink: 0;
    padding: 6px 12px;
    background: #4285f4;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.2s;
}

.wc-gmaps-route-product-link:hover {
    background: #3367d6;
    color: #fff;
}

/* Unavailable Message */
.wc-gmaps-route-unavailable {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px;
    background: #fff8e1;
    border-radius: 6px;
    border-left: 3px solid #ffa000;
}

.wc-gmaps-route-unavailable-icon {
    color: #ffa000;
    font-size: 16px;
    line-height: 1;
}

.wc-gmaps-route-unavailable-text {
    font-size: 13px;
    color: #666;
    line-height: 1.4;
}

/* Loading Overlay */
.wc-gmaps-route-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 8px;
}

.wc-gmaps-route-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e5e5;
    border-top-color: #4285f4;
    border-radius: 50%;
    animation: wc-gmaps-spin 0.8s linear infinite;
}

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

.wc-gmaps-route-loading p {
    margin: 15px 0 0;
    color: #666;
}

/* Error Message */
.wc-gmaps-route-error {
    padding: 12px 15px;
    background: #ffebee;
    color: #c62828;
    border-radius: 6px;
    margin-top: 10px;
    font-size: 14px;
}

/* Notice (for admin) */
.wc-gmaps-route-notice {
    padding: 20px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 6px;
    color: #856404;
}

/* Mobile Responsive */
@media (max-width: 900px) {
    .wc-gmaps-route-wrapper {
        flex-direction: column;
    }

    .wc-gmaps-route-map-section {
        flex: 1 1 auto;
    }

    .wc-gmaps-route-sidebar {
        flex: 1 1 auto;
        min-width: 0;
        max-height: none;
    }

    .wc-gmaps-route-map {
        min-height: 350px;
    }
}

@media (max-width: 600px) {
    .wc-gmaps-route-info {
        flex-direction: column;
        gap: 10px;
    }

    .wc-gmaps-route-product {
        flex-wrap: wrap;
    }

    .wc-gmaps-route-product-image {
        width: 40px;
        height: 40px;
    }

    .wc-gmaps-route-product-link {
        width: 100%;
        text-align: center;
        margin-top: 8px;
    }
}

/* Google Places Autocomplete Dropdown Styling */
.pac-container {
    border-radius: 6px;
    border: 1px solid #ddd;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin-top: 5px;
    font-family: inherit;
}

.pac-item {
    padding: 10px 15px;
    cursor: pointer;
    font-size: 14px;
}

.pac-item:hover {
    background: #f5f5f5;
}

.pac-item-selected {
    background: #e8f0fe;
}

.pac-icon {
    margin-right: 10px;
}

.pac-item-query {
    font-size: 14px;
}
