/**
 * Outdoorsy Integration - Frontend Styles
 */

/* ==========================================================================
   Search Form
   ========================================================================== */

.outdoorsy-search-wrapper {
    width: 100%;
}

.outdoorsy-search-form {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
}

.outdoorsy-search-form.layout-vertical {
    flex-direction: column;
    align-items: stretch;
}

.outdoorsy-search-form.layout-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.outdoorsy-search-form .form-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
    min-width: 150px;
}

.outdoorsy-search-form .form-field label {
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.outdoorsy-search-form .form-field input,
.outdoorsy-search-form .form-field select {
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
}

/* Input wrapper for icons */
.outdoorsy-search-form .input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.outdoorsy-search-form .input-wrapper input,
.outdoorsy-search-form .input-wrapper select {
    flex: 1;
}

.outdoorsy-search-form .form-field.has-icon .input-wrapper input,
.outdoorsy-search-form .form-field.has-icon .input-wrapper select {
    padding-left: 38px;
}

.outdoorsy-search-form .field-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
    font-size: 16px;
    pointer-events: none;
    z-index: 1;
    display:flex;
}

.outdoorsy-search-form .form-field.has-icon .price-inputs {
    padding-left: 26px;
}

.outdoorsy-search-form .form-field.has-icon .price-inputs input {
    padding-left: 12px;
}

.outdoorsy-search-form .form-field input:focus,
.outdoorsy-search-form .form-field select:focus {
    outline: none;
    border-color: #2d6a4f;
    box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.1);
}

.outdoorsy-search-form .date-inputs,
.outdoorsy-search-form .price-inputs {
    display: flex;
    gap: 10px;
}

.outdoorsy-search-form .date-inputs input,
.outdoorsy-search-form .price-inputs input {
    flex: 1;
    min-width: 0;
}

/* Date Range Picker */
.outdoorsy-search-form .field-dates {
    position: relative;
}

.outdoorsy-search-form .date-range-picker {
    cursor: pointer;
    padding-right: 35px;
}

.outdoorsy-search-form .flatpickr-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 18px;
    color: #999;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
    display: none;
}

.outdoorsy-search-form .date-range-picker:not([value=""]) ~ .flatpickr-clear,
.outdoorsy-search-form .date-range-picker.active ~ .flatpickr-clear {
    display: block;
}

.outdoorsy-search-form .flatpickr-clear:hover {
    color: #333;
}

/* Flatpickr Customizations */
.flatpickr-calendar {
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.flatpickr-calendar .flatpickr-current-month {
    padding-top: 0;
}

.flatpickr-calendar.multiMonth {
    width: auto !important;
    padding: 16px;
}

.flatpickr-calendar.multiMonth .flatpickr-months {
    margin-bottom: 8px;
}

.flatpickr-calendar.multiMonth .flatpickr-innerContainer {
    padding-bottom: 8px;
}

.flatpickr-day {
    color: var(--primary) !important;
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
    background: var(--secondary) !important;
    border-color: var(--secondary) !important;
    color: var(--light) !important;
}

.flatpickr-day.selected:hover {
    background-color: var(--secondary) !important;
    color: var(--light) !important;
}

.flatpickr-day.inRange {
    background: var(--tertiary-10) !important;
    border-color: transparent !important;
    box-shadow: 0px 0 0 var(--tertiary-10), 5px 0 0 var(--tertiary-10) !important;
}

.flatpickr-day.startRange {
    box-shadow: 5px 0 0 var(--tertiary-10) !important;
}

.flatpickr-day.endRange {
    box-shadow: -5px 0 0 var(--tertiary-10) !important;
    color: var(--primary) !important;
}

.flatpickr-day.selected.endRange {
    color: var(--light) !important;
}

.flatpickr-day:hover {
    background-color: var(--tertiary-10) !important;
    border-color: rgba(45, 106, 79, 0.3);
}

.flatpickr-day.today:hover {
    color: var(--primary) !important;
}

.flatpickr-next-month:hover svg, .flatpickr-prev-month:hover svg {
    fill: var(--primary) !important;
}

.outdoorsy-search-form .checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}

