/* ===== CSS Variables ===== */
:root {
    --primary-color: #FFB347;
    --primary-dark: #FF9F1C;
    --secondary-color: #2EC4B6;
    --background: #FFF9F0;
    --text-color: #2D3436;
    --text-light: #636E72;
    --white: #FFFFFF;
    --shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.15);
    --radius: 12px;
    --radius-lg: 20px;
}

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

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--background);
    color: var(--text-color);
    -webkit-tap-highlight-color: transparent;
}

/* ===== Map ===== */
#map {
    height: 100%;
    width: 100%;
    z-index: 1;
}

/* Move Leaflet zoom controls below home button */
.leaflet-top.leaflet-left {
    top: 75px;
}

.leaflet-control-zoom {
    border: none !important;
    box-shadow: var(--shadow) !important;
}

.leaflet-control-zoom a {
    width: 36px !important;
    height: 36px !important;
    line-height: 36px !important;
    border-radius: 8px !important;
    background: var(--white) !important;
    color: var(--text-color) !important;
    font-size: 18px !important;
}

.leaflet-control-zoom a:hover {
    background: var(--background) !important;
}

/* ===== Home Button ===== */
.home-btn {
    position: fixed;
    top: 20px;
    left: 15px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--white);
    border: none;
    cursor: pointer;
    box-shadow: var(--shadow);
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
    padding: 6px;
}

.home-btn:hover {
    transform: scale(1.1);
}

.home-btn:active {
    transform: scale(0.95);
}

.home-icon {
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

/* ===== Menu Button (Hamburger) ===== */
.menu-btn {
    position: fixed;
    top: 20px;
    right: 15px;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--white);
    border: none;
    cursor: pointer;
    box-shadow: var(--shadow);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 12px;
    transition: transform 0.2s ease;
}

.menu-btn:hover {
    transform: scale(1.05);
}

.hamburger-line {
    width: 20px;
    height: 2px;
    background: var(--text-color);
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* ===== Side Menu ===== */
.side-menu {
    position: fixed;
    top: 0;
    right: 0;
    width: 280px;
    max-width: 85vw;
    height: 100%;
    background: var(--white);
    box-shadow: -5px 0 30px rgba(0, 0, 0, 0.2);
    z-index: 3000;
    transform: translateX(0);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.side-menu.hidden {
    transform: translateX(100%);
}

.menu-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    border-bottom: 1px solid #EEE;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: var(--white);
}

.menu-logo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.menu-title {
    flex: 1;
    font-weight: 600;
    font-size: 18px;
}

.close-menu-btn {
    background: none;
    border: none;
    color: var(--white);
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.8;
}

.close-menu-btn:hover {
    opacity: 1;
}

.menu-nav {
    flex: 1;
    padding: 15px 0;
    overflow-y: auto;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    color: var(--text-color);
    text-decoration: none;
    transition: background 0.2s ease;
}

.menu-item:hover {
    background: #F5F5F5;
}

.menu-icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
}

.menu-footer {
    padding: 20px;
    border-top: 1px solid #EEE;
    text-align: center;
    color: var(--text-light);
    font-size: 12px;
}

.menu-footer .version {
    margin-top: 5px;
    opacity: 0.6;
}

/* ===== Menu Overlay ===== */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2500;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.menu-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

/* ===== Info Modals (About, Privacy, etc.) ===== */
.info-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 4000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.info-modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.info-modal-content {
    background: var(--white);
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    padding: 30px;
    box-shadow: var(--shadow-lg);
}

.info-modal-content h2 {
    margin-bottom: 20px;
    color: var(--primary-dark);
    padding-right: 30px;
}

.info-modal-content h3 {
    margin-top: 20px;
    margin-bottom: 10px;
    color: var(--text-color);
    font-size: 16px;
}

.info-body {
    color: var(--text-color);
    line-height: 1.7;
}

.info-body p {
    margin-bottom: 12px;
}

.info-body ul, .info-body ol {
    margin-left: 20px;
    margin-bottom: 15px;
}

.info-body li {
    margin-bottom: 8px;
}

.info-body a {
    color: var(--primary-dark);
}

.info-close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-light);
    cursor: pointer;
    line-height: 1;
    padding: 5px;
}

.info-close-btn:hover {
    color: var(--text-color);
}

/* ===== Floating Add Button ===== */
.floating-btn {
    position: fixed;
    bottom: 30px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border: none;
    color: var(--white);
    font-size: 32px;
    font-weight: 300;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== Emotion Filter ===== */
.emotion-filter {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--white);
    padding: 8px 12px;
    border-radius: 30px;
    box-shadow: var(--shadow);
    z-index: 1000;
    display: flex;
    gap: 5px;
    flex-wrap: nowrap;
    max-width: 95vw;
    overflow-x: auto;
}

