/* Internal·IA Platform — Design System */

:root {
    --primary: #1a56db;
    --primary-hover: #1648b5;
    --primary-light: #e1effe;
    --success: #059669;
    --success-light: #d1fae5;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
}

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

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

/* ===== LAYOUT ===== */
#app { min-height: 100vh; }
.layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--gray-900);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform 0.3s;
}

.sidebar-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--gray-700);
}

.sidebar-header img { display: block; margin-bottom: 8px; }
.sidebar-header h1 { font-size: 18px; font-weight: 700; }
.sidebar-header .subtitle { font-size: 11px; color: var(--gray-400); text-transform: uppercase; letter-spacing: 1.5px; }

.sidebar-nav { flex: 1; padding: 8px 0; overflow-y: auto; }

.nav-section {
    padding: 16px 24px 6px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--gray-500);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 24px;
    color: var(--gray-400);
    text-decoration: none;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.12s;
    border-left: 3px solid transparent;
}

.nav-item:hover { background: var(--gray-800); color: white; }
.nav-item.active { background: rgba(26,86,219,0.12); color: #93bbfd; border-left-color: var(--primary); }
.nav-item .icon { width: 18px; text-align: center; font-size: 14px; }

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-700);
}

.sidebar-footer .user-info { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }

.sidebar-footer .user-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--primary); display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px;
}

.sidebar-footer .user-name { font-weight: 600; color: white; font-size: 13px; }
.sidebar-footer .user-role { font-size: 11px; color: var(--gray-400); }

.btn-logout {
    display: block; width: 100%; padding: 7px 12px;
    background: var(--gray-800); color: var(--gray-300);
    border: 1px solid var(--gray-700); border-radius: var(--radius);
    cursor: pointer; font-size: 12px; text-align: center;
}

.btn-logout:hover { background: var(--gray-700); color: white; }

/* Main content */
.main-content { flex: 1; margin-left: 260px; padding: 28px 36px; min-height: 100vh; }

/* Page header */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.page-header h2 { font-size: 22px; font-weight: 700; }

/* Section help */
.section-help {
    background: var(--primary-light);
    border: 1px solid #bfdbfe;
    border-radius: var(--radius-lg);
    padding: 14px 20px;
    margin-bottom: 24px;
    font-size: 13px;
    color: var(--gray-700);
    line-height: 1.6;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.section-help .help-icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.section-help .help-dismiss { margin-left: auto; cursor: pointer; color: var(--gray-400); font-size: 16px; flex-shrink: 0; }
.section-help .help-dismiss:hover { color: var(--gray-600); }

/* ===== LOGIN ===== */
.login-container {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--gray-900) 0%, #1e3a5f 100%);
}

.login-card {
    background: white; border-radius: var(--radius-lg); padding: 40px; width: 400px;
    box-shadow: var(--shadow-md);
}

.login-card h1 { text-align: center; font-size: 22px; margin-bottom: 4px; }
.login-card .subtitle { text-align: center; color: var(--gray-500); font-size: 13px; margin-bottom: 28px; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 4px; color: var(--gray-600); }

.form-input {
    width: 100%; padding: 9px 12px;
    border: 1px solid var(--gray-300); border-radius: var(--radius);
    font-size: 14px; outline: none; font-family: inherit;
}

.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

.form-select {
    width: 100%; padding: 9px 12px;
    border: 1px solid var(--gray-300); border-radius: var(--radius);
    font-size: 14px; outline: none; background: white; font-family: inherit;
}

.form-select:focus { border-color: var(--primary); }

textarea.form-input { min-height: 100px; resize: vertical; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border: none; border-radius: var(--radius);
    font-size: 13px; font-weight: 600; cursor: pointer;
    transition: all 0.12s; text-decoration: none; font-family: inherit;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #047857; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--warning); color: white; }
.btn-outline { background: white; color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-400); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== CARDS ===== */
.card {
    background: white; border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200); box-shadow: var(--shadow);
}

.card-header {
    padding: 14px 20px; border-bottom: 1px solid var(--gray-200);
    display: flex; align-items: center; justify-content: space-between;
    font-weight: 600; font-size: 14px;
}

.card-body { padding: 20px; }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }

.kpi-card {
    background: white; border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200); padding: 16px 20px; box-shadow: var(--shadow);
}

.kpi-card .kpi-label { font-size: 11px; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-card .kpi-value { font-size: 26px; font-weight: 700; margin: 2px 0; }
.kpi-card .kpi-sub { font-size: 12px; color: var(--gray-500); }

/* ===== TABLES ===== */
.table-container { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
thead th {
    text-align: left; padding: 10px 14px;
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--gray-500); background: var(--gray-50);
    border-bottom: 2px solid var(--gray-200);
}
tbody td { padding: 10px 14px; font-size: 13px; border-bottom: 1px solid var(--gray-100); }
tbody tr:hover { background: var(--gray-50); }

/* ===== BADGES ===== */
.badge {
    display: inline-block; padding: 2px 8px; border-radius: 12px;
    font-size: 11px; font-weight: 600; text-transform: uppercase; white-space: nowrap;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-info { background: var(--primary-light); color: var(--primary); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* ===== TABS ===== */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--gray-200); margin-bottom: 20px; }

.tab {
    padding: 10px 20px; font-size: 13px; font-weight: 500; color: var(--gray-500);
    cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px;
}

.tab:hover { color: var(--gray-700); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== MODAL ===== */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center;
    z-index: 1000;
}

.modal {
    background: white; border-radius: var(--radius-lg);
    width: 90%; max-width: 600px; max-height: 85vh; overflow-y: auto;
    box-shadow: var(--shadow-md);
}

.modal-header {
    padding: 16px 24px; border-bottom: 1px solid var(--gray-200);
    display: flex; align-items: center; justify-content: space-between;
    font-weight: 700; font-size: 16px; position: sticky; top: 0; background: white; z-index: 1;
}

.modal-header .close-btn { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--gray-400); padding: 4px 8px; }
.modal-header .close-btn:hover { color: var(--gray-700); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 8px; position: sticky; bottom: 0; background: white; }

