/**
 * VoteCraft Tours Widget Styles
 * Custom styles and overrides for the location-based music app
 */

/* Base reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #000;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Page transition overlay */
.page-transition-overlay {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 9999;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.page-transition-overlay.fade-out {
    opacity: 0;
}

.page-transition-overlay.fade-in {
    opacity: 1;
}

#root {
    height: 100%;
}

/* Map placeholder styles */
.map-placeholder {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
}

/* Pin animation */
.map-pin {
    transition: transform 0.2s ease, filter 0.2s ease;
}

.map-pin:hover {
    transform: scale(1.1);
}

.map-pin.selected {
    transform: scale(1.25);
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
}

/* Callout bubble animation */
.callout-bubble {
    animation: fadeInUp 0.2s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translate(-50%, 10px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* Playlist card hover effect */
.playlist-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    /* Offset for sticky header (48px) + sticky map (35vh) + gap */
    scroll-margin-top: calc(48px + 35vh + 16px);
    /* Default height - 128px on desktop, overridden on mobile */
    height: 128px;
}

/* Mobile: compact cards to fit 4+ below map */
@media screen and (max-width: 430px) {
    .playlist-card {
        height: 52px;
        margin-bottom: 0.5rem !important;
    }
    .playlist-card .w-28 {
        width: 52px;
    }
    .playlist-card h3 {
        font-size: 0.8125rem !important;
        line-height: 1.2 !important;
        margin-bottom: 0.125rem !important;
    }
    .playlist-card p {
        font-size: 0.6875rem !important;
        line-height: 1.2 !important;
    }
    .playlist-card .p-3 {
        padding: 0.25rem 0.5rem !important;
    }
    .playlist-card .pr-3 {
        padding-right: 0.25rem !important;
    }
    /* Smaller arrow buttons on mobile */
    .playlist-card .w-8 {
        width: 24px !important;
        height: 24px !important;
    }
    .playlist-card .w-8 svg {
        width: 12px !important;
        height: 12px !important;
    }
    .playlist-card .ml-2 {
        margin-left: 0.375rem !important;
    }
    /* Smaller play buttons on mobile - circle half size, arrow same */
    .play-button {
        width: 16px !important;
        height: 16px !important;
        min-width: 16px !important;
        min-height: 16px !important;
    }
    .play-button svg {
        width: 10px !important;
        height: 10px !important;
    }
    .play-button svg {
        width: 10px !important;
        height: 10px !important;
    }
    /* Smaller close button in drawer */
    .nav-drawer-close {
        width: 1.75rem;
        height: 1.75rem;
    }
    .nav-drawer-close svg {
        width: 1rem;
        height: 1rem;
    }
    /* Reduce map overlay text size */
    #map-tour-name {
        padding: 0.375rem 0.75rem !important;
    }
    #map-tour-name span,
    #map-tour-name a {
        font-size: 0.875rem !important;
        white-space: nowrap !important;
        overflow: hidden;
        text-overflow: ellipsis;
        display: block;
    }
    /* Reduce playlist container padding */
    #playlist-container {
        padding: 0 !important;
    }
}

.playlist-card:hover:not(.ring-2) {
    opacity: 0.7;
}

.playlist-card:active:not(.ring-2) {
    opacity: 0.5;
}

/* Play button pulse animation */
.play-button {
    width: 36px;
    height: 36px;
    transition: transform 0.15s ease, background-color 0.15s ease;
}

.play-button:hover {
    transform: scale(1.1);
}

.play-button:active {
    transform: scale(0.95);
}