.filter-btn {
    padding: 8px 12px;
    border: 2px solid transparent;
    border-radius: 20px;
    background: #F5F5F5;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.filter-btn:hover {
    background: #EFEFEF;
    transform: scale(1.05);
}

.filter-btn.active {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-dark);
}

.filter-btn[data-filter="all"] {
    font-size: 14px;
    padding: 8px 14px;
}

/* ===== Help Text ===== */
.help-text {
    position: fixed;
    top: 75px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-light);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 999;
    white-space: nowrap;
}

/* ===== Marker Cluster Custom Styles ===== */
.marker-cluster {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark)) !important;
}

.marker-cluster div {
    background: var(--white) !important;
    color: var(--primary-dark) !important;
    font-weight: 600;
}

.marker-cluster-small {
    background-color: rgba(255, 179, 71, 0.6) !important;
}

.marker-cluster-small div {
    background-color: rgba(255, 179, 71, 0.9) !important;
}

.marker-cluster-medium {
    background-color: rgba(255, 159, 28, 0.6) !important;
}

.marker-cluster-medium div {
    background-color: rgba(255, 159, 28, 0.9) !important;
}

.marker-cluster-large {
    background-color: rgba(230, 126, 0, 0.6) !important;
}

.marker-cluster-large div {
    background-color: rgba(230, 126, 0, 0.9) !important;
}

.floating-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 35px rgba(255, 159, 28, 0.4);
}

.floating-btn:active {
    transform: scale(0.95);
}

/* ===== Location Status ===== */
.location-status {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--white);
    padding: 10px 20px;
    border-radius: 25px;
    box-shadow: var(--shadow);
    z-index: 1000;
    font-size: 14px;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 8px;
}

.location-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--secondary-color);
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: var(--white);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 30px 25px 40px;
    overflow-y: auto;
    transform: translateY(0);
    transition: transform 0.3s ease;
}

.modal.hidden .modal-content {
    transform: translateY(100%);
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-light);
    cursor: pointer;
    padding: 5px;
    line-height: 1;
}

.modal-content h2 {
    font-size: 24px;
    margin-bottom: 5px;
    color: var(--text-color);
}

.modal-subtitle {
    color: var(--text-light);
    margin-bottom: 25px;
    font-size: 15px;
}

/* ===== Form ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-color);
}

textarea {
    width: 100%;
    min-height: 120px;
    padding: 15px;
    border: 2px solid #E0E0E0;
    border-radius: var(--radius);
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s ease;
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

textarea::placeholder {
    color: #BDBDBD;
}

.char-count {
    display: block;
    text-align: right;
    font-size: 12px;
    color: var(--text-light);
    margin-top: 5px;
}

/* ===== Emotion Picker ===== */
.emotion-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.emotion-btn {
    padding: 10px 15px;
    border: 2px solid #E0E0E0;
    border-radius: 25px;
    background: var(--white);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.emotion-btn:hover {
    border-color: var(--primary-color);
    background: #FFF5E6;
}

.emotion-btn.selected {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: var(--white);
}

/* ===== Submit Button ===== */
.submit-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border: none;
    border-radius: var(--radius);
    color: var(--white);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(255, 159, 28, 0.4);
}

.submit-btn:active {
    transform: translateY(0);
}

.submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.btn-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid var(--white);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ===== Privacy Note ===== */
.privacy-note {
    text-align: center;
    font-size: 12px;
    color: var(--text-light);
    margin-top: 20px;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--text-color);
    color: var(--white);
    padding: 15px 25px;
    border-radius: 25px;
    font-size: 14px;
    z-index: 3000;
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    background: var(--secondary-color);
}

.toast.error {
    background: #E74C3C;
}