/* ===== TOAST ===== */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }

.toast {
    padding: 12px 20px; border-radius: var(--radius);
    font-size: 13px; color: white; box-shadow: var(--shadow-md);
    animation: slideIn 0.3s ease; max-width: 400px;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }
.toast-info { background: var(--primary); }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== HEALTH DOTS ===== */
.health-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.health-dot.online { background: var(--success); box-shadow: 0 0 4px var(--success); }
.health-dot.degraded { background: var(--warning); }
.health-dot.offline { background: var(--danger); }
.health-dot.unknown { background: var(--gray-400); }

/* ===== CHAT ===== */
.chat-frame {
    max-width: 420px; margin: 0 auto;
    border: 1px solid var(--gray-200); border-radius: var(--radius-lg);
    overflow: hidden; background: white; box-shadow: var(--shadow-md);
}

.chat-header-bar { background: #075e54; color: white; padding: 12px 16px; font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 10px; }

.chat-messages { height: 400px; overflow-y: auto; padding: 12px 16px; background: #e5ddd5; display: flex; flex-direction: column; gap: 6px; }

.chat-bubble { max-width: 80%; padding: 8px 12px; border-radius: 8px; font-size: 13px; line-height: 1.4; }
.chat-bubble.user { background: #dcf8c6; align-self: flex-end; border-bottom-right-radius: 2px; }
.chat-bubble.bot { background: white; align-self: flex-start; border-bottom-left-radius: 2px; }
.chat-bubble .bubble-time { font-size: 10px; color: var(--gray-500); text-align: right; margin-top: 4px; }

.chat-input-bar { display: flex; gap: 8px; padding: 10px 12px; background: #f0f0f0; border-top: 1px solid var(--gray-200); }
.chat-input-bar input { flex: 1; padding: 10px 14px; border: none; border-radius: 20px; font-size: 14px; outline: none; }
.chat-input-bar button { width: 40px; height: 40px; border-radius: 50%; background: #075e54; color: white; border: none; cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; }
.chat-input-bar button:hover { background: #064e46; }

.quick-tests { display: flex; flex-wrap: wrap; gap: 6px; }
.quick-test-btn { padding: 5px 12px; background: white; border: 1px solid var(--gray-300); border-radius: 16px; font-size: 12px; cursor: pointer; }
.quick-test-btn:hover { background: var(--primary-light); border-color: var(--primary); }

/* ===== PROGRESS BAR ===== */
.progress-bar { height: 24px; border-radius: 12px; overflow: hidden; display: flex; background: var(--gray-200); }
.progress-segment { height: 100%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: white; }

/* ===== AUDIT ===== */
.audit-entry { padding: 10px 14px; border-bottom: 1px solid var(--gray-100); }
.audit-entry .audit-action { font-weight: 600; }
.audit-entry .audit-meta { color: var(--gray-500); font-size: 12px; margin-top: 2px; }

/* ===== GRIDS ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 40px 20px; color: var(--gray-500); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }

/* ===== LOADING ===== */
.spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--gray-300); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay { display: flex; align-items: center; justify-content: center; padding: 40px; color: var(--gray-500); gap: 10px; }

/* ===== STEP INDICATORS ===== */
.steps { display: flex; gap: 0; margin-bottom: 24px; }
.step {
    flex: 1; text-align: center; padding: 12px 8px; font-size: 12px; font-weight: 600;
    color: var(--gray-400); border-bottom: 3px solid var(--gray-200); position: relative;
}
.step.active { color: var(--primary); border-bottom-color: var(--primary); }
.step.done { color: var(--success); border-bottom-color: var(--success); }
.step-num { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: var(--gray-200); color: var(--gray-500); font-size: 12px; margin-bottom: 4px; }
.step.active .step-num { background: var(--primary); color: white; }
.step.done .step-num { background: var(--success); color: white; }

/* ===== RESPONSIVE ===== */
.mobile-menu-btn {
    display: none; position: fixed; top: 12px; left: 12px; z-index: 200;
    background: var(--gray-900); color: white; border: none; border-radius: var(--radius);
    padding: 8px 12px; font-size: 18px; cursor: pointer;
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; padding: 16px; }
    .mobile-menu-btn { display: block; }
    .page-header h2 { font-size: 18px; margin-left: 44px; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .modal { width: 95%; }
}

/* Help content */
.help-content { font-size: 14px; line-height: 1.7; color: var(--gray-700); }
.help-content h3 { font-size: 16px; font-weight: 700; margin: 24px 0 10px; color: var(--gray-900); }
.help-content h3:first-child { margin-top: 0; }
.help-content h4 { font-size: 14px; font-weight: 700; margin: 20px 0 8px; color: var(--gray-800); }
.help-content p { margin: 0 0 12px; }
.help-content ul { margin: 0 0 16px; }
.help-content li { margin-bottom: 4px; }
.help-content table { margin: 12px 0 16px; }
.help-content code { background: var(--gray-100); padding: 1px 6px; border-radius: 4px; font-size: 13px; }
