:root {
    --primary: #2563eb;
    --bg: #f3f4f6;
    --card-bg: #ffffff;
    --text: #1f2937;
    --border: #e5e7eb;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    margin-bottom: 30px;
    text-align: center;
}

h1 {
    margin: 0;
    font-size: 1.8rem;
    color: var(--primary);
}

p {
    margin: 5px 0 0;
    color: #6b7280;
}

/* Tabs */
.tabs {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    gap: 10px;
}

.tab-btn {
    padding: 10px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-weight: 600;
    color: #6b7280;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--primary);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Layouts */
.grid-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 768px) {
    .grid-layout {
        grid-template-columns: 1fr 1fr;
    }
}

.full-width-container {
    max-width: 800px;
    margin: 0 auto;
}

.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border);
}

h2 {
    margin-top: 0;
    font-size: 1.2rem;
    margin-bottom: 15px;
}

/* Upload & List Layout */
.col-upload {
    /* Left column */
}

.col-list {
    /* Right column */
}

@media (min-width: 768px) {
    .grid-layout {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 20px;
    }
}

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s;
}

.drop-zone:hover {
    border-color: var(--primary);
}

.doc-list {
    max-height: 400px;
    overflow-y: auto;
}

.doc-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.doc-info {
    display: flex;
    flex-direction: column;
}

.doc-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.view-btn {
    padding: 4px 10px;
    background-color: var(--bg);
    color: var(--primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s;
}

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

.delete-btn {
    padding: 4px 10px;
    background-color: white;
    color: var(--error);
    border: 1px solid var(--error);
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.delete-btn:hover {
    background-color: var(--error);
    color: white;
}

/* Chat */
.chat-box {
    height: 400px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px;
    overflow-y: auto;
    background: #f9fafb;
    margin-bottom: 15px;
}

.message {
    margin-bottom: 10px;
    display: flex;
}

.message.user {
    justify-content: flex-end;
}

.message.bot {
    justify-content: flex-start;
}

.bubble {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.4;
}

.message.user .bubble {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 2px;
}

.message.bot .bubble {
    background: #e5e7eb;
    color: var(--text);
    border-bottom-left-radius: 2px;
}

.input-area {
    display: flex;
    gap: 10px;
}

input[type="text"] {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
}

button {
    padding: 10px 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
}

button:hover {
    background: #1d4ed8;
}

/* Dashboard Styles */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.kpi-card {
    text-align: center;
    padding: 15px;
}

.kpi-card h3 {
    font-size: 0.9rem;
    color: #6b7280;
    margin-bottom: 5px;
}

.kpi-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (min-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Tablas */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th,
td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    color: #6b7280;
    font-weight: 600;
}

/* --- Modal --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: var(--card-bg);
    margin: 5% auto;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    max-height: 85vh;
}

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
}

.close-modal {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close-modal:hover {
    color: var(--text);
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    background: #f9fafb;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.modal-msg {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
    max-width: 85%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.modal-msg.user {
    align-self: flex-end;
    background-color: var(--primary);
    color: white;
    border-bottom-right-radius: 2px;
}

.modal-msg.assistant {
    align-self: flex-start;
    background-color: white;
    border: 1px solid var(--border);
    color: var(--text);
    border-bottom-left-radius: 2px;
}

.modal-msg strong {
    display: block;
    font-size: 0.75rem;
    margin-bottom: 4px;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Log Viewer Improvements */
.log-viewer {
    height: 400px;
    overflow-y: auto;
    background: #1e1e1e;
    /* Darker VS Code style */
    color: #d4d4d4;
    padding: 15px;
    border-radius: 8px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    line-height: 1.4;
    border: 1px solid #333;
}

.log-line {
    margin-bottom: 4px;
    white-space: pre-wrap;
    /* Wrap long lines */
    word-break: break-all;
    border-bottom: 1px solid #333;
    padding-bottom: 2px;
}

.log-time {
    color: #858585;
    margin-right: 8px;
}

.log-INFO {
    color: #4ec9b0;
}

.log-WARNING {
    color: #cca700;
}

.log-ERROR {
    color: #f14c4c;
    font-weight: bold;
}

.log-UNKNOWN {
    color: #d4d4d4;
}

/* Chart (Simple Bars) */
.chart-container {
    height: 200px;
    display: flex;
    align-items: flex-end;
    gap: 5px;
    padding-top: 20px;
}

.chart-bar {
    flex: 1;
    background: var(--primary);
    opacity: 0.7;
    border-radius: 4px 4px 0 0;
    transition: height 0.3s;
    position: relative;
}

.chart-bar:hover {
    opacity: 1;
}

.chart-bar:hover::after {
    content: attr(data-val);
    position: absolute;
    top: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
}