/* TeleAI - Dark Theme CSS */
:root {
  --bg-primary: #1a1b2e;
  --bg-secondary: #252640;
  --bg-tertiary: #2d2e4a;
  --bg-hover: #33345a;
  --text-primary: #e2e4f0;
  --text-secondary: #9a9cc0;
  --text-muted: #6b6d8a;
  --accent: #4f8fff;
  --accent-hover: #3a7aee;
  --border: #3a3b5c;
  --green: #22c55e;
  --orange: #f59e0b;
  --red: #ef4444;
  --purple: #a855f7;
  --teal: #14b8a6;
  --yellow: #eab308;
  --sidebar-width: 220px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg-primary); color: var(--text-primary); min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* Layout */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-width); background: var(--bg-secondary); border-right: 1px solid var(--border); position: fixed; top: 0; bottom: 0; display: flex; flex-direction: column; z-index: 100; }
.sidebar-logo { padding: 20px; font-size: 1.4rem; font-weight: 700; color: var(--accent); border-bottom: 1px solid var(--border); }
.sidebar-logo span { color: var(--text-primary); }
.sidebar-nav { flex: 1; padding: 12px 0; }
.sidebar-nav a { display: flex; align-items: center; padding: 10px 20px; color: var(--text-secondary); font-size: 0.9rem; transition: all 0.15s; }
.sidebar-nav a:hover, .sidebar-nav a.active { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-nav a.active { border-left: 3px solid var(--accent); }

.main-wrap { flex: 1; margin-left: var(--sidebar-width); display: flex; flex-direction: column; min-height: 100vh; }
.topbar { background: var(--bg-secondary); border-bottom: 1px solid var(--border); padding: 12px 24px; display: flex; justify-content: flex-end; align-items: center; gap: 12px; }
.topbar .user-info { display: flex; align-items: center; gap: 8px; }
.main-content { flex: 1; padding: 24px; }
.footer { padding: 12px 24px; border-top: 1px solid var(--border); font-size: 0.8rem; color: var(--text-muted); display: flex; justify-content: space-between; }

/* Cards */
.card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px; padding: 20px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-title { font-size: 1.1rem; font-weight: 600; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
.stat-card .stat-value { font-size: 2rem; font-weight: 700; }
.stat-card .stat-label { color: var(--text-secondary); font-size: 0.85rem; margin-top: 4px; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text-secondary); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
tr:hover td { background: var(--bg-tertiary); }

/* Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; }
.badge-draft { background: #3a3b5c; color: #9a9cc0; }
.badge-monitoring { background: #1e3a5f; color: #4f8fff; }
.badge-evaluated { background: #3b1f6e; color: #a855f7; }
.badge-approved { background: #4a3a0a; color: #eab308; }
.badge-active, .badge-online { background: #0a3a1e; color: #22c55e; }
.badge-paused { background: #4a2a0a; color: #f59e0b; }
.badge-completed { background: #0a3a3a; color: #14b8a6; }
.badge-admin { background: #1e3a5f; color: #4f8fff; }
.badge-superadmin { background: #3b1f6e; color: #a855f7; }
.badge-offline { background: #3a1a1a; color: #ef4444; }

/* Status dots */
.status-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.status-dot.green { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.orange { background: var(--orange); }
.status-dot.red { background: var(--red); box-shadow: 0 0 6px var(--red); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 6px; border: none; font-size: 0.9rem; font-weight: 500; cursor: pointer; transition: all 0.15s; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { opacity: 0.9; }
.btn-warning { background: var(--orange); color: #000; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border); }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 0.85rem; color: var(--text-secondary); font-weight: 500; }
.form-control { width: 100%; padding: 8px 12px; background: var(--bg-primary); border: 1px solid var(--border); border-radius: 6px; color: var(--text-primary); font-size: 0.9rem; }
.form-control:focus { outline: none; border-color: var(--accent); }
textarea.form-control { min-height: 80px; resize: vertical; }
select.form-control { appearance: auto; }
.radio-group { display: flex; gap: 16px; margin-top: 4px; }
.radio-group label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Flash messages */
.flash { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 0.9rem; display: flex; justify-content: space-between; align-items: center; }
.flash-success { background: #0a3a1e; border: 1px solid var(--green); color: var(--green); }
.flash-error { background: #3a1a1a; border: 1px solid var(--red); color: var(--red); }
.flash-close { cursor: pointer; opacity: 0.7; background: none; border: none; color: inherit; font-size: 1.2rem; }

/* Progress bars */
.progress-bar { background: var(--bg-primary); border-radius: 4px; height: 8px; overflow: hidden; }
.progress-bar .fill { height: 100%; border-radius: 4px; transition: width 0.3s; }
.progress-bar .fill.green { background: var(--green); }
.progress-bar .fill.blue { background: var(--accent); }
.progress-bar .fill.orange { background: var(--orange); }
.progress-bar .fill.red { background: var(--red); }

/* Funnel */
.funnel { margin: 20px 0; }
.funnel-step { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.funnel-label { width: 140px; text-align: right; font-size: 0.85rem; color: var(--text-secondary); }
.funnel-bar-wrap { flex: 1; }
.funnel-bar { height: 28px; border-radius: 4px; display: flex; align-items: center; padding: 0 10px; font-size: 0.8rem; font-weight: 600; color: #fff; transition: width 0.3s; }
.funnel-value { width: 60px; text-align: right; font-size: 0.85rem; }

/* Chat */
.chat-container { display: flex; gap: 20px; }
.chat-messages { flex: 1; }
.chat-sidebar { width: 260px; }
.message { max-width: 70%; margin-bottom: 12px; padding: 10px 14px; border-radius: 12px; font-size: 0.9rem; line-height: 1.4; }
.message.inbound { background: var(--bg-tertiary); border-bottom-left-radius: 4px; margin-right: auto; }
.message.outbound { background: #1e3a5f; border-bottom-right-radius: 4px; margin-left: auto; }
.message .meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.phase-divider { text-align: center; padding: 8px; margin: 16px 0; border-top: 1px solid var(--border); }
.phase-divider span { background: var(--bg-primary); padding: 0 12px; font-size: 0.8rem; color: var(--accent); text-transform: uppercase; }
.alignment-big { font-size: 2.5rem; font-weight: 700; }

/* Provider cards */
.provider-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.model-list { margin-top: 12px; }
.model-item { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; border-top: 1px solid var(--border); font-size: 0.85rem; }

/* Login page */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg-primary); }
.login-card { width: 380px; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 12px; padding: 40px 32px; }
.login-card h1 { text-align: center; margin-bottom: 8px; color: var(--accent); }
.login-card .subtitle { text-align: center; color: var(--text-muted); margin-bottom: 28px; font-size: 0.9rem; }
.login-error { background: #3a1a1a; border: 1px solid var(--red); color: var(--red); padding: 8px 12px; border-radius: 6px; margin-bottom: 16px; font-size: 0.85rem; }

/* Utilities */
.text-muted { color: var(--text-muted); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-orange { color: var(--orange); }
.mb-0 { margin-bottom: 0; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 250px; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.page-header h1 { font-size: 1.5rem; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-wrap { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .chat-container { flex-direction: column; }
  .chat-sidebar { width: 100%; }
  .funnel-label { width: 80px; }
  .message { max-width: 90%; }
}
