/* Reset and Base Styles */
:root {
    --animation-duration: 0.3s;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    color: white;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

header p {
    font-size: 1.2em;
    opacity: 0.9;
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    height: calc(100vh - 200px);
}

/* Chat Section */
.chat-section {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    padding: 20px;
    text-align: center;
}

.chat-header {
    position: relative;
}

.chat-header h3 {
    font-size: 1.3em;
    font-weight: 600;
}

.settings-btn {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
}

.settings-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%) scale(1.1);
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    max-height: calc(100vh - 400px);
}

.message {
    margin-bottom: 20px;
    animation: fadeIn var(--animation-duration) ease-in;
}

.message-content {
    padding: 15px 20px;
    border-radius: 18px;
    max-width: 85%;
    line-height: 1.5;
}

.message.user .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 5px;
}

.message.assistant .message-content {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 5px;
}

.message.assistant ul {
    margin: 10px 0;
    padding-left: 20px;
}

.message.assistant li {
    margin: 5px 0;
}

.chat-input-container {
    padding: 20px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

.input-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

#userInput {
    flex: 1;
    padding: 15px 20px;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    font-size: 16px;
    outline: none;
    transition: all 0.3s ease;
}

#userInput:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#sendButton {
    padding: 15px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#sendButton:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

#sendButton:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Map Section */
.map-section {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.map-header {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.map-header h3 {
    font-size: 1.3em;
    font-weight: 600;
}

.map-controls {
    display: flex;
    gap: 10px;
}

.map-controls button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
}

.map-controls button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

#map {
    flex: 1;
    min-height: 400px;
    width: 100%;
}

/* Modal */
.modal {
    display: flex;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    max-width: 500px;
    width: 90%;
    text-align: center;
    max-height: 95vh;
    overflow-y: auto;
    position: relative;
}

.modal-content h3 {
    margin-bottom: 20px;
    color: #333;
}

.config-input {
    margin: 20px 0;
}

.config-input input {
    width: 100%;
    padding: 15px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 16px;
    margin-bottom: 10px;
}

.config-input small {
    color: #666;
    font-size: 14px;
}

.config-input a {
    color: #667eea;
    text-decoration: none;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 25px;
}

.modal-buttons button {
    padding: 12px 25px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
}

#saveConfig {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

#skipConfig {
    background: #f8f9fa;
    color: #666;
    border: 2px solid #e9ecef;
}

.modal-buttons button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* Settings Modal Styles */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.close-btn {
    background: #f8f9fa;
    border: none;
    color: #666;
    padding: 8px 12px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: #e9ecef;
    color: #333;
}

.settings-section {
    margin-bottom: 25px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 12px;
    text-align: left;
}

.settings-section h4 {
    margin-bottom: 15px;
    color: #333;
    font-size: 1.1em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.setting-item {
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.setting-item label {
    font-weight: 500;
    color: #555;
    flex: 1;
}

.setting-item input[type="range"] {
    flex: 2;
    margin-right: 10px;
}

.setting-item select {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
}

.setting-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

#zoomValue {
    background: #667eea;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    min-width: 25px;
    text-align: center;
}

.api-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: white;
    border-radius: 8px;
    margin-top: 10px;
}

.status-indicator {
    font-size: 12px;
}

#statusText {
    font-size: 14px;
    font-weight: 500;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.stat-item {
    background: white;
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.stat-number {
    display: block;
    font-size: 2em;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#saveSettings {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
}

#resetSettings {
    background: linear-gradient(135deg, #ff9800 0%, #e68900 100%);
    color: white;
}

#clearData {
    background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
    color: white;
}

/* Loading Overlay */
#loadingOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

#loadingOverlay p {
    font-size: 18px;
    color: #666;
}

