/* ========== Lexi Dashboard — Style System ========== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #0f0f0f;
  --bg-secondary: #1a1a1a;
  --bg-card: #252525;
  --bg-card-hover: #2a2a2a;
  --bg-input: #1e1e1e;
  --accent: #f59e0b;
  --accent-hover: #d97706;
  --accent-glow: rgba(245, 158, 11, 0.15);
  --text-primary: #f0f0f0;
  --text-secondary: #999;
  --text-muted: #666;
  --border: #333;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.2);
  --transition: all 0.2s ease;
  --sidebar-width: 240px;
  --header-height: 64px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

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

/* ========== Scrollbar ========== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* ========== Login Page ========== */
.login-wrapper {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: radial-gradient(ellipse at center, #1a1a1a 0%, #0f0f0f 70%);
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 40px;
  width: 100%; max-width: 400px;
  box-shadow: var(--shadow);
  text-align: center;
  animation: fadeUp 0.5s ease;
}

.login-logo { font-size: 64px; margin-bottom: 8px; }
.login-card h1 { font-size: 24px; font-weight: 600; margin-bottom: 4px; }
.login-card .subtitle { color: var(--text-secondary); margin-bottom: 32px; font-size: 14px; }

.form-group { margin-bottom: 16px; text-align: left; }
.form-group label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; font-weight: 500; }

.form-input {
  width: 100%; padding: 12px 16px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-size: 14px; font-family: inherit;
  transition: var(--transition); outline: none;
}
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-input::placeholder { color: var(--text-muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 24px; border: none; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: var(--transition); outline: none;
}
.btn-primary {
  background: var(--accent); color: #000; width: 100%;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--bg-card); color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); background: var(--bg-card-hover); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }

.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-icon { padding: 8px; width: 36px; height: 36px; }

.login-error {
  color: var(--danger); font-size: 13px; margin-top: 12px;
  display: none;
}

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

/* Sidebar */
.sidebar {
  width: var(--sidebar-width); background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100; transition: transform 0.3s ease;
}

.sidebar-brand {
  padding: 20px 24px; display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand .logo { font-size: 28px; }
.sidebar-brand h2 { font-size: 18px; font-weight: 700; color: var(--accent); }

.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 14px; font-weight: 500;
  transition: var(--transition); cursor: pointer;
}
.nav-item:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active { background: var(--accent-glow); color: var(--accent); }
.nav-item .icon { font-size: 18px; width: 24px; text-align: center; }

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

/* Main Content */
.main-content {
  flex: 1; margin-left: var(--sidebar-width);
  display: flex; flex-direction: column;
}

.header {
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px; position: sticky; top: 0; z-index: 50;
}

.header h1 { font-size: 20px; font-weight: 600; }
.header-actions { display: flex; align-items: center; gap: 12px; }

.mobile-toggle {
  display: none; background: none; border: none;
  color: var(--text-primary); font-size: 24px; cursor: pointer;
}

.page-content { padding: 32px; flex: 1; animation: fadeUp 0.3s ease; }

/* ========== Cards & Grid ========== */
.grid { display: grid; gap: 20px; }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(400px, 1fr)); }

.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
  transition: var(--transition);
}
.card:hover { border-color: #444; box-shadow: var(--shadow-sm); }

.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 14px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }

.stat-value { font-size: 28px; font-weight: 700; margin-bottom: 4px; }
.stat-label { font-size: 13px; color: var(--text-secondary); }

/* ========== Status LED ========== */
.led {
  width: 12px; height: 12px; border-radius: 50%;
  display: inline-block; position: relative;
}
.led::after {
  content: ''; position: absolute; inset: -4px;
  border-radius: 50%; animation: pulse 2s infinite;
}
.led-green { background: var(--success); box-shadow: 0 0 8px var(--success); }
.led-green::after { background: rgba(34,197,94,0.3); }
.led-yellow { background: var(--warning); box-shadow: 0 0 8px var(--warning); }
.led-yellow::after { background: rgba(245,158,11,0.3); }
.led-red { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.led-red::after { background: rgba(239,68,68,0.3); }

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.8); opacity: 0; }
}

