/* Architecture CSS - Main App Structure */

/* Global Variables - Light Mode */
:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --accent-color: #3b82f6;
    --background-color: #f8fafc;
    --surface-color: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --border-color: #e2e8f0;
    --hover-color: #f1f5f9;
    --shadow-light: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-heavy: 0 10px 15px rgba(0, 0, 0, 0.1);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --transition: all 0.2s ease;
    --header-height: 64px;
}

/* Dark Mode Variables */
[data-theme="dark"] {
    --primary-color: #3b82f6;
    --secondary-color: #94a3b8;
    --accent-color: #60a5fa;
    --background-color: #0f172a;
    --surface-color: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --border-color: #334155;
    --hover-color: #334155;
    --shadow-light: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-medium: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-heavy: 0 10px 15px rgba(0, 0, 0, 0.3);
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--background-color);
    overflow: hidden;
}

/* App Container */
#app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

/* Header */
#app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-light);
    z-index: 1000;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 32px;
}

.header-left h1 {
    font-size: 24px;
    font-weight: 600;
    color: var(--primary-color);
    margin: 0;
}

/* Mode Switcher */
#mode-switcher {
    display: flex;
    background-color: var(--hover-color);
    padding: 4px;
    border-radius: var(--radius-lg);
    gap: 2px;
}

.mode-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: none;
    background-color: transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.mode-tab:hover {
    background-color: var(--surface-color);
    color: var(--text-primary);
}

.mode-tab.active {
    background-color: var(--surface-color);
    color: var(--primary-color);
    box-shadow: var(--shadow-light);
}

.mode-icon {
    font-size: 16px;
}

.mode-label {
    font-weight: 500;
}

/* Header Actions */
.header-right {
    display: flex;
    align-items: center;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    padding: 8px 12px;
    border: none;
    background-color: transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    font-size: 16px;
    color: var(--text-secondary);
}

.action-btn:hover {
    background-color: var(--hover-color);
    color: var(--text-primary);
}

/* Main Content Area */
#app-main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Central Canvas */
#central-canvas {
    flex: 1;
    position: relative;
    overflow: hidden;
}

/* Module Styles */
.module {
    height: 100%;
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.module.active {
    opacity: 1;
    visibility: visible;
}

/* Module Workspace */
.module-header {
    padding: 24px;
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}

.module-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.module-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.workspace-content {
    display: flex;
    flex-direction: column;
    height: calc(100% - 100px);
}

/* Toolbar */
.toolbar {
    display: flex;
    gap: 8px;
    padding: 16px 24px;
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
}

.tool-btn {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    background-color: var(--surface-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.tool-btn:hover {
    background-color: var(--hover-color);
    border-color: var(--primary-color);
}

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

/* Canvas Area */
.canvas-area {
    flex: 1;
    background-color: var(--surface-color);
    position: relative;
    overflow: hidden;
}

/* Wireframe Placeholder */
.wireframe-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-secondary);
    padding: 40px;
}

.placeholder-icon {
    font-size: 64px;
    margin-bottom: 24px;
    opacity: 0.5;
}

.wireframe-placeholder h3 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.wireframe-placeholder p {
    font-size: 16px;
    margin-bottom: 8px;
    max-width: 400px;
}

.coming-soon {
    font-style: italic;
    color: var(--accent-color);
    font-weight: 500;
    margin-top: 16px;
}

/* Chat App Container */
#chat-app {
    position: fixed;
    top: var(--header-height);
    right: 0;
    bottom: 0;
    width: 400px;
    z-index: 1000;
    background-color: var(--surface-color);
    box-shadow: -2px 0 5px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

#chat-app.hidden {
    transform: translateX(100%);
}

#chat-app.minimized {
    height: 60px;
    bottom: auto;
    top: auto;
    bottom: 20px;
    width: 300px;
}

/* Chat container styles for vue-advanced-chat */
.chat-container,
.advanced-chat-container {
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    background-color: var(--surface-color);
    border-radius: 0;
    overflow: hidden;
}

/* Fallback chat styles */
.fallback-chat {
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    background-color: var(--surface-color);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.fallback-chat .chat-header {
    padding: 16px 20px;
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}

.fallback-chat .chat-header h3 {
    margin: 0 0 4px 0;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
}

.fallback-chat .chat-header p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 12px;
}

.fallback-chat .chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background-color: var(--background-color);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.fallback-chat .message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}

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

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

.fallback-chat .message-content {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    word-wrap: break-word;
    white-space: pre-wrap;
}

