/* ==========================================================================
   CityGuide Core Design System & Stylesheet
   ========================================================================== */

/* Design Tokens & Variables */
:root {
    --bg-dark: #f8fafc;
    --bg-glass: rgba(255, 255, 255, 0.7);
    --border-glass: rgba(0, 0, 0, 0.08);
    --border-glass-active: rgba(99, 102, 241, 0.3);
    
    /* Typography */
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    
    /* Colors */
    --color-text-main: #0f172a;
    --color-text-muted: #64748b;
    --color-mint: #10b981;
    --color-cyan: #06b6d4;
    --color-indigo: #4f46e5;
    --color-sunset: #f97316;
    
    /* Category Colors */
    --cat-culture: #8b5cf6;
    --cat-food: #ef4444;
    --cat-nature: #10b981;
    --cat-shopping: #06b6d4;
    --cat-custom: #f97316;
    
    /* Transitions & Shadows */
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-premium: 0 4px 20px 0 rgba(0, 0, 0, 0.08);
    --shadow-glow: 0 0 15px rgba(99, 102, 241, 0.15);
    --blur-strength: 12px;
}

/* Base Reset & Layout */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-dark);
    color: var(--color-text-main);
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    letter-spacing: -0.02em;
}

a {
    color: var(--color-cyan);
    text-decoration: none;
    transition: var(--transition-smooth);
}
a:hover {
    color: var(--color-mint);
    text-decoration: underline;
}

/* Glassmorphism Class utility */
.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(var(--blur-strength));
    -webkit-backdrop-filter: blur(var(--blur-strength));
    border: 1px solid var(--border-glass);
    box-shadow: var(--shadow-premium);
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    position: relative;
}


/* ==========================================================================
   Map Interface
   ========================================================================== */
.map-wrapper {
    flex: 1;
    position: relative;
    height: 100%;
}

#map {
    height: 100%;
    width: 100%;
    background-color: var(--bg-dark);
}

/* Floating Map Overlay Controls */
.map-overlay-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 999;
}

.overlay-control-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-glass);
    color: var(--color-text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-premium);
    transition: var(--transition-smooth);
    position: relative;
}

.overlay-control-btn svg {
    width: 20px;
    height: 20px;
}

.overlay-control-btn:hover {
    border-color: var(--color-indigo);
    color: var(--color-indigo);
    transform: scale(1.05);
}

.control-tooltip {
    position: absolute;
    right: 50px;
    background: rgba(0, 0, 0, 0.85);
    color: #ffffff;
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-smooth);
    border: 1px solid var(--border-glass);
}
.overlay-control-btn:hover .control-tooltip {
    opacity: 1;
}

/* ==========================================================================
   Drawers and Overlays (Slide-out Settings)
   ========================================================================== */
.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1400;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.drawer-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.drawer {
    position: absolute;
    top: 0;
    right: 0;
    width: 420px;
    height: 100%;
    border-left: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.32, 0.94, 0.6, 1);
}

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

.drawer-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.drawer-header h3 {
    font-size: 18px;
    color: #ffffff;
}

.close-btn {
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 24px;
    cursor: pointer;
    transition: var(--transition-smooth);
}
.close-btn:hover {
    color: #ffffff;
}

.drawer-body {
    padding: 24px;
    flex: 1;
    overflow-y: auto;
}

.drawer-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-glass);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Form Controls */
.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.input-help {
    font-size: 11px;
    color: var(--color-text-muted);
    line-height: 1.4;
    margin-bottom: 8px;
}

/* Password wrapper field */
.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrapper input {
    width: 100%;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    padding: 10px 42px 10px 12px;
    color: #ffffff;
    font-family: var(--font-body);
    font-size: 13px;
    transition: var(--transition-smooth);
}

.password-wrapper input:focus {
    outline: none;
    border-color: var(--color-cyan);
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.15);
}

.toggle-password {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
}
.toggle-password:hover {
    color: #ffffff;
}
.toggle-password svg {
    width: 18px;
    height: 18px;
}

/* Instructions card */
.api-instructions {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 24px;
}

.api-instructions h4 {
    font-size: 12px;
    color: #ffffff;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.api-instructions ol {
    padding-left: 18px;
    font-size: 11px;
    color: var(--color-text-muted);
    line-height: 1.6;
}

/* Buttons System */
.primary-btn, .secondary-btn {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 13px;
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-smooth);
    border: 1px solid transparent;
}