/* Modal backdrop */
.modal-backdrop {
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Modal content slide up */
.modal-content {
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Bottom navigation styling */
.bottom-nav {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Custom scrollbar for playlist list */
.playlist-scroll::-webkit-scrollbar {
    width: 6px;
}

.playlist-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.playlist-scroll::-webkit-scrollbar-thumb {
    background: #4b5563;
    border-radius: 3px;
}

.playlist-scroll::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}

/* Sticky map positioning */
.sticky-map {
    top: 48px; /* Height of top bar */
    height: 35vh; /* Default height, overridden on mobile */
    transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                top 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                position 0s;
}

/* Fullscreen map mode */
.sticky-map.map-fullscreen {
    position: fixed !important;
    top: 48px !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: calc(100vh - 48px) !important;
    z-index: 9999 !important;
    max-width: none !important;
    transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                top 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.sticky-map.map-fullscreen #map-tour-name {
    position: fixed !important;
    bottom: env(safe-area-inset-bottom, 0px) !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 10000 !important;
}

/* Keep top bar visible in fullscreen map */
body:has(.sticky-map.map-fullscreen) .top-bar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 10001 !important;
}

/* Fullscreen button styling */
.leaflet-fullscreen-btn {
    background: white !important;
}

.leaflet-fullscreen-btn svg {
    color: #333;
}

/* Keep Leaflet controls fixed in place during fullscreen */
.sticky-map.map-fullscreen .leaflet-control-container .leaflet-top.leaflet-left {
    position: fixed !important;
    top: 58px !important;
    left: 10px !important;
    z-index: 10002 !important;
}

/* Top bar base height */
.top-bar {
    height: auto;
    min-height: 48px;
}

/* Mobile top bar optimizations */
@media screen and (max-width: 430px) {
    .top-bar {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
        min-height: 44px;
    }

    /* Smaller logo icon */
    .top-bar .logo-icon {
        width: 32px !important;
        height: 32px !important;
    }

    .top-bar .logo-icon svg {
        width: 18px !important;
        height: 18px !important;
    }

    /* Smaller logo text */
    .top-bar .logo-text {
        font-size: 1rem !important;
    }

    /* Menu button closer to edge */
    .top-bar .btn-menu {
        right: 0.5rem !important;
        padding: 0.375rem !important;
    }

    /* Back button closer to edge */
    .top-bar .btn-back {
        left: 0.5rem !important;
        padding: 0.375rem !important;
    }
}

/* Sticky map shadow - creates depth effect for content scrolling under */
.sticky-map::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 0;
    right: 0;
    height: 15px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.3), transparent);
    pointer-events: none;
    z-index: 25;
}

