/* --- Global Styles & Variables --- */
:root {
    --primary-color: #4f46e5; /* Indigo */
    --primary-hover-color: #4338ca;
    --secondary-color: #10b981; /* Emerald */
    --background-color: #f9fafb; /* Light Gray */
    --surface-color: #ffffff; /* White */
    --text-primary: #111827; /* Dark Gray */
    --text-secondary: #6b7280; /* Medium Gray */
    --border-color: #e5e7eb; /* Light Gray Border */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --border-radius: 0.5rem;
    --transition: all 0.2s ease-in-out;
}

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

body {
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--background-color);
}

.dashboard-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

/* --- Header / Hero Section --- */
.dashboard-header {
    background: linear-gradient(135deg, var(--primary-color), #6366f1); /* Slightly lighter indigo for gradient */
    color: white;
    padding: 3rem 2rem;
    border-radius: var(--border-radius);
    margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.dashboard-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.tagline {
    font-size: 1.125rem;
    font-weight: 300;
    opacity: 0.9;
    margin-bottom: 1.5rem;
}

.stats-container {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.stat-item {
    background-color: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    padding: 1rem 1.5rem;
    border-radius: calc(var(--border-radius) - 0.2rem);
    text-align: center;
    min-width: 120px;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    display: block;
}

.stat-label {
    font-size: 0.875rem;
    opacity: 0.9;
}

/* --- UniversalRAG Link --- */
.universal-rag-link {
    margin: 1.5rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.universal-rag-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border-radius: calc(var(--border-radius) - 0.2rem);
    font-weight: 600;
    font-size: 1rem;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.universal-rag-button:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.6);
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.universal-rag-button:active {
    transform: translateY(0) scale(0.98);
}

.rag-hint {
    font-size: 0.8rem;
    opacity: 0.85;
    font-style: italic;
    color: rgba(255, 255, 255, 0.9);
}

/* --- Main Content Area --- */
.dashboard-main {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

section {
    background-color: var(--surface-color);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
}

section h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.5rem;
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

/* --- Ask Your Project Interface --- */
.query-container {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

#user-query {
    flex-grow: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: calc(var(--border-radius) - 0.2rem);
    font-size: 1rem;
    transition: var(--transition);
}

#user-query:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

#ask-button {
    padding: 0.75rem 1.5rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: calc(var(--border-radius) - 0.2rem);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

#ask-button:hover {
    background-color: var(--primary-hover-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.response-container {
    background-color: #f3f4f6; /* Lighter gray for response */
    border-left: 4px solid var(--secondary-color);
    padding: 1rem;
    border-radius: 0.25rem;
    min-height: 60px;
    white-space: pre-wrap; /* Preserve whitespace and line breaks */
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    color: var(--text-primary);
}

/* --- Project Summary --- */
.summary-content {
    background-color: #f9fafb; /* Very light gray */
    padding: 1.25rem;
    border-radius: calc(var(--border-radius) - 0.2rem);
    line-height: 1.8;
}

.summary-content h3, .summary-content h4 {
    color: var(--primary-color);
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.summary-content ul {
    list-style-type: disc;
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

.summary-content li {
    margin-bottom: 0.25rem;
}

/* --- Project Explorer / Tabs --- */
.tab-container {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.tab-button {
    padding: 0.75rem 1.25rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.tab-button.active,
.tab-button:hover {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    min-height: 300px; /* Ensure tabs have some height */
}

.document-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.document-card {
    background-color: #f9fafb;
    border: 1px solid var(--border-color);
    border-radius: calc(var(--border-radius) - 0.2rem);
    padding: 1rem;
    cursor: pointer;
    transition: var(--transition);
}

.document-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}

.document-card h4 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.document-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* --- RAG System Health --- */
.health-content p {
    margin-bottom: 0.75rem;
}

#rag-log-snippet {
    background-color: #1f2937; /* Dark gray for log */
    color: #d1d5db; /* Light gray for text */
    padding: 1rem;
    border-radius: calc(var(--border-radius) - 0.2rem);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    white-space: pre-wrap;
    overflow-x: auto;
    margin-bottom: 1rem;
}

.action-button {
    padding: 0.625rem 1.25rem;
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: calc(var(--border-radius) - 0.2rem);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.action-button:hover {
    background-color: #059669; /* Darker emerald */
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.update-status {
    margin-top: 0.75rem;
    font-weight: 500;
    min-height: 1.2em; /* Space for status text */
}

.update-status.success { color: var(--secondary-color); }
.update-status.error { color: #ef4444; } /* Red */
.update-status.info { color: var(--primary-color); }

/* --- Documentation Viewer Modal --- */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1000; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5); /* Black background with opacity */
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: var(--surface-color);
    margin: 2% auto; /* 2% from the top and centered */
    padding: 0;
    border-radius: var(--border-radius);
    width: 80%;
    max-width: 900px;
    max-height: 85vh;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Ensure content doesn't spill out */
}

.modal-header {
    padding: 1rem 1.5rem;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.close-button {
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    background: none;
    border: none;
    line-height: 1;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.close-button:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto; /* Scroll if content is too tall */
    flex-grow: 1; /* Allow modal body to take available space */
}

/* Responsive Design */
@media (max-width: 768px) {
    .dashboard-container {
        padding: 0.5rem;
    }

    .dashboard-header {
        padding: 2rem 1rem;
    }

    .dashboard-header h1 {
        font-size: 2rem;
    }

    .stats-container {
        gap: 1rem;
    }

    .stat-item {
        min-width: 100px;
        padding: 0.75rem 1rem;
    }

    .document-grid {
        grid-template-columns: 1fr; /* Single column on small screens */
    }

    .modal-content {
        width: 95%;
        margin: 5% auto;
    }

    .tab-container {
        flex-wrap: wrap;
    }
    .tab-button {
        flex: 1 1 calc(50% - 0.5rem); /* Two buttons per row on small screens */
        text-align: center;
    }
}