.primary-btn {
    background: linear-gradient(135deg, var(--color-cyan) 0%, var(--color-indigo) 100%);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(0, 229, 255, 0.2);
}
.primary-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 229, 255, 0.35);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border-glass);
    color: var(--color-text-muted);
}
.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

/* ==========================================================================
   Leaflet Styling Overrides for Dark Mode
   ========================================================================== */
.leaflet-bar {
    border: 1px solid var(--border-glass) !important;
    box-shadow: var(--shadow-premium) !important;
}

.leaflet-bar a {
    background-color: rgba(255, 255, 255, 0.9) !important;
    color: #0f172a !important;
    border-bottom: 1px solid var(--border-glass) !important;
    transition: var(--transition-smooth) !important;
}

.leaflet-bar a:hover {
    color: var(--color-indigo) !important;
    background-color: #ffffff !important;
}

.leaflet-bar a.leaflet-disabled {
    background-color: rgba(241, 245, 249, 0.9) !important;
    color: rgba(15, 23, 42, 0.2) !important;
}

.leaflet-popup-content-wrapper {
    background: rgba(255, 255, 255, 0.95) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    border: 1px solid var(--border-glass) !important;
    box-shadow: var(--shadow-premium) !important;
    color: #0f172a !important;
    border-radius: 10px !important;
    padding: 4px;
}

.leaflet-popup-tip {
    background: rgba(255, 255, 255, 0.95) !important;
    border-left: 1px solid var(--border-glass) !important;
    border-bottom: 1px solid var(--border-glass) !important;
}

.leaflet-popup-content h4 {
    font-size: 14px;
    margin-bottom: 4px;
    font-family: var(--font-heading);
}

.leaflet-popup-content p {
    font-size: 12px;
    color: var(--color-text-muted);
    line-height: 1.4;
    margin-bottom: 6px !important;
}

.leaflet-container a.leaflet-popup-close-button {
    color: var(--color-text-muted) !important;
    padding: 6px 8px 0 0 !important;
}
.leaflet-container a.leaflet-popup-close-button:hover {
    color: #0f172a !important;
}

/* Custom leaflet marker pin styling (using CSS) */
.custom-div-icon {
    background: none;
    border: none;
}

.marker-pin {
    width: 30px;
    height: 30px;
    border-radius: 50% 50% 50% 0;
    position: absolute;
    transform: rotate(-45deg);
    left: 50%;
    top: 50%;
    margin: -15px 0 0 -15px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
}

.marker-pin::after {
    content: '';
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    position: absolute;
}

.marker-pin.culture { background-color: var(--cat-culture); box-shadow: 0 0 10px rgba(138, 79, 255, 0.6); }
.marker-pin.food { background-color: var(--cat-food); box-shadow: 0 0 10px rgba(255, 82, 82, 0.6); }
.marker-pin.nature { background-color: var(--cat-nature); box-shadow: 0 0 10px rgba(0, 230, 118, 0.6); }
.marker-pin.shopping { background-color: var(--cat-shopping); box-shadow: 0 0 10px rgba(0, 229, 255, 0.6); }
.marker-pin.custom { background-color: var(--cat-custom); box-shadow: 0 0 10px rgba(255, 145, 0, 0.6); }

/* Pulsing User Location Marker */
.user-location-icon {
    background: none;
    border: none;
}
.pulsing-user-dot {
    width: 14px;
    height: 14px;
    background-color: #4285F4;
    border: 2px solid #ffffff;
    border-radius: 50%;
    position: relative;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
}
.pulsing-user-dot::before {
    content: '';
    position: absolute;
    width: 300%;
    height: 300%;
    background-color: rgba(66, 133, 244, 0.3);
    border-radius: 50%;
    left: -100%;
    top: -100%;
    animation: user-dot-pulse 1.8s infinite ease-out;
    pointer-events: none;
}
@keyframes user-dot-pulse {
    0% {
        transform: scale(0.3);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 0;
    }
}

/* ==========================================================================
   Toast Notification System
   ========================================================================== */
.toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 9999;
}

