:root {
    --bg-main: #0b0d14;
    --bg-card: rgba(22, 26, 42, 0.65);
    --bg-card-hover: rgba(30, 36, 58, 0.75);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-color-focus: rgba(99, 102, 241, 0.5);
    
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.35);
    --accent: #ec4899;
    --accent-glow: rgba(236, 72, 153, 0.3);
    
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dim: #6b7280;
    
    --msg-user: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    --msg-ai: rgba(255, 255, 255, 0.05);
    --msg-ai-border: rgba(255, 255, 255, 0.1);
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-code: 'Fira Code', monospace;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    overflow: hidden;
    line-height: 1.6;
}

/* Background Glowing Blobs Animation */
.bg-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    filter: blur(80px);
    opacity: 0.6;
}

.blob {
    position: absolute;
    border-radius: 50%;
    animation: float 20s infinite alternate cubic-bezier(0.45, 0, 0.55, 1);
}

.blob-1 {
    width: 450px;
    height: 450px;
    background: radial-gradient(circle, #6366f1 0%, rgba(99,102,241,0) 70%);
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #ec4899 0%, rgba(236,72,153,0) 70%);
    bottom: -150px;
    right: -100px;
    animation-delay: -7s;
}

.blob-3 {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, #8b5cf6 0%, rgba(139,92,246,0) 70%);
    top: 40%;
    left: 40%;
    animation-delay: -14s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(60px, 40px) scale(1.1); }
    100% { transform: translate(-40px, 80px) scale(0.95); }
}

/* App Container Layout */
.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    backdrop-filter: blur(20px);
    background: rgba(11, 13, 20, 0.7);
}

/* Buttons Styling */
button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    outline: none;
    transition: var(--transition);
}

.primary-btn {
    width: 100%;
    padding: 12px 18px;
    background: linear-gradient(135deg, var(--primary) 0%, #4338ca 100%);
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 15px var(--primary-glow);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.secondary-btn {
    width: 100%;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.secondary-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.3);
}

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
}

.icon-btn-small {
    background: transparent;
    color: var(--text-muted);
    padding: 6px;
    border-radius: var(--radius-sm);
}

.icon-btn-small:hover {
    color: var(--text-main);
}

/* Sidebar */
.sidebar {
    width: 320px;
    height: 100%;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 20px;
    z-index: 10;
    transition: var(--transition);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.brand-icon {
    font-size: 1.5rem;
    color: var(--accent);
    filter: drop-shadow(0 0 10px var(--accent-glow));
}

.brand h2 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #fff 0%, var(--text-muted) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-section label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.badge {
    font-size: 0.7rem;
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
    padding: 2px 6px;
    border-radius: var(--radius-full);
    margin-left: auto;
}

/* Seoul Data Status Box Styling */
.seoul-status-box {
    background: rgba(0, 168, 255, 0.08);
    border: 1px solid rgba(0, 168, 255, 0.25);
    border-radius: var(--radius-md);
    padding: 12px 14px;
}

.status-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.status-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #38bdf8;
    display: flex;
    align-items: center;
    gap: 6px;
}

.badge-status {
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-weight: 600;
}

.badge-status.success {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.4);
}

.badge-status.loading {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.4);
}

.badge-status.error {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.status-detail {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    line-height: 1.3;
}

.mini-btn {
    width: 100%;
    padding: 6px;
    font-size: 0.78rem;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: var(--transition);
}

.mini-btn:hover {
    background: rgba(56, 189, 248, 0.2);
    border-color: #38bdf8;
    color: #38bdf8;
}
input[type="text"],
input[type="password"],
select,
textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}

input[type="text"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
    border-color: var(--border-color-focus);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.select-wrapper {
    position: relative;
}

.select-wrapper select {
    appearance: none;
    cursor: pointer;
    padding-right: 32px;
}

.select-wrapper::after {
    content: "\f107";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon input {
    padding-right: 38px;
}

.input-with-icon button {
    position: absolute;
    right: 6px;
}

.hidden-input {
    display: none;
    margin-top: 4px;
}

.hidden-input.active {
    display: block;
}

/* Toggle Switch Styling */
.toggle-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 0;
}

.toggle-label {
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 600;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.15);
    transition: .3s;
    border: 1px solid var(--border-color);
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .3s;
}

input:checked + .slider {
    background-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

.help-text {
    font-size: 0.75rem;
    color: var(--text-dim);
    line-height: 1.3;
}

.sidebar-footer {
    margin-top: auto;
}

/* Main Chat Window */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

.chat-header {
    height: 64px;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(15, 17, 26, 0.4);
}

.current-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 0.95rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 10px #10b981;
}

/* Chat Split Layout & Map Panel */
.chat-body-split {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
}

/* Map Panel */
.map-panel {
    width: 360px;
    height: 100%;
    background: var(--bg-card);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 14px;
    gap: 10px;
    transition: var(--transition);
}

.map-panel.collapsed {
    display: none;
}

.map-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-main);
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
}

.badge-mini {
    font-size: 0.72rem;
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.3);
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

#map {
    flex: 1;
    width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    z-index: 1;
}

/* Leaflet Dark Custom Popup */
.leaflet-popup-content-wrapper {
    background: #1a1d2e !important;
    color: #f3f4f6 !important;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5) !important;
    padding: 2px;
}

.leaflet-popup-tip {
    background: #1a1d2e !important;
}

.map-popup-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-family: var(--font-sans);
    padding: 4px;
}

.map-popup-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
}