.outdoorsy-search-form .checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.outdoorsy-search-form .field-submit {
    flex: 0 0 auto;
}

/* Button base - uses Bricks native .bricks-button classes */
.outdoorsy-search-form .bricks-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Button Sizes */
.outdoorsy-search-form .bricks-button.btn-size-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.outdoorsy-search-form .bricks-button.btn-size-md {
    padding: 10px 24px;
    font-size: 14px;
}

.outdoorsy-search-form .bricks-button.btn-size-lg {
    padding: 14px 32px;
    font-size: 16px;
}

/* ==========================================================================
   Rental Grid
   ========================================================================== */

.outdoorsy-grid-wrapper {
    width: 100%;
}

.outdoorsy-rental-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

/* Loading State */
.outdoorsy-rental-grid .loading-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.outdoorsy-rental-grid .loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e0e0e0;
    border-top-color: #2d6a4f;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.outdoorsy-rental-grid .loading-state p {
    margin-top: 15px;
    color: #666;
    font-size: 14px;
}

/* Empty/No Results State */
.outdoorsy-rental-grid .empty-state,
.outdoorsy-rental-grid .no-results-state {
    grid-column: 1 / -1;
    padding: 60px 20px;
    text-align: center;
    color: #666;
}

/* Error State */
.outdoorsy-rental-grid .error-state {
    grid-column: 1 / -1;
    padding: 40px 20px;
    text-align: center;
    color: #c0392b;
    background: #fdf2f2;
    border-radius: 8px;
}

/* ==========================================================================
   Rental Card
   ========================================================================== */

.rental-card {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s, box-shadow 0.2s;
}

.rental-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.rental-card .card-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.rental-card .card-image {
    position: relative;
    height: 200px;
    background-size: cover;
    background-position: center;
    background-color: #f0f0f0;
}

.rental-card .instant-book-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 4px 10px;
    background: #2d6a4f;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    border-radius: 4px;
}

.rental-card .card-content {
    padding: 15px;
}

.rental-card .card-title {
    margin: 0 0 5px 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.rental-card .card-vehicle {
    margin: 0 0 8px 0;
    font-size: 13px;
    color: #666;
}

.rental-card .card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 15px;
    margin-bottom: 10px;
    font-size: 13px;
    color: #666;
}

.rental-card .card-meta span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.rental-card .card-rating {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 10px;
}

.rental-card .rating-stars {
    color: #f39c12;
    font-size: 14px;
    letter-spacing: 1px;
}

.rental-card .rating-count {
    font-size: 12px;
    color: #999;
}

.rental-card .card-price {
    display: flex;
    align-items: baseline;
    gap: 3px;
}

.rental-card .price-amount {
    font-size: 18px;
    font-weight: 700;
    color: #2d6a4f;
}

.rental-card .price-period {
    font-size: 13px;
    color: #666;
}

.rental-card .card-error {
    padding: 20px;
    text-align: center;
    color: #c0392b;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 992px) {
    .outdoorsy-rental-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .outdoorsy-search-form {
        flex-direction: column;
    }

    .outdoorsy-search-form .form-field {
        min-width: 100%;
    }

    .outdoorsy-search-form .date-inputs,
    .outdoorsy-search-form .price-inputs {
        flex-direction: column;
    }

    .outdoorsy-search-form .bricks-button {
        width: 100%;
    }
}

@media (max-width: 576px) {
    .outdoorsy-rental-grid {
        grid-template-columns: 1fr;
    }

    .rental-card .card-image {
        height: 180px;
    }
}

/* ==========================================================================
   Rental Map
   ========================================================================== */

.outdoorsy-rental-map {
    width: 100%;
}

.rental-map-container {
    height: 600px;
    background: #e9e9e9;
    border-radius: 8px;
    overflow: hidden;
}

.rental-map-container .map-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #666;
}

.rental-map-container .map-loading .loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e0e0e0;
    border-top-color: #2d6a4f;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* View Toggle */
