/* === Generis AI Dashboard — Cosmic Dark Theme === */
:root {
    --bg: #0a0a0f;
    --bg-card: #12121a;
    --bg-card-hover: #1a1a2e;
    --bg-sidebar: #0e0e16;
    --primary: #6c5ce7;
    --primary-rgb: 108,92,231;
    --primary-light: #a29bfe;
    --accent: #00cec9;
    --accent-rgb: 0,206,201;
    --accent2: #fd79a8;
    --accent2-rgb: 253,121,168;
    --text: #e2e2e2;
    --text-dim: #8b8b9e;
    --border: #1e1e2e;
    --glow: rgba(108,92,231,0.3);
    --success: #00b894;
    --warning: #fdcb6e;
    --danger: #e17055;
    --sidebar-w: 250px;
    --topbar-h: 60px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg); color: var(--text);
    line-height: 1.6; overflow-x: hidden;
}

a { color: var(--primary-light); text-decoration: none; }
a:hover { color: var(--accent); }

/* === LAYOUT === */
.dashboard-layout {
    display: flex; min-height: 100vh;
}
.sidebar {
    width: var(--sidebar-w); background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    position: fixed; top: 0; left: 0; bottom: 0;
    display: flex; flex-direction: column; z-index: 100;
    transition: transform .3s ease;
}
.sidebar-logo {
    padding: 20px 24px; border-bottom: 1px solid var(--border);
    font-size: 1.3rem; font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}
.sidebar-logo span { font-size: .7rem; color: var(--text-dim); -webkit-text-fill-color: var(--text-dim); display: block; margin-top: 2px; }
.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; border-radius: 10px;
    color: var(--text-dim); font-size: .9rem; font-weight: 500;
    transition: all .2s; margin-bottom: 2px;
}
.sidebar-nav a:hover { background: rgba(var(--primary-rgb),.1); color: var(--text); }
.sidebar-nav a.active { background: rgba(var(--primary-rgb),.15); color: var(--primary-light); }
.sidebar-nav a .icon { font-size: 1.15rem; width: 24px; text-align: center; }
.sidebar-nav .divider { height: 1px; background: var(--border); margin: 12px 0; }
.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); }
.sidebar-footer .plan-badge {
    display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: .7rem; font-weight: 600;
    background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff;
}

.main-content {
    flex: 1; margin-left: var(--sidebar-w);
}
.topbar {
    height: var(--topbar-h); background: rgba(10,10,15,.85);
    backdrop-filter: blur(20px); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 28px; position: sticky; top: 0; z-index: 90;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-left h2 { font-size: 1.1rem; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-user { display: flex; align-items: center; gap: 8px; font-size: .9rem; }
.topbar-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .8rem; color: #fff;
}

.page-content { padding: 28px; max-width: 1400px; }

/* === HAMBURGER === */
.hamburger {
    display: none; background: none; border: none; color: var(--text);
    font-size: 1.5rem; cursor: pointer; padding: 4px;
}
.sidebar-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 99;
}

/* === CARDS === */
.card {
    background: rgba(18,18,26,.7); border: 1px solid var(--border);
    border-radius: 16px; padding: 24px;
    backdrop-filter: blur(10px);
    transition: all .3s ease;
}
.card:hover { border-color: rgba(var(--primary-rgb),.3); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-header h3 { font-size: 1rem; font-weight: 600; }

/* === STAT CARDS === */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 28px; }
.stat-card {
    background: rgba(18,18,26,.7); border: 1px solid var(--border);
    border-radius: 16px; padding: 22px;
    backdrop-filter: blur(10px); transition: all .3s;
    position: relative; overflow: hidden;
}
.stat-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    opacity: 0; transition: opacity .3s;
}
.stat-card:hover::before { opacity: 1; }
.stat-card:hover { border-color: rgba(var(--primary-rgb),.3); transform: translateY(-2px); }
.stat-icon { font-size: 1.8rem; margin-bottom: 10px; }
.stat-label { font-size: .8rem; color: var(--text-dim); margin-bottom: 4px; }
.stat-value { font-size: 1.7rem; font-weight: 700; }