/* User Location Marker */
.user-location-pulse {
    animation: pulse 2s infinite;
    font-size: 24px;
    text-align: center;
    line-height: 40px;
}

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

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .chat-section, .map-section {
        height: 50vh;
    }
    
    header h1 {
        font-size: 2em;
    }
    
    .container {
        padding: 15px;
    }
    
    #map {
        min-height: 300px;
    }

    /* Settings Modal Responsive */
    .modal-content {
        max-width: 95%;
        max-height: 90vh;
        overflow-y: auto;
        padding: 20px;
    }

    .settings-section {
        padding: 15px;
        margin-bottom: 20px;
    }

    .setting-item {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .setting-item label {
        flex: none;
        margin-bottom: 5px;
    }

    .setting-item input[type="range"] {
        flex: none;
        margin-right: 0;
        margin-bottom: 8px;
    }

    .setting-item select {
        flex: none;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .modal-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .modal-buttons button {
        width: 100%;
        padding: 15px;
    }

    .settings-btn {
        right: 15px;
        padding: 6px 10px;
        font-size: 14px;
    }

    .chat-header h3 {
        font-size: 1.1em;
        margin-right: 40px;
    }
}

@media (max-width: 480px) {
    header {
        padding: 20px;
    }
    
    header h1 {
        font-size: 1.8em;
    }
    
    .chat-messages {
        max-height: calc(50vh - 200px);
    }
    
    .message-content {
        max-width: 95%;
    }

    /* Extra small screen settings adjustments */
    .modal-content {
        padding: 15px;
        max-width: 98%;
        border-radius: 15px;
    }

    .settings-section {
        padding: 12px;
        margin-bottom: 15px;
    }

    .settings-section h4 {
        font-size: 1em;
        margin-bottom: 12px;
    }

    .config-input input {
        padding: 12px;
        font-size: 14px;
    }

    .setting-item {
        gap: 6px;
    }

    .setting-item label {
        font-size: 14px;
    }

    .stat-item {
        padding: 12px;
    }

    .stat-number {
        font-size: 1.5em;
    }

    .stat-label {
        font-size: 11px;
    }

    .modal-header {
        margin-bottom: 20px;
        padding-bottom: 12px;
    }

    .modal-header h3 {
        font-size: 1.2em;
    }

    .close-btn {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }

    .settings-btn {
        right: 10px;
        padding: 5px 8px;
        font-size: 12px;
    }

    .chat-header {
        padding: 15px;
    }

    .chat-header h3 {
        font-size: 1em;
        margin-right: 35px;
    }

    .api-status {
        padding: 10px;
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    #zoomValue {
        font-size: 11px;
        padding: 3px 6px;
        min-width: 20px;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .modal-content {
        max-height: 85vh;
        overflow-y: auto;
    }

    .settings-section {
        padding: 10px;
        margin-bottom: 15px;
    }

    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .stat-item {
        padding: 10px;
    }

    .stat-number {
        font-size: 1.3em;
    }
}

/* Tablet-specific styles */
@media (min-width: 481px) and (max-width: 768px) {
    .modal-content {
        max-width: 600px;
        padding: 25px;
    }

    .settings-section {
        padding: 18px;
    }

    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }

    .setting-item {
        flex-direction: row;
        align-items: center;
    }

    .setting-item label {
        flex: 1;
        margin-bottom: 0;
    }

    .modal-buttons {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 12px;
    }

    .modal-buttons button {
        flex: 1;
        min-width: 140px;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .settings-btn {
        min-height: 44px;
        min-width: 44px;
        padding: 10px;
    }

    .close-btn {
        min-height: 44px;
        min-width: 44px;
    }

    .modal-buttons button {
        min-height: 44px;
        padding: 12px 20px;
    }

    .setting-item input[type="checkbox"] {
        width: 24px;
        height: 24px;
    }

    .setting-item input[type="range"] {
        height: 44px;
    }

    .setting-item select {
        min-height: 44px;
        padding: 12px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .config-input input {
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 44px;
    }
}
