:root {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --accent-purple: #8b5cf6;
    --accent-cyan: #0891b2;
    --accent-glow-purple: rgba(139, 92, 246, 0.12);
    --accent-glow-cyan: rgba(8, 145, 178, 0.12);
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --border-color: rgba(15, 23, 42, 0.08);
    --border-active: rgba(139, 92, 246, 0.4);
    
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(15, 23, 42, 0.06);
    --glass-blur: blur(20px);
    
    --shadow-main: 0 10px 30px rgba(15, 23, 42, 0.06);
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
}

/* Scrollbar customization */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-purple);
}

/* Layout Container (Full screen map base) */
.app-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* Full-Screen Map Panel */
.map-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#map {
    width: 100%;
    height: 100%;
}

/* Floating Chat Panel overlay */
.chat-panel {
    position: absolute;
    top: 24px;
    left: 24px;
    bottom: 24px;
    width: 440px;
    background-color: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--shadow-main);
    display: flex;
    flex-direction: column;
    z-index: 10;
    overflow: hidden;
}

.chat-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.02);
}

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

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 0 15px var(--accent-glow-purple);
}

.agent-info h4 {
    font-size: 14px;
    font-weight: 600;
}

.status-indicator {
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-indicator .dot {
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px #10b981;
}

#clear-chat {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    padding: 6px;
    border-radius: 6px;
    transition: var(--transition-fast);
}

#clear-chat:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}

#toggle-map {
    display: none !important;
}

.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

.message.system {
    align-self: flex-start;
    max-width: 100%;
}

.message.user {
    align-self: flex-end;
}

.message.assistant {
    align-self: flex-start;
}

.message .bubble {
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.5;
    word-wrap: break-word;
}

.message.user .bubble {
    background: linear-gradient(135deg, var(--accent-purple), #7c3aed);
    color: white;
    border-bottom-right-radius: 2px;
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.25);
}

.message.assistant .bubble {
    background: rgba(15, 23, 42, 0.02);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-bottom-left-radius: 2px;
}

.message.system .bubble {
    background: rgba(6, 182, 212, 0.05);
    border: 1px solid rgba(6, 182, 212, 0.15);
    color: var(--text-primary);
    border-radius: 10px;
}

/* Markdown typography details */
.bubble strong {
    color: var(--accent-cyan);
    font-weight: 600;
}

.bubble code {
    background: rgba(15, 23, 42, 0.06);
    padding: 2px 5px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
}

.chat-input-area {
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#chat-form {
    display: flex;
    gap: 10px;
}

#chat-input {
    flex-grow: 1;
    background: rgba(15, 23, 42, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: var(--transition-fast);
}

#chat-input:focus {
    border-color: var(--border-active);
    background: rgba(15, 23, 42, 0.01);
}

#send-btn {
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    color: white;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 15px var(--accent-glow-purple);
}

#send-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--accent-glow-cyan);
    filter: brightness(1.1);
}

#send-btn:active {
    transform: translateY(1px);
}

/* Typing indicator dot animation */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    align-self: flex-start;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background-color: var(--accent-cyan);
    border-radius: 50%;
    display: inline-block;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

.typing-indicator small {
    margin-left: 6px;
    color: var(--text-secondary);
    font-size: 11px;
}

.hidden {
    display: none !important;
}

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

/* Map Overlay Card */
.map-overlay-card {
    position: absolute;
    top: 24px;
    right: 24px;
    width: 300px;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    padding: 16px;
    z-index: 10;
    box-shadow: var(--shadow-main);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.card-header h4 {
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-primary);
}

.card-header h4 i {
    color: var(--accent-cyan);
}

.card-content {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.btn-sm {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-sm:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.25);
}

/* Leaflet Popups Customization */
.leaflet-popup-content-wrapper {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 12px !important;
    box-shadow: var(--shadow-main) !important;
    font-family: 'Inter', sans-serif !important;
}

.leaflet-popup-content {
    margin: 14px !important;
    line-height: 1.4 !important;
    font-size: 12.5px !important;
}

.leaflet-popup-tip {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-color) !important;
}

.leaflet-popup-content h3 {
    color: var(--accent-cyan);
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 4px;
}

.popup-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    gap: 12px;
}

.popup-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.popup-value {
    color: var(--text-primary);
    font-weight: 600;
    text-align: right;
}

/* Badges */
.badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 10px;
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.badge-primary {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

/* Neon Text Helpers */
.neon-text-purple {
    color: var(--accent-purple);
    text-shadow: 0 0 10px var(--accent-glow-purple);
}

.gradient-text {
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Chat bubble interior markdown elements styling */
.bubble p {
    margin: 8px 0;
}
.bubble p:first-child {
    margin-top: 0;
}
.bubble p:last-child {
    margin-bottom: 0;
}

.bubble ul, .bubble ol {
    margin: 8px 0;
    padding-left: 20px;
}

.bubble li {
    margin-bottom: 4px;
}

.bubble .spacer {
    height: 8px;
}

/* Markdown tables styling */
.table-wrapper {
    overflow-x: auto;
    margin: 12px 0;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.01);
    box-shadow: inset 0 1px 4px rgba(15, 23, 42, 0.04);
}

.chat-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
    text-align: left;
}

.chat-table th {
    background: rgba(15, 23, 42, 0.02);
    color: var(--accent-cyan);
    padding: 8px 12px;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    font-family: 'Outfit', sans-serif;
}

.chat-table td {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.04);
    color: var(--text-primary);
}

.chat-table tr:last-child td {
    border-bottom: none;
}

.chat-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Mobile Responsiveness Rules */
@media (max-width: 1024px) {
    body {
        overflow: auto;
    }

    .app-container {
        display: flex;
        flex-direction: column;
        height: 100vh;
        width: 100vw;
    }
    
    .map-panel {
        position: relative;
        width: 100%;
        height: 40vh; /* Map occupies top 40% */
        z-index: 1;
    }
    
    .chat-panel {
        position: relative;
        top: 0;
        left: 0;
        bottom: 0;
        width: 100%;
        height: 60vh; /* Chat occupies bottom 60% */
        border-radius: 20px 20px 0 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
        box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.5);
        z-index: 10;
    }
    
    .map-overlay-card {
        top: 10px;
        left: 10px;
        right: auto;
        width: auto;
        max-width: 240px;
        padding: 10px 14px;
        border-radius: 8px;
        font-size: 11px;
    }
    
    .card-header {
        margin-bottom: 6px;
        padding-bottom: 4px;
    }
    
    .card-header h4 {
        font-size: 11px;
    }
    
    .card-content {
        font-size: 10px;
    }

    .chat-messages {
        padding: 16px;
        gap: 12px;
    }

    .chat-input-area {
        padding: 12px 16px;
        gap: 8px;
    }

    .message {
        max-width: 90%;
    }
    
    #chat-input {
        padding: 10px 14px;
        font-size: 13px;
    }
    
    #send-btn {
        width: 40px;
        height: 40px;
    }

    #toggle-map {
        display: inline-block !important;
    }
    
    .app-container.map-hidden .map-panel {
        display: none !important;
    }

    .app-container.map-hidden .chat-panel {
        height: 100vh !important;
        border-radius: 0 !important;
    }
}

