/* Beach Finder Custom Styles - Enhanced UX Version */

/* ========================================
   BASE STYLES & UTILITIES
   ======================================== */

* {
    scroll-behavior: smooth;
}

/* Line clamp utilities */
.line-clamp-1 {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */

.toast-container {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    border-radius: 0.75rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
    font-size: 0.875rem;
    font-weight: 500;
    pointer-events: auto;
    animation: toast-in 0.3s ease-out;
    max-width: 350px;
}

.toast.toast-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.toast.toast-error {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

.toast.toast-info {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
}

.toast.toast-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

.toast-icon {
    flex-shrink: 0;
    font-size: 1rem;
}

.toast-message {
    flex: 1;
}

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: inherit;
    opacity: 0.7;
    cursor: pointer;
    padding: 0.25rem;
    margin-left: 0.5rem;
    transition: opacity 0.15s ease;
}

.toast-close:hover {
    opacity: 1;
}

.toast.show {
    animation: toast-in 0.3s ease-out forwards;
}

.toast.removing {
    animation: toast-out 0.3s ease-in forwards;
}

@keyframes toast-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toast-out {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ========================================
   LOADING STATES
   ======================================== */

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 0.5rem;
}

.skeleton-image {
    width: 100%;
    aspect-ratio: 16/9;
}

.skeleton-title {
    height: 1.5rem;
    width: 70%;
    margin-bottom: 0.75rem;
}

.skeleton-text {
    height: 1rem;
    width: 100%;
    margin-bottom: 0.5rem;
}

.skeleton-card {
    background: white;
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.loading-spinner {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

.loading-spinner-lg {
    width: 2.5rem;
    height: 2.5rem;
    border-width: 3px;
}

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

/* HTMX loading states */
.htmx-request {
    position: relative;
    pointer-events: none;
}

.htmx-request::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
}

.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-flex;
}

/* Button loading state */
.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 1rem;
    height: 1rem;
    top: 50%;
    left: 50%;
    margin-left: -0.5rem;
    margin-top: -0.5rem;
    border: 2px solid white;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

/* ========================================
   BEACH CARDS - SIMPLIFIED
   ======================================== */

.beach-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

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

.beach-card:focus-within {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Card action buttons - mobile stacking */
@media (max-width: 480px) {
    .beach-card .card-actions {
        flex-direction: column;
    }

    .beach-card .card-actions > * {
        width: 100%;
        justify-content: center;
    }
}

/* ========================================
   FILTER CHIPS
   ======================================== */

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: #eff6ff;
    color: #1d4ed8;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.filter-chip:hover {
    background: #dbeafe;
}

.filter-chip .remove-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    background: rgba(29, 78, 216, 0.1);
    color: #1d4ed8;
    font-size: 0.75rem;
    transition: background 0.15s ease;
}

.filter-chip .remove-btn:hover {
    background: rgba(29, 78, 216, 0.2);
}

.filter-chip.clear-all {
    background: #fef2f2;
    color: #dc2626;
    cursor: pointer;
    border: none;
}

.filter-chip.clear-all:hover {
    background: #fee2e2;
}

/* ========================================
   FILTERS - MOBILE RESPONSIVE
   ======================================== */

.filters-container {
    position: relative;
}

/* Mobile filter layout */
@media (max-width: 640px) {
    .filter-row {
        flex-direction: column;
        gap: 0.75rem;
    }

    .filter-row > * {
        width: 100%;
        min-width: 0 !important;
    }

    .tag-filters {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .tag-btn {
        font-size: 0.75rem;
        padding: 0.375rem 0.75rem;
    }
}

/* Tag button styles */
.tag-btn {
    transition: all 0.15s ease;
    border: 2px solid transparent;
}

.tag-btn:focus {
    outline: none;
    border-color: #3b82f6;
}

.tag-btn.active,
.tag-btn[aria-pressed="true"] {
    background-color: #2563eb;
    color: white;
}

/* ========================================
   MAP CONTAINER & CONTROLS
   ======================================== */

#map-container {
    position: relative;
    width: 100%;
    height: 500px;
    border-radius: 0.75rem;
    overflow: hidden;
}

@media (min-width: 768px) {
    #map-container {
        height: 600px;
    }
}

/* Map loading overlay */
.map-loading {
    position: absolute;
    inset: 0;
    background: #f3f4f6;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 10;
}

/* Map legend */
.map-legend {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    background: white;
    border-radius: 0.5rem;
    padding: 0.75rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    font-size: 0.75rem;
    z-index: 10;
}

.legend-title {
    font-weight: 600;
    font-size: 0.75rem;
    color: #374151;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
    font-size: 0.75rem;
    color: #4b5563;
}

.legend-icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.legend-icon.user-icon {
    width: 12px;
    height: 12px;
    background: #3b82f6;
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.legend-count {
    background: #2563eb;
    color: white;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.7rem;
}

/* Map markers */
.beach-marker {
    width: 36px;
    height: 36px;
    background-color: #2563eb;
    border: 3px solid white;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.beach-marker:hover {
    transform: scale(1.15);
}

.beach-marker.selected {
    background-color: #dc2626;
    transform: scale(1.2);
}

.beach-marker.clustered {
    background-color: #7c3aed;
    font-size: 12px;
    font-weight: bold;
    color: white;
}

.user-marker {
    width: 20px;
    height: 20px;
    background-color: #3b82f6;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.3);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(59, 130, 246, 0.1);
    }
}

.user-marker-pulse {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.2);
    animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
    0% {
        transform: scale(0.8);
        opacity: 1;
    }
    100% {
        transform: scale(1.8);
        opacity: 0;
    }
}

/* Map popups */
.beach-popup-container .maplibregl-popup-content {
    padding: 0;
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
}