/* === TABLES === */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: .85rem; }
th { color: var(--text-dim); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .5px; }
tr:hover td { background: rgba(var(--primary-rgb),.04); }
.badge {
    display: inline-block; padding: 2px 10px; border-radius: 20px;
    font-size: .7rem; font-weight: 600;
}
.badge-success { background: rgba(0,184,148,.15); color: var(--success); }
.badge-warning { background: rgba(253,203,110,.15); color: var(--warning); }
.badge-danger { background: rgba(225,112,85,.15); color: var(--danger); }
.badge-primary { background: rgba(var(--primary-rgb),.15); color: var(--primary-light); }
.badge-accent { background: rgba(var(--accent-rgb),.15); color: var(--accent); }

/* === BUTTONS === */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 20px; border-radius: 10px; border: none;
    font-family: inherit; font-size: .85rem; font-weight: 600;
    cursor: pointer; transition: all .3s; text-decoration: none;
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary), #5a4bd1);
    color: #fff; box-shadow: 0 4px 15px rgba(var(--primary-rgb),.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(var(--primary-rgb),.4); }
.btn-secondary {
    background: rgba(var(--primary-rgb),.1); color: var(--primary-light);
    border: 1px solid rgba(var(--primary-rgb),.2);
}
.btn-secondary:hover { background: rgba(var(--primary-rgb),.2); }
.btn-danger { background: rgba(225,112,85,.15); color: var(--danger); border: 1px solid rgba(225,112,85,.2); }
.btn-danger:hover { background: rgba(225,112,85,.25); }
.btn-sm { padding: 6px 14px; font-size: .78rem; }
.btn-icon { padding: 8px; width: 36px; height: 36px; justify-content: center; border-radius: 8px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* === FORMS === */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: .8rem; font-weight: 600; color: var(--text-dim); margin-bottom: 6px; }
.form-input, .form-select, .form-textarea {
    width: 100%; padding: 10px 14px; border-radius: 10px;
    border: 1px solid var(--border); background: rgba(10,10,15,.6);
    color: var(--text); font-family: inherit; font-size: .9rem;
    transition: border-color .3s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb),.15);
}
.form-textarea { min-height: 100px; resize: vertical; }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238b8b9e' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.form-check { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; cursor: pointer; }
.form-check input[type="checkbox"] { accent-color: var(--primary); width: 16px; height: 16px; }
.form-check label { font-size: .85rem; cursor: pointer; }
.form-range { width: 100%; accent-color: var(--primary); }
.form-hint { font-size: .75rem; color: var(--text-dim); margin-top: 4px; }

/* === MODAL === */
.modal-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.7);
    z-index: 200; align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 20px; padding: 32px; width: 90%; max-width: 600px;
    max-height: 90vh; overflow-y: auto;
    animation: modalIn .3s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.modal-header h3 { font-size: 1.2rem; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-dim); font-size: 1.5rem; cursor: pointer; }
.modal-close:hover { color: var(--text); }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

/* === TABS === */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tab-btn {
    padding: 10px 20px; border: none; background: none;
    color: var(--text-dim); font-family: inherit; font-size: .85rem; font-weight: 600;
    cursor: pointer; border-bottom: 2px solid transparent;
    transition: all .2s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary-light); border-bottom-color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* === TOAST === */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
    padding: 12px 20px; border-radius: 10px; font-size: .85rem; font-weight: 500;
    background: var(--bg-card); border: 1px solid var(--border);
    box-shadow: 0 10px 30px rgba(0,0,0,.4);
    animation: toastIn .3s ease;
    display: flex; align-items: center; gap: 8px;
}
.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-info { border-left: 3px solid var(--accent); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateX(20px); } }

/* === EMPTY STATE === */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-state .emoji { font-size: 3rem; margin-bottom: 12px; }
.empty-state h3 { font-size: 1.1rem; margin-bottom: 8px; }
.empty-state p { color: var(--text-dim); font-size: .9rem; margin-bottom: 20px; }

/* === SKELETON LOADING === */
.skeleton { background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%); background-size: 200% 100%; animation: shimmer 1.5s infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-text { height: 14px; margin-bottom: 8px; }
.skeleton-card { height: 120px; border-radius: 16px; }