.map-popup-info {
    font-size: 0.78rem;
    color: #9ca3af;
}

.map-popup-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 6px;
}

.btn-popup-link {
    display: block;
    text-align: center;
    background: var(--primary);
    color: #fff !important;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
}

.btn-popup-link:hover {
    background: var(--primary-hover);
}

.btn-nav-group {
    display: flex;
    gap: 4px;
}

.btn-nav {
    flex: 1;
    text-align: center;
    padding: 5px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    text-decoration: none;
}

.btn-nav-kakao {
    background: #fee500;
    color: #000 !important;
}

.btn-nav-naver {
    background: #03cf5d;
    color: #fff !important;
}

/* Scrollbar Customization */
.chat-history::-webkit-scrollbar {
    width: 6px;
}

.chat-history::-webkit-scrollbar-track {
    background: transparent;
}

.chat-history::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.chat-history::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Welcome Card */
.welcome-card {
    max-width: 680px;
    margin: auto;
    text-align: center;
    padding: 40px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.5s ease;
}

.welcome-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: #fff;
    box-shadow: 0 10px 25px var(--primary-glow);
}

.welcome-card h1 {
    font-size: 1.5rem;
    margin-bottom: 12px;
    font-weight: 700;
}

.welcome-card p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 28px;
}

.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.chip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 10px 16px;
    border-radius: var(--radius-full);
    color: var(--text-main);
    font-size: 0.88rem;
    transition: var(--transition);
}

.chip:hover {
    background: var(--primary-glow);
    border-color: var(--primary);
    transform: translateY(-2px);
}

/* Message Bubbles */
.message-wrapper {
    display: flex;
    gap: 14px;
    max-width: 850px;
    width: 100%;
    margin: 0 auto;
    animation: messageSlide 0.3s ease-out;
}

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

.message-wrapper.user {
    flex-direction: row-reverse;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.message-wrapper.user .avatar {
    background: linear-gradient(135deg, var(--accent) 0%, #c084fc 100%);
    color: #fff;
}

.message-wrapper.assistant .avatar {
    background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
    color: #fff;
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 80%;
}

.bubble {
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    font-size: 0.95rem;
    line-height: 1.65;
    word-break: break-word;
}

.message-wrapper.user .bubble {
    background: var(--msg-user);
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.message-wrapper.assistant .bubble {
    background: var(--msg-ai);
    border: 1px solid var(--msg-ai-border);
    color: var(--text-main);
    border-bottom-left-radius: 4px;
    backdrop-filter: blur(10px);
}

/* Markdown Rendering Custom Styles inside Assistant Bubble */
.bubble p {
    margin-bottom: 0.8em;
}

.bubble p:last-child {
    margin-bottom: 0;
}

.bubble ul, .bubble ol {
    margin-left: 1.4em;
    margin-bottom: 0.8em;
}

.bubble blockquote {
    border-left: 3px solid var(--primary);
    padding-left: 12px;
    color: var(--text-muted);
    margin: 8px 0;
}

.bubble code:not(pre code) {
    background: rgba(255, 255, 255, 0.1);
    color: #f472b6;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--font-code);
    font-size: 0.88em;
}

.code-block-wrapper {
    position: relative;
    margin: 12px 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: #1a1b26;
}

.code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 14px;
    background: rgba(0, 0, 0, 0.4);
    font-family: var(--font-code);
    font-size: 0.78rem;
    color: var(--text-muted);
}

.copy-code-btn {
    background: transparent;
    color: var(--text-muted);
    font-size: 0.78rem;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 4px;
}

.copy-code-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.code-block-wrapper pre {
    margin: 0;
    padding: 14px;
    overflow-x: auto;
}

.code-block-wrapper code {
    font-family: var(--font-code);
    font-size: 0.88rem;
}

/* Typing Cursor Pulse Effect */
.typing-cursor {
    display: inline-block;
    width: 6px;
    height: 1.1em;
    background: var(--primary);
    margin-left: 4px;
    vertical-align: middle;
    animation: blink 0.8s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Bottom Input Area */
.chat-input-area {
    padding: 16px 24px 20px;
    background: rgba(15, 17, 26, 0.8);
    border-top: 1px solid var(--border-color);
}

.chat-form {
    max-width: 850px;
    margin: 0 auto;
    position: relative;
    display: flex;
    align-items: center;
}

.chat-form textarea {
    padding-right: 54px;
    resize: none;
    max-height: 160px;
    min-height: 52px;
    border-radius: var(--radius-lg);
    background: rgba(22, 26, 42, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 0.95rem;
    line-height: 1.5;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.chat-form textarea:focus {
    border-color: var(--primary);
}

.chat-form button[type="submit"] {
    position: absolute;
    right: 8px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px var(--primary-glow);
}

.chat-form button[type="submit"]:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.chat-form button[type="submit"]:disabled {
    background: var(--text-dim);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.input-footer {
    max-width: 850px;
    margin: 8px auto 0;
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-dim);
}

.mobile-only {
    display: none;
}

/* Responsive Styles */
@media (max-width: 768px) {
    .mobile-only {
        display: flex;
    }

    .sidebar {
        position: fixed;
        left: -320px;
        top: 0;
        bottom: 0;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    }

    .sidebar.open {
        left: 0;
    }

    .chat-header #open-sidebar-btn {
        display: flex;
    }

    .message-content {
        max-width: 90%;
    }
}

@media (min-width: 769px) {
    .chat-header #open-sidebar-btn {
        display: none;
    }
}