.beach-popup {
    padding: 1rem;
    min-width: 220px;
}

.popup-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.popup-title {
    font-weight: 600;
    font-size: 1rem;
    color: #111827;
    line-height: 1.3;
}

.popup-rating {
    font-size: 0.875rem;
    color: #6b7280;
    white-space: nowrap;
}

.popup-municipality {
    font-size: 0.875rem;
    color: #6b7280;
    margin-bottom: 0.5rem;
}

.popup-distance {
    font-size: 0.75rem;
    color: #3b82f6;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.popup-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
}

.popup-tag {
    display: inline-block;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 0.625rem;
    font-weight: 500;
    padding: 0.125rem 0.375rem;
    border-radius: 9999px;
}

.popup-actions {
    display: flex;
    gap: 0.5rem;
}

.popup-btn {
    flex: 1;
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 0.375rem;
    text-align: center;
    text-decoration: none;
    transition: all 0.15s ease;
    cursor: pointer;
    border: none;
}

.popup-btn-primary {
    background: #2563eb;
    color: white;
}

.popup-btn-primary:hover {
    background: #1d4ed8;
}

.popup-btn-secondary {
    background: #f3f4f6;
    color: #374151;
}

.popup-btn-secondary:hover {
    background: #e5e7eb;
}

/* Mobile map controls */
@media (max-width: 640px) {
    #map-container {
        height: 400px;
        border-radius: 0;
        margin-left: -1rem;
        margin-right: -1rem;
        width: calc(100% + 2rem);
    }

    .map-legend {
        top: auto;
        bottom: 0.75rem;
        left: 0.75rem;
        padding: 0.5rem;
    }
}

/* ========================================
   DRAWER / MODAL
   ======================================== */

.drawer-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.drawer-overlay.open {
    opacity: 1;
    visibility: visible;
}

.drawer-content {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: white;
    border-radius: 1.5rem 1.5rem 0 0;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 51;
}

.drawer-overlay.open .drawer-content {
    transform: translateY(0);
}

/* Drawer handle for mobile */
.drawer-handle {
    width: 40px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 0.75rem auto;
}

@media (min-width: 768px) {
    .drawer-content {
        left: 50%;
        right: auto;
        bottom: auto;
        top: 50%;
        transform: translate(-50%, -50%) scale(0.9);
        border-radius: 1rem;
        max-width: 600px;
        width: 90%;
        max-height: 85vh;
    }

    .drawer-overlay.open .drawer-content {
        transform: translate(-50%, -50%) scale(1);
    }

    .drawer-handle {
        display: none;
    }
}

/* Drawer loading state */
.drawer-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    gap: 1rem;
}

/* ========================================
   SHARE MODAL
   ======================================== */

.share-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 60;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.share-modal.open {
    opacity: 1;
    visibility: visible;
}

.share-modal-content {
    background-color: white;
    border-radius: 1rem;
    padding: 1.5rem;
    max-width: 400px;
    width: 90%;
    transform: scale(0.9);
    transition: transform 0.2s ease;
}

.share-modal.open .share-modal-content {
    transform: scale(1);
}

/* ========================================
   GALLERY
   ======================================== */

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

@media (min-width: 640px) {
    .gallery-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.gallery-grid img {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.gallery-grid img:hover {
    transform: scale(1.03);
    opacity: 0.9;
}

/* ========================================
   HERO SECTION
   ======================================== */

.hero-gradient {
    background: linear-gradient(135deg, #0ea5e9 0%, #2563eb 50%, #7c3aed 100%);
}

.hero-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: white;
    color: #2563eb;
    padding: 1rem 2rem;
    border-radius: 9999px;
    font-weight: 600;
    font-size: 1.125rem;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hero-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

/* ========================================
   EMPTY STATES
   ======================================== */

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    background: #f9fafb;
    border-radius: 1rem;
    border: 2px dashed #e5e7eb;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
}

.empty-state-message {
    color: #6b7280;
    margin-bottom: 1rem;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.empty-state-context {
    color: #6b7280;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.empty-state-suggestions {
    list-style: none;
    padding: 0;
    margin: 0 0 1.5rem 0;
    text-align: left;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

.empty-state-suggestions li {
    padding: 0.375rem 0;
    font-size: 0.875rem;
    color: #6b7280;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.empty-state-suggestions li::before {
    content: '•';
    color: #9ca3af;
}

.empty-state-action {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: #2563eb;
    color: white;
    font-weight: 500;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    transition: background 0.15s ease;
}

.empty-state-action:hover {
    background: #1d4ed8;
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

/* Focus visible for keyboard navigation */
:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Skip link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #2563eb;
    color: white;
    padding: 0.5rem 1rem;
    z-index: 100;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 0;
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Screen reader only on mobile */
@media (max-width: 640px) {
    .sr-only-mobile {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================
   RANGE SLIDER
   ======================================== */

input[type="range"] {
    -webkit-appearance: none;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: #2563eb;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.2);
}

input[type="range"]:focus::-webkit-slider-thumb {
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.3);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #2563eb;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* ========================================
   SEARCHABLE SELECT (Tom Select compatible)
   ======================================== */

.ts-wrapper {
    width: 100%;
}

.ts-control {
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    background: white;
}

.ts-control:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.ts-dropdown {
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    margin-top: 0.25rem;
}

.ts-dropdown .option {
    padding: 0.625rem 0.75rem;
}

.ts-dropdown .option.active {
    background: #eff6ff;
    color: #1d4ed8;
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    nav, footer, .filters-container, button, .drawer-overlay, .share-modal, .toast-container {
        display: none !important;
    }

    .beach-card {
        break-inside: avoid;
        page-break-inside: avoid;
        box-shadow: none;
        border: 1px solid #e5e7eb;
    }
}