/* === LANGUAGE TOGGLE === */
.lang-toggle {
    display: flex; border-radius: 8px; overflow: hidden; border: 1px solid var(--border);
}
.lang-toggle button {
    padding: 4px 10px; border: none; background: transparent;
    color: var(--text-dim); font-size: .75rem; font-weight: 600;
    cursor: pointer; transition: all .2s;
}
.lang-toggle button.active { background: var(--primary); color: #fff; }

/* === CHAT === */
.chat-container { display: flex; flex-direction: column; height: 500px; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.chat-msg { max-width: 80%; padding: 10px 16px; border-radius: 14px; font-size: .85rem; line-height: 1.5; }
.chat-msg.user { background: var(--primary); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.chat-msg.bot { background: var(--bg-card-hover); color: var(--text); align-self: flex-start; border-bottom-left-radius: 4px; }
.chat-input-area { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); background: rgba(10,10,15,.5); }
.chat-input { flex: 1; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border); background: rgba(10,10,15,.6); color: var(--text); font-family: inherit; font-size: .85rem; }
.chat-input:focus { outline: none; border-color: var(--primary); }

/* === UPLOAD AREA === */
.upload-area {
    border: 2px dashed var(--border); border-radius: 16px;
    padding: 40px; text-align: center; cursor: pointer;
    transition: all .3s;
}
.upload-area:hover, .upload-area.dragover { border-color: var(--primary); background: rgba(var(--primary-rgb),.05); }
.upload-area .emoji { font-size: 2.5rem; margin-bottom: 8px; }

/* === DATE PICKER === */
.date-range { display: flex; align-items: center; gap: 8px; }
.date-range input[type="date"] {
    padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border);
    background: rgba(10,10,15,.6); color: var(--text); font-family: inherit; font-size: .8rem;
}
.date-range input[type="date"]:focus { outline: none; border-color: var(--primary); }

/* === CHART === */
.chart-card { padding: 20px; }
.chart-wrap { position: relative; height: 300px; }

/* === TOGGLE SWITCH === */
.toggle { position: relative; width: 44px; height: 24px; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; inset: 0; background: var(--border); border-radius: 24px; transition: .3s;
}
.toggle-slider::before {
    content: ''; position: absolute; width: 18px; height: 18px;
    left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .3s;
}
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* === AGENT CARDS GRID === */
.agents-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }
.agent-card { position: relative; }
.agent-card .agent-status { position: absolute; top: 20px; right: 20px; }
.agent-card h4 { font-size: 1rem; margin-bottom: 4px; }
.agent-card .agent-type { font-size: .8rem; color: var(--text-dim); margin-bottom: 12px; }
.agent-card .agent-channels { display: flex; gap: 6px; margin-bottom: 12px; }
.agent-card .agent-channels span { font-size: .7rem; padding: 2px 8px; border-radius: 6px; background: rgba(var(--primary-rgb),.1); color: var(--primary-light); }
.agent-card .agent-stats { display: flex; gap: 16px; font-size: .8rem; color: var(--text-dim); }
.agent-card .agent-actions { display: flex; gap: 8px; margin-top: 14px; }

/* === AUTH PAGES === */
.auth-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: var(--bg);
    position: relative;
}
.auth-page::before {
    content: ''; position: absolute; inset: 0;
    background: radial-gradient(ellipse at 30% 50%, rgba(var(--primary-rgb),.1) 0%, transparent 60%),
                radial-gradient(ellipse at 70% 30%, rgba(var(--accent-rgb),.08) 0%, transparent 60%);
}
.auth-card {
    background: rgba(18,18,26,.8); border: 1px solid var(--border);
    border-radius: 24px; padding: 40px; width: 90%; max-width: 420px;
    backdrop-filter: blur(20px); position: relative; z-index: 1;
}
.auth-card h1 {
    font-size: 1.6rem; font-weight: 800; margin-bottom: 4px;
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.auth-card .subtitle { color: var(--text-dim); font-size: .9rem; margin-bottom: 28px; }
.auth-card .auth-footer { text-align: center; margin-top: 20px; font-size: .85rem; color: var(--text-dim); }
.auth-card .auth-footer a { color: var(--primary-light); }
.auth-card .auth-lang { position: absolute; top: 16px; right: 16px; }

/* === SETTINGS SECTIONS === */
.settings-section { margin-bottom: 36px; }
.settings-section h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.api-key-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid rgba(var(--primary-rgb),.05); }
.api-key-row code { font-family: 'JetBrains Mono', monospace; font-size: .8rem; color: var(--accent); flex: 1; }

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
    .main-content { margin-left: 0; }
    .hamburger { display: block; }
    .page-content { padding: 16px; }
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
    .agents-grid { grid-template-columns: 1fr; }
    .modal { width: 95%; padding: 24px; }
    .topbar { padding: 0 16px; }
    .chart-wrap { height: 220px; }
}