/* Map container shadow */
.leaflet-container {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

/* Mobile optimizations */
@media (max-width: 640px) {
    .playlist-card {
        transition: none;
    }

    .playlist-card:hover {
        transform: none;
    }
}

/* Safe area padding for notched phones and Dynamic Island */
@supports (padding: env(safe-area-inset-top)) {
    .top-bar {
        padding-top: calc(0.5rem + env(safe-area-inset-top));
    }

    .bottom-nav {
        padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
    }

    /* Adjust sticky map position to account for dynamic top bar height */
    .sticky-map {
        top: calc(48px + env(safe-area-inset-top));
    }

    /* Update scroll margin for playlist cards */
    .playlist-card {
        scroll-margin-top: calc(48px + env(safe-area-inset-top) + 35vh + 16px);
    }
}

/* Leaflet map customizations */
.leaflet-container {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.custom-marker {
    background: transparent;
    border: none;
}

.marker-pin {
    transition: transform 0.2s ease;
    cursor: pointer;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.marker-pin:hover {
    transform: scale(1.1);
}

.marker-pin.selected {
    transform: scale(1.2);
    filter: drop-shadow(0 4px 8px rgba(59, 130, 246, 0.5));
    z-index: 1000 !important;
}

.leaflet-popup-content-wrapper {
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid #e5e7eb;
}

.leaflet-popup-content {
    margin: 12px 16px;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
}

@media (max-width: 430px) {
    .leaflet-popup-content {
        margin: 8px 12px;
        font-size: 12px;
    }

    .leaflet-popup-content-wrapper {
        border-radius: 8px;
    }
}

.leaflet-popup-tip {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
}

/* Clean zoom controls matching votecraft.org style */
.leaflet-control-zoom {
    border: 1px solid #d6d6d6 !important;
    border-radius: 8px !important;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
}

.leaflet-control-zoom a {
    width: 32px !important;
    height: 32px !important;
    line-height: 32px !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    color: #32373c !important;
    background: #fff !important;
    border: none !important;
    transition: background-color 0.15s ease;
}

.leaflet-control-zoom a:hover {
    background: #f5f5f5 !important;
    color: #5087e5 !important;
}

.leaflet-control-zoom-in {
    border-bottom: 1px solid #d6d6d6 !important;
}

/* Attribution styling - subtle and clean */
.leaflet-control-attribution {
    font-size: 9px;
    background: rgba(255, 255, 255, 0.9) !important;
    padding: 2px 8px !important;
    color: #767676;
}

.leaflet-control-attribution a {
    color: #5087e5;
}

/* ============================================
   iPhone 16 Pro Optimizations
   Screen: 402 x 874 CSS pixels, 3x density
   ============================================ */

/* Ensure minimum touch target size of 44pt for iOS */
@media (pointer: coarse) {
    .bottom-nav button {
        min-width: 44px;
        min-height: 44px;
        padding: 8px;
    }

    #btn-menu {
        min-width: 44px;
        min-height: 44px;
    }

    .play-button {
        min-width: 20px;
        min-height: 20px;
    }

    .playlist-card {
        min-height: 72px;
    }
}

/* iPhone 16 Pro specific (402px width, taller aspect ratio ~19.5:9) */
@media screen and (max-width: 430px) and (min-height: 800px) and (-webkit-device-pixel-ratio: 3) {
    /* Optimize map height for taller display */
    .sticky-map {
        height: 32vh !important;
    }

    /* Better use of vertical space */
    .playlist-card {
        scroll-margin-top: calc(48px + env(safe-area-inset-top, 0px) + 28vh + 12px);
    }

    /* Compact cards to fit 4+ below map */
    .playlist-card {
        height: 52px !important;
    }

    .playlist-card .w-28 {
        width: 52px !important;
    }

    /* Optimize bottom nav icon size */
    .bottom-nav svg {
        width: 28px;
        height: 28px;
    }
}

/* For all tall phones with notch/Dynamic Island */
@media screen and (max-width: 430px) and (min-height: 750px) {
    /* Prevent content from being hidden under Dynamic Island */
    #app {
        padding-top: env(safe-area-inset-top, 0px);
    }

    /* Ensure map doesn't overlap with safe areas */
    .sticky-map {
        height: min(32vh, 260px) !important;
    }

    /* Compact cards to fit 4+ below map */
    .playlist-card {
        height: 52px !important;
    }

    .playlist-card .w-28 {
        width: 52px !important;
    }

    /* Better spacing for playlist items on mobile */
    #playlist-container {
        gap: 4px;
    }
}

/* Landscape orientation on iPhone 16 Pro */
@media screen and (max-height: 430px) and (orientation: landscape) {
    .sticky-map {
        height: 45vh !important;
        position: relative;
        top: 0;
    }

    .top-bar {
        padding-top: 0.5rem;
        padding-left: calc(0.5rem + env(safe-area-inset-left, 0px));
        padding-right: calc(0.5rem + env(safe-area-inset-right, 0px));
    }

    .bottom-nav {
        padding-left: calc(0.5rem + env(safe-area-inset-left, 0px));
        padding-right: calc(0.5rem + env(safe-area-inset-right, 0px));
    }
}

/* ============================================
   Navigation Drawer Styles
   ============================================ */

.nav-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 40;
    transition: background-color 0.3s ease;
    pointer-events: none;
}

.nav-drawer-overlay.open {
    background: rgba(0, 0, 0, 0.5);
    pointer-events: auto;
}

.nav-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 85%;
    max-width: 320px;
    background: #111827;
    z-index: 50;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
}

.nav-drawer.open {
    transform: translateX(0);
}

.nav-drawer-top {
    padding: 1rem;
    padding-top: calc(1rem + env(safe-area-inset-top, 0px));
    flex-shrink: 0;
    display: flex;
    justify-content: flex-end;
}

.nav-drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.nav-drawer-footer {
    padding: 1rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #374151;
    background: #0f172a;
    flex-shrink: 0;
}

.nav-drawer-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    border-radius: 0.75rem;
    margin-bottom: 0.5rem;
    background: #1f2937;
    transition: background-color 0.15s ease, transform 0.15s ease;
    cursor: pointer;
    border: 2px solid transparent;
}