/* ========== Badges ========== */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.badge-success { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-info { background: rgba(59,130,246,0.15); color: var(--info); }

/* ========== Tables ========== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; font-size: 14px; }
th { color: var(--text-secondary); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); }
td { border-bottom: 1px solid var(--border); }
tr:hover td { background: rgba(255,255,255,0.02); }

/* ========== Chat ========== */
.chat-container {
  display: flex; flex-direction: column;
  height: calc(100vh - var(--header-height) - 64px);
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}

.chat-messages {
  flex: 1; padding: 24px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 16px;
}

.message { display: flex; gap: 12px; max-width: 75%; animation: fadeUp 0.2s ease; }
.message-bot { align-self: flex-start; }
.message-user { align-self: flex-end; flex-direction: row-reverse; }

.message-bubble {
  padding: 12px 16px; border-radius: 16px;
  font-size: 14px; line-height: 1.5;
}
.message-bot .message-bubble {
  background: linear-gradient(135deg, #3d2800, #2d1f00);
  border: 1px solid rgba(245,158,11,0.2);
  border-bottom-left-radius: 4px;
}
.message-user .message-bubble {
  background: #333; border: 1px solid #444;
  border-bottom-right-radius: 4px;
}

.message-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.message-bot .message-avatar { background: var(--accent-glow); }
.message-user .message-avatar { background: #333; }

.message-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.chat-input-bar {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; gap: 12px; background: var(--bg-secondary);
}
.chat-input-bar input {
  flex: 1; padding: 12px 16px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 24px; color: var(--text-primary);
  font-size: 14px; font-family: inherit; outline: none;
  transition: var(--transition);
}
.chat-input-bar input:focus { border-color: var(--accent); }
.chat-input-bar button {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--accent); border: none; color: #000;
  font-size: 18px; cursor: pointer; transition: var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.chat-input-bar button:hover { background: var(--accent-hover); transform: scale(1.05); }

/* ========== Accordion ========== */
.accordion-item { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.accordion-item + .accordion-item { margin-top: 8px; }

.accordion-header {
  padding: 16px 20px; background: var(--bg-card);
  display: flex; align-items: center; justify-content: space-between;
  cursor: pointer; transition: var(--transition);
  font-weight: 500;
}
.accordion-header:hover { background: var(--bg-card-hover); }
.accordion-arrow { transition: transform 0.2s ease; }
.accordion-item.open .accordion-arrow { transform: rotate(180deg); }

.accordion-body {
  max-height: 0; overflow: hidden;
  transition: max-height 0.3s ease;
}
.accordion-body-inner { padding: 16px 20px; border-top: 1px solid var(--border); }

/* ========== Section ========== */
.section { margin-bottom: 32px; }
.section-title { font-size: 18px; font-weight: 600; margin-bottom: 16px; }

/* ========== Overlay ========== */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 99;
}

/* ========== Toast ========== */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 20px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow); animation: slideIn 0.3s ease;
  display: flex; align-items: center; gap: 8px;
}
.toast-success { background: #166534; color: #bbf7d0; }
.toast-error { background: #7f1d1d; color: #fecaca; }
.toast-info { background: #1e3a5f; color: #93c5fd; }

/* ========== Animations ========== */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ========== Loading Skeleton ========== */
.skeleton {
  background: linear-gradient(90deg, #2a2a2a 25%, #333 50%, #2a2a2a 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ========== Responsive ========== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.active { display: block; }
  .main-content { margin-left: 0; }
  .mobile-toggle { display: block; }
  .page-content { padding: 20px; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .header { padding: 0 16px; }
  .message { max-width: 90%; }
  .login-card { margin: 16px; padding: 32px 24px; }
}
