/* ============================================================
   Bench Master AI — Main Stylesheet
   ============================================================ */

:root {
  --bm-sidebar-width: 240px;
  --bm-sidebar-bg: #0f1724;
  --bm-sidebar-text: #a8b4c8;
  --bm-sidebar-hover: #1e2d42;
  --bm-sidebar-active: #1a6fc4;
  --bm-accent: #1a6fc4;
  --bm-accent-light: #e8f0fb;
  --bm-topbar-h: 56px;
  --bm-body-bg: #f0f2f5;
  --bm-card-border: #e3e8ef;
  --bm-success: #17a35f;
  --bm-warning: #f59e0b;
  --bm-danger: #e53e3e;
}

/* ---- Body / Layout ---- */
body.bm-body {
  background: var(--bm-body-bg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 0.875rem;
  margin: 0;
  overflow-x: hidden;
}

/* ---- Sidebar ---- */
.bm-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--bm-sidebar-width);
  background: var(--bm-sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.25s ease;
  scrollbar-width: thin;
  scrollbar-color: #2a3a52 transparent;
}

.bm-sidebar-brand {
  padding: 18px 16px;
  border-bottom: 1px solid #1e2d42;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--bm-topbar-h);
  flex-shrink: 0;
}
.bm-logo-icon { font-size: 1.5rem; color: var(--bm-accent); }
.bm-logo-text { color: #fff; font-size: 1rem; white-space: nowrap; }
.bm-logo-text strong { color: var(--bm-accent); }

.bm-nav { list-style: none; padding: 8px 0; margin: 0; flex: 1; }
.bm-nav-item { margin: 1px 8px; }
.bm-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  color: var(--bm-sidebar-text);
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.15s;
  font-size: 0.82rem;
  white-space: nowrap;
}
.bm-nav-link:hover { background: var(--bm-sidebar-hover); color: #fff; }
.bm-nav-item.active .bm-nav-link { background: var(--bm-accent); color: #fff; font-weight: 600; }
.bm-nav-link i { font-size: 1rem; width: 18px; text-align: center; flex-shrink: 0; }
.bm-badge-pending {
  background: #ef4444;
  color: #fff;
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 0.7rem;
  font-weight: 700;
}

.bm-sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid #1e2d42;
  flex-shrink: 0;
}
.bm-logout-link {
  color: var(--bm-sidebar-text);
  text-decoration: none;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  border-radius: 6px;
  transition: color 0.15s;
}
.bm-logout-link:hover { color: #ef4444; }

/* ---- Main Content ---- */
.bm-main {
  margin-left: var(--bm-sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.25s ease;
}

/* ---- Topbar ---- */
.bm-topbar {
  background: #fff;
  height: var(--bm-topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--bm-card-border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.bm-sidebar-toggle {
  background: none;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 1.1rem;
  color: #64748b;
  cursor: pointer;
  display: none;
}
.bm-topbar-title { font-weight: 600; font-size: 0.95rem; color: #1e293b; }
.bm-topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.bm-topbar-date { color: #94a3b8; font-size: 0.8rem; }
.bm-topbar-badge {
  position: relative;
  color: #ef4444;
  font-size: 1rem;
  text-decoration: none;
}
.bm-topbar-badge span {
  position: absolute;
  top: -6px;
  right: -8px;
  background: #ef4444;
  color: #fff;
  border-radius: 10px;
  padding: 0 5px;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.4;
}
.bm-topbar-user { color: #475569; font-size: 0.82rem; display: flex; align-items: center; gap: 6px; }

/* ---- Content area ---- */
.bm-content { padding: 20px; flex: 1; }

/* ---- Flash messages ---- */
.bm-flash { margin-top: 0; }

/* ---- KPI Cards ---- */
.bm-kpi-card { transition: transform 0.15s, box-shadow 0.15s; }
.bm-kpi-card:hover { transform: translateY(-2px); box-shadow: 0 4px 15px rgba(0,0,0,.1) !important; }
.bm-kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.bm-kpi-value { font-size: 1.5rem; font-weight: 700; line-height: 1.2; color: #1e293b; }
.bm-kpi-label { font-size: 0.75rem; }

/* ---- Card headers ---- */
.bm-card-header {
  background: #f8fafc;
  border-bottom: 1px solid #e3e8ef;
  font-weight: 600;
  font-size: 0.85rem;
  color: #374151;
  padding: 10px 16px;
}

/* ---- Metric boxes ---- */
.bm-metric-box {
  border-radius: 10px;
  padding: 12px 8px;
}
.bm-metric-val { font-size: 1.8rem; font-weight: 700; line-height: 1; }

/* ---- Tables ---- */
.table th { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: #64748b; }
.table td { vertical-align: middle; font-size: 0.83rem; }
.table-hover tbody tr:hover { background: #f0f7ff; }

/* ---- Badges ---- */
.badge { font-size: 0.72rem; font-weight: 600; }

/* ---- Login page ---- */
body.bm-login-body {
  background: linear-gradient(135deg, #0f1724 0%, #1a2d48 50%, #0d2137 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.bm-login-wrapper { width: 100%; max-width: 420px; padding: 20px; }
.bm-login-box {
  background: #fff;
  border-radius: 16px;
  padding: 40px 36px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.bm-login-logo { text-align: center; margin-bottom: 28px; }
.bm-login-logo i { font-size: 3rem; color: var(--bm-accent); }
.bm-login-logo h1 { font-size: 1.6rem; font-weight: 700; margin: 8px 0 0; color: #1e293b; }
.bm-login-logo h1 strong { color: var(--bm-accent); }

/* ---- AI Chat ---- */
.bm-chat-window {
  height: 480px;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fafbfc;
  scroll-behavior: smooth;
}
.bm-chat-msg { display: flex; flex-direction: column; max-width: 85%; }
.bm-chat-user { align-self: flex-end; align-items: flex-end; }
.bm-chat-assistant { align-self: flex-start; align-items: flex-start; }
.bm-chat-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  line-height: 1.55;
  font-size: 0.875rem;
}
.bm-chat-user .bm-chat-bubble {
  background: var(--bm-accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.bm-chat-assistant .bm-chat-bubble {
  background: #fff;
  border: 1px solid #e2e8f0;
  color: #1e293b;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.bm-chat-time { font-size: 0.7rem; color: #94a3b8; margin-top: 3px; padding: 0 4px; }
.bm-chat-typing {
  padding: 8px 16px;
  display: flex;
  gap: 4px;
  align-items: center;
}
.bm-chat-typing span {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--bm-accent);
  border-radius: 50%;
  animation: bm-typing 1.2s ease-in-out infinite;
}
.bm-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.bm-chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bm-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ---- Voice ---- */
.bm-voice-mic {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--bm-accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: var(--bm-accent);
  transition: all 0.3s;
  cursor: pointer;
}
.bm-voice-listening {
  background: #fee2e2;
  color: #ef4444;
  animation: bm-pulse 1s ease-in-out infinite;
}
@keyframes bm-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239,68,68,.4); }
  50% { transform: scale(1.05); box-shadow: 0 0 0 12px rgba(239,68,68,0); }
}

/* ---- Responsive ---- */
@media (max-width: 991.98px) {
  .bm-sidebar {
    width: 0;
    overflow: hidden;
  }
  .bm-sidebar.bm-sidebar-open {
    width: var(--bm-sidebar-width);
  }
  .bm-main { margin-left: 0; }
  .bm-sidebar-toggle { display: block; }
  .bm-content { padding: 12px; }
}

@media (max-width: 575.98px) {
  .bm-kpi-value { font-size: 1.2rem; }
  .bm-chat-window { height: 320px; }
}

/* ---- Utilities ---- */
.btn-xs { padding: 2px 6px; font-size: 0.72rem; }
.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