.nav-drawer-item:hover {
    background: #374151;
}

.nav-drawer-item:active {
    transform: scale(0.98);
}

.nav-drawer-item.active {
    background: #1e3a8a;
    border-color: #3b82f6;
}

.nav-drawer-item .icon {
    font-size: 1.75rem;
    flex-shrink: 0;
    width: 2.5rem;
    text-align: center;
}

.nav-drawer-item .content {
    flex: 1;
    min-width: 0;
}

.nav-drawer-item .title {
    color: #fff;
    font-weight: 600;
    font-size: 0.9375rem;
    margin-bottom: 0.25rem;
}

.nav-drawer-item .description {
    color: #9ca3af;
    font-size: 0.8125rem;
    line-height: 1.4;
}

.nav-drawer-item .badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

/* Close button in drawer */
.nav-drawer-close {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.nav-drawer-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* Prevent body scroll when drawer is open */
body.drawer-open {
    overflow: hidden;
}

/* ============================================
   Accordion Styles
   ============================================ */

.accordion {
    background: #1f2937;
    border-radius: 0.75rem;
    overflow: hidden;
}

.accordion-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.accordion-trigger:hover {
    background: #374151;
}

.accordion-chevron {
    transition: transform 0.2s ease;
}

.accordion.open .accordion-chevron {
    transform: rotate(180deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: #111827;
}

.accordion.open .accordion-content {
    max-height: 500px;
}

.accordion-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    cursor: pointer;
    transition: filter 0.15s ease, background-color 0.15s ease;
    border-bottom: 1px solid #1f2937;
}

.accordion-item:last-child {
    border-bottom: none;
}

.accordion-item:hover {
    filter: brightness(1.3);
}

.accordion-item.active {
    background: rgba(59, 130, 246, 0.15);
}

.accordion-item.active:hover {
    filter: brightness(1.3);
}

/* ============================================
   Navigation Menu Items
   ============================================ */

.nav-menu-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-menu-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1rem;
    border-radius: 0.75rem;
    color: #fff;
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 500;
    transition: background-color 0.15s ease;
    cursor: pointer;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
}

.nav-menu-item:hover {
    background: #1f2937;
}

.nav-menu-item:active {
    background: #374151;
}

.nav-menu-icon {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    color: #9ca3af;
}

.nav-menu-item:hover .nav-menu-icon {
    color: #3b82f6;
}

/* Accordion inside menu list */
.nav-menu-list .accordion {
    background: transparent;
    border-radius: 0;
    overflow: visible;
}

.nav-menu-list .accordion-trigger {
    padding: 0.875rem 1rem;
    border-radius: 0.75rem;
}

.nav-menu-list .accordion-trigger:hover {
    background: #1f2937;
}

.nav-menu-list .accordion-content {
    margin-left: 2.125rem;
    margin-top: 0.25rem;
    background: #1f2937;
    border-radius: 0.75rem;
    overflow: hidden;
}

.nav-menu-list .accordion.open .accordion-content {
    max-height: 600px;
}

/* ============================================
   Settings Styles
   ============================================ */

.settings-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    cursor: pointer;
    transition: background-color 0.15s ease;
    border-bottom: 1px solid #1f2937;
}

.settings-item:last-child {
    border-bottom: none;
}

.settings-item:hover {
    background: #1f2937;
}

/* Toggle switch */
.settings-item [id$="-toggle"] {
    width: 2.5rem;
    height: 1.5rem;
    background: #4B5563;
    border-radius: 9999px;
    position: relative;
    cursor: pointer;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
}

.settings-item [id$="-toggle"] > div {
    position: absolute;
    left: 0.25rem;
    top: 0.25rem;
    width: 1rem;
    height: 1rem;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s ease;
}

.settings-item [id$="-toggle"].active {
    background: #3B82F6;
}

.settings-item [id$="-toggle"].active > div {
    transform: translateX(1rem);
}

/* Volume slider */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    background: #4B5563;
    border-radius: 2px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: #3B82F6;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

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