.toast {
    background: rgba(13, 17, 23, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border-glass);
    border-radius: 30px;
    padding: 10px 20px;
    color: #ffffff;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-premium);
    animation: toast-in 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.toast.success { border-color: rgba(0, 230, 118, 0.3); }
.toast.error { border-color: rgba(255, 82, 82, 0.3); }

.toast-icon {
    width: 14px;
    height: 14px;
}
.toast.success .toast-icon { color: var(--color-mint); }
.toast.error .toast-icon { color: #ff5252; }

/* ==========================================================================
   Animations Keyframes
   ========================================================================== */
@keyframes toast-in {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ==========================================================================
   Responsive Design Adjustments
   ========================================================================== */
@media (max-width: 768px) {
    .map-overlay-controls {
        top: 14px;
        right: 12px;
    }

    /* Zoom buttons are not rendered on mobile (pinch-to-zoom instead);
       hide them defensively in case an engine injects its own. */
    .leaflet-control-zoom,
    .gm-bundled-control {
        display: none;
    }

    /* Settings drawer goes full width */
    .drawer {
        width: 100%;
    }

    /* Tour panel spans the width with a safe bottom inset */
    .tour-panel {
        left: 12px;
        right: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom));
        width: auto;
        max-height: 68vh;
        max-height: 68dvh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* 16px inputs prevent iOS Safari from auto-zooming on focus */
    #gmaps-api-key,
    #gemini-api-key,
    #app-language-select,
    #gemini-model-select {
        font-size: 16px;
    }
}

/* ==========================================================================
   Sightseeing Tour Generator & Audio Guide Panel
   ========================================================================== */
.tour-panel {
    position: absolute;
    bottom: 24px;
    left: 24px;
    width: 350px;
    max-height: calc(100% - 48px);
    z-index: 999;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    animation: slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.tour-panel h3 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--color-text-main);
}

.tour-panel p {
    font-size: 12px;
    color: var(--color-text-muted);
    line-height: 1.5;
}

/* Sights Checklist selection styles */
.sights-checklist::-webkit-scrollbar {
    width: 6px;
}
.sights-checklist::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 4px;
}
.sights-checklist::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}
.sights-checklist::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

.sight-select-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition-smooth);
    user-select: none;
}
.sight-select-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-glass-active);
}
.sight-select-card.selected {
    background: rgba(79, 70, 229, 0.06);
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.05);
}
.sight-select-card input[type="checkbox"] {
    margin-top: 3px;
    accent-color: var(--color-indigo);
    cursor: pointer;
    width: 16px;
    height: 16px;
}
.sight-select-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
}
.sight-select-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-main);
    font-family: var(--font-heading);
}
.sight-select-desc {
    font-size: 11px;
    color: var(--color-text-muted);
    line-height: 1.4;
}

/* Active Tour Header */
.tour-header {
    border-bottom: 1px solid var(--border-glass);
    padding-bottom: 10px;
    margin-bottom: 4px;
}

.tour-badge {
    display: inline-block;
    font-size: 9px;
    text-transform: uppercase;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
    background: rgba(79, 70, 229, 0.1);
    color: var(--color-indigo);
    margin-bottom: 6px;
}

#tour-title-text {
    font-size: 15px;
    font-weight: 700;
    color: var(--color-text-main);
}

/* Sight Card */
.sight-card {
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sight-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sight-number {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--color-indigo);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sight-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-main);
}

.sight-desc {
    font-size: 11px;
    color: var(--color-text-muted);
    line-height: 1.4;
}

/* Audio Player */
.audio-player {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(79, 70, 229, 0.05);
    border: 1px solid rgba(79, 70, 229, 0.15);
    border-radius: 8px;
    padding: 8px 12px;
    margin-top: 4px;
}

.play-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-indigo);
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.play-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.45);
}

.audio-status {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-indigo);
}

/* Pulse Loader Animation */
.pulse-loader {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--color-indigo);
    margin: 12px auto;
    animation: pulse-loader-anim 1.5s infinite ease-in-out;
}

@keyframes pulse-loader-anim {
    0% { transform: scale(0.6); opacity: 0.8; }
    50% { transform: scale(1.1); opacity: 0.3; }
    100% { transform: scale(0.6); opacity: 0.8; }
}

/* Tour Footer Controls */
.tour-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
}

.tour-footer button {
    padding: 6px 14px;
    font-size: 11px;
}

.sight-progress {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted);
}

.exit-tour-btn {
    background: none;
    border: none;
    color: #ff5252;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    align-self: center;
    margin-top: 4px;
    transition: var(--transition-smooth);
}

.exit-tour-btn:hover {
    text-decoration: underline;
}

/* Premium AI Magic FAB button styling */
.fab-ai-generate {
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%) !important;
    border: none !important;
    color: #ffffff !important;
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.4) !important;
    transition: var(--transition-smooth) !important;
}

.fab-ai-generate:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(168, 85, 247, 0.6) !important;
}