.fallback-chat .message.user .message-content {
    background-color: var(--primary-color);
    color: white;
}

.fallback-chat .message.assistant .message-content {
    background-color: var(--surface-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.fallback-chat .message-time {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    padding: 0 4px;
}

.fallback-chat .chat-input {
    padding: 16px;
    background-color: var(--surface-color);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.fallback-chat .chat-input textarea {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--surface-color);
    color: var(--text-primary);
    font-size: 14px;
    resize: none;
    font-family: inherit;
    transition: var(--transition);
}

.fallback-chat .chat-input textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.fallback-chat .chat-input button {
    padding: 12px 20px;
    border: none;
    background-color: var(--primary-color);
    color: white;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    flex-shrink: 0;
}

.fallback-chat .chat-input button:hover:not(:disabled) {
    background-color: var(--accent-color);
}

.fallback-chat .chat-input button:disabled {
    background-color: var(--secondary-color);
    cursor: not-allowed;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-secondary);
    animation: typing-pulse 1.4s infinite ease-in-out;
}

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

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-pulse {
    0%, 60%, 100% {
        transform: scale(1);
        opacity: 0.5;
    }
    30% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Chat error styles */
.chat-error {
    height: 100%;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--surface-color);
    padding: 20px;
}

.chat-error .error-content {
    text-align: center;
    max-width: 300px;
}

.chat-error h3 {
    color: var(--text-primary);
    margin-bottom: 12px;
    font-size: 18px;
}

.chat-error p {
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.4;
}

.chat-error button {
    padding: 10px 20px;
    border: 1px solid var(--border-color);
    background-color: var(--primary-color);
    color: white;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
}

.chat-error button:hover {
    background-color: var(--accent-color);
}


/* Loading Spinner */
#loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: var(--text-secondary);
}

#loading-spinner.hidden {
    display: none;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.spinner-text {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Chat History Panel */
#chat-history-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 500px;
    max-width: 90vw;
    height: 600px;
    max-height: 90vh;
    background-color: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-heavy);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
}

#chat-history-panel.hidden {
    display: none;
}

#history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--surface-color);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

#history-header h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

#history-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

#history-close:hover {
    background-color: var(--hover-color);
    color: var(--text-primary);
}

#history-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background-color: var(--background-color);
}

#history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-item {
    padding: 12px 16px;
    background-color: var(--surface-color);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
}

.history-item:hover {
    background-color: var(--hover-color);
    border-color: var(--primary-color);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.history-item-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.history-item-date {
    font-size: 12px;
    color: var(--text-secondary);
}

.history-item-preview {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.history-item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-secondary);
}

.history-item-model {
    background-color: var(--primary-color);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

#history-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    background-color: var(--surface-color);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.clear-history-btn {
    width: 100%;
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    background-color: var(--surface-color);
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
    font-weight: 500;
}

.clear-history-btn:hover {
    background-color: #fee2e2;
    border-color: #dc2626;
    color: #dc2626;
}

/* Responsive Design */
@media (max-width: 768px) {
    #app-header {
        padding: 12px 16px;
    }
    
    .header-left {
        gap: 16px;
    }
    
    .header-left h1 {
        font-size: 20px;
    }
    
    .mode-tab {
        padding: 8px 12px;
    }
    
    .mode-label {
        display: none;
    }
    
    #chat-app {
        width: 100%;
        top: var(--header-height);
        height: 100vh;
        z-index: 2000;
        transform: translateX(100%);
        transition: transform 0.3s ease;
    }
    
    #chat-app.visible {
        transform: translateX(0);
    }
}

/* Dark mode support for chat */
[data-theme="dark"] #chat-app {
    background-color: var(--surface-color);
    box-shadow: -2px 0 5px rgba(0,0,0,0.3);
}

[data-theme="dark"] .chat-container,
[data-theme="dark"] .advanced-chat-container,
[data-theme="dark"] .fallback-chat {
    background-color: var(--surface-color);
}

[data-theme="dark"] .fallback-chat .message.assistant .message-content {
    background-color: var(--surface-color);
    border-color: var(--border-color);
    color: var(--text-primary);
}

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

.fade-in {
    opacity: 0;
    animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
    to { opacity: 1; }
}

.fade-out {
    opacity: 1;
    animation: fadeOut 0.3s ease forwards;
}

@keyframes fadeOut {
    to { opacity: 0; }
} 

/* Map Container Height Fix */
#app-container, #app-main, #central-canvas, .module {
    height: 100vh;
}

#gis-module, #gis-workspace {
    height: 100%;
} 