.map-view-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
}

.map-view-toggle .toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
}

.map-view-toggle .toggle-btn:hover {
    background: #eee;
}

.map-view-toggle .toggle-btn.active {
    background: #2d6a4f;
    border-color: #2d6a4f;
    color: #fff;
}

.map-view-toggle .toggle-btn svg {
    width: 16px;
    height: 16px;
}

/* Grid View */
.rental-grid-view {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

@media (max-width: 992px) {
    .rental-grid-view {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 576px) {
    .rental-grid-view {
        grid-template-columns: 1fr;
    }
}

/* Map Markers */
.rental-marker-icon {
    background: transparent !important;
    border: none !important;
}

.map-marker {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    white-space: nowrap;
}

.map-marker.price-marker {
    padding: 6px 10px;
    background: var(--marker-bg, #fff);
    color: var(--marker-text, #1a1a1a);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    border: 2px solid rgba(0, 0, 0, 0.08);
    transition: all 0.15s;
}

.map-marker.price-marker:hover,
.map-marker.price-marker.active {
    background: var(--marker-bg, #1a1a1a);
    color: var(--marker-text, #fff);
    transform: scale(1.05);
}

.map-marker.price-marker .instant-icon {
    font-size: 11px;
}

.map-marker.dot-marker {
    width: 14px;
    height: 14px;
    background: var(--marker-bg, #2d6a4f);
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    border: 2px solid #fff;
}

.map-marker.dot-marker.active {
    background: var(--marker-bg, #1a1a1a);
    transform: scale(1.2);
}

/* Map Popup */
.rental-popup .leaflet-popup-content-wrapper {
    padding: 0;
    border-radius: 12px;
    overflow: hidden;
}

.rental-popup .leaflet-popup-content {
    margin: 0;
    min-width: 260px;
}

.rental-popup-content {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.rental-popup-content .popup-link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.rental-popup-content .popup-image {
    height: 140px;
    background-size: cover;
    background-position: center;
    background-color: #f0f0f0;
}

.rental-popup-content .popup-details {
    padding: 12px 15px;
}

.rental-popup-content .popup-title {
    margin: 0 0 5px 0;
    font-size: 15px;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
}

.rental-popup-content .popup-vehicle {
    margin: 0 0 4px 0;
    font-size: 12px;
    color: #666;
}

.rental-popup-content .popup-location {
    margin: 0 0 8px 0;
    font-size: 12px;
    color: #888;
}

.rental-popup-content .popup-meta {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 12px;
    color: #666;
}

.rental-popup-content .meta-rating {
    color: #f39c12;
}

.rental-popup-content .popup-price {
    display: flex;
    align-items: baseline;
    gap: 2px;
}

.rental-popup-content .popup-price .price-amount {
    font-size: 16px;
    font-weight: 700;
    color: #2d6a4f;
}

.rental-popup-content .popup-price .price-period {
    font-size: 12px;
    color: #666;
}

/* Leaflet Overrides */
.leaflet-popup-close-button {
    top: 8px !important;
    right: 8px !important;
    width: 24px !important;
    height: 24px !important;
    font-size: 18px !important;
    line-height: 24px !important;
    color: #666 !important;
    background: rgba(255, 255, 255, 0.9) !important;
    border-radius: 50% !important;
}

.leaflet-popup-close-button:hover {
    color: #333 !important;
}

/* Cluster Markers */
.rental-cluster-icon {
    background: transparent !important;
    border: none !important;
}

.map-cluster-marker {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--marker-bg, #fff);
    color: var(--marker-text, #1a1a1a);
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    border: 2px solid rgba(0, 0, 0, 0.08);
    white-space: nowrap;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.map-cluster-marker .cluster-icon {
    width: 18px;
    height: 18px;
    opacity: 0.7;
}

.map-cluster-marker .cluster-count {
    font-weight: 700;
}

.map-cluster-marker:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Override default markercluster styles */
.marker-cluster {
    background: transparent !important;
}

.marker-cluster div {
    background: transparent !important;
}