/* ===== Leaflet Customization ===== */
.leaflet-popup-content-wrapper {
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

.leaflet-popup-content {
    margin: 15px;
    font-size: 14px;
    line-height: 1.5;
}

/* Prevent popup from closing on mobile touch */
.leaflet-popup {
    pointer-events: auto;
}

.leaflet-popup-pane {
    pointer-events: auto;
}

/* Make close button bigger and easier to tap on mobile */
.leaflet-popup-close-button {
    width: 30px !important;
    height: 30px !important;
    font-size: 24px !important;
    line-height: 30px !important;
    padding: 0 !important;
    text-align: center;
    color: var(--text-light) !important;
}

.leaflet-popup-close-button:hover {
    color: var(--text-color) !important;
}

.story-popup {
    max-width: 250px;
}

.story-popup .emotion-tag {
    display: inline-block;
    padding: 4px 10px;
    background: #FFF5E6;
    border-radius: 15px;
    font-size: 12px;
    margin-bottom: 10px;
}

.story-popup .story-text {
    color: var(--text-color);
    margin-bottom: 8px;
}

.story-popup .story-date {
    font-size: 11px;
    color: var(--text-light);
}

.story-popup .street-view-btn {
    display: block;
    margin-top: 12px;
    padding: 8px 12px;
    background: linear-gradient(135deg, #4285F4, #34A853);
    color: white;
    text-decoration: none;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    transition: all 0.2s ease;
}

.story-popup .street-view-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(66, 133, 244, 0.4);
}

/* Custom marker styles */
.custom-marker-wrapper {
    background: transparent !important;
    border: none !important;
}

.story-marker-pin {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.marker-bubble {
    width: 44px;
    height: 44px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.25);
    border: 3px solid var(--primary-color);
    position: relative;
    z-index: 2;
}

.marker-tail {
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 14px solid var(--primary-color);
    margin-top: -3px;
    position: relative;
    z-index: 1;
}

.marker-tail::after {
    content: '';
    position: absolute;
    top: -16px;
    left: -7px;
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 10px solid white;
}

/* ===== Utility Classes ===== */
.hidden {
    display: none !important;
}

/* ===== Location Selected Prompt ===== */
.location-selected-prompt {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--white);
    padding: 15px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1500;
    opacity: 0;
    transition: all 0.3s ease;
}

.location-selected-prompt.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.prompt-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.prompt-text {
    font-weight: 500;
    color: var(--text-color);
}

.prompt-btn {
    padding: 8px 16px;
    border-radius: 20px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.add-story-btn-prompt {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: var(--white);
}

.add-story-btn-prompt:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(255, 159, 28, 0.4);
}

.cancel-btn-prompt {
    background: #E0E0E0;
    color: var(--text-color);
}

.cancel-btn-prompt:hover {
    background: #D0D0D0;
}

/* Selection marker animation */
@keyframes pulse-selection {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 4px 15px rgba(255, 159, 28, 0.5);
    }
    50% { 
        transform: scale(1.1);
        box-shadow: 0 6px 20px rgba(255, 159, 28, 0.7);
    }
}

/* ===== Install App Banner ===== */
.install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    padding: 16px 20px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    z-index: 1002;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    animation: slideUp 0.3s ease-out;
}

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

/* ===== WebView Warning Banner ===== */
.webview-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #FF6B6B, #EE5A5A);
    padding: 16px 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.webview-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.webview-icon {
    font-size: 28px;
}

.webview-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.webview-text strong {
    font-size: 16px;
    color: white;
}

.webview-text span {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9);
}

.webview-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.webview-dismiss {
    padding: 10px 16px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    background: transparent;
    color: white;
    font-size: 14px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}

.webview-dismiss:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: white;
}

.webview-open {
    padding: 10px 20px;
    border: none;
    background: white;
    color: #EE5A5A;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s, box-shadow 0.2s;
}

.webview-open:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.install-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.install-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.install-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.install-text strong {
    font-size: 15px;
    color: var(--text-color);
}

.install-text span {
    font-size: 13px;
    color: var(--text-light);
}

.install-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.install-dismiss {
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-light);
    font-size: 14px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
}

.install-dismiss:hover {
    background: var(--background);
}

.install-btn {
    padding: 10px 20px;
    border: none;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(255, 159, 28, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}

.install-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(255, 159, 28, 0.4);
}

/* Adjust floating button when banner is visible */
.install-banner:not(.hidden) ~ .floating-btn,
body:has(.install-banner:not(.hidden)) .floating-btn {
    bottom: 100px;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
    .install-banner {
        flex-direction: column;
        align-items: stretch;
        padding: 16px;
    }
    
    .install-content {
        margin-bottom: 12px;
    }
    
    .install-actions {
        justify-content: flex-end;
    }
}

/* Mobile: Move home and menu buttons below filter bar */
@media (max-width: 767px) {
    .home-btn {
        top: 145px;
    }
    
    .menu-btn {
        top: 145px;
    }
    
    .leaflet-top.leaflet-left {
        top: 200px;
    }
}

@media (min-width: 768px) {
    .modal {
        align-items: center;
    }
    
    .modal-content {
        border-radius: var(--radius-lg);
        max-height: 80vh;
    }
    
    .floating-btn {
        bottom: 40px;
        right: 40px;
        width: 70px;
        height: 70px;
        font-size: 36px;
    }
}
