/* Maracade Cyber Defense Platform — theme.css
   Works with Bootstrap 5's data-bs-theme attribute for dark/light mode. */

:root {
  --mc-accent: #ff3b3b;
  --mc-accent-soft: rgba(255, 59, 59, .12);
}

[data-bs-theme="dark"] {
  --mc-bg: #0d1117;
  --mc-surface: #161b22;
  --mc-surface-2: #1c2129;
  --mc-border: #30363d;
  --mc-text: #e6edf3;
  --mc-text-secondary: #8b949e;
}

[data-bs-theme="light"] {
  --mc-bg: #f5f6f8;
  --mc-surface: #ffffff;
  --mc-surface-2: #f0f1f4;
  --mc-border: #e2e4e9;
  --mc-text: #1b1f24;
  --mc-text-secondary: #5c6570;
}

body {
  background: var(--mc-bg);
  color: var(--mc-text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  background: var(--mc-bg, #0d1117);
  color: var(--mc-text, #e6edf3);
}

.auth-card, .card {
  background: var(--mc-surface);
  border: 1px solid var(--mc-border);
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--mc-surface);
  border-right: 1px solid var(--mc-border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  padding: 20px 18px;
  border-bottom: 1px solid var(--mc-border);
  font-size: 1.05rem;
}

.sidebar-nav {
  padding: 10px 10px 40px;
}

.nav-section-title {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--mc-text-secondary);
  padding: 16px 12px 6px;
}

.sidebar-nav .nav-link {
  color: var(--mc-text);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: .9rem;
  display: flex;
  align-items: center;
}

.sidebar-nav .nav-link:hover {
  background: var(--mc-surface-2);
}

.sidebar-nav .nav-link.active {
  background: var(--mc-accent-soft);
  color: var(--mc-accent);
  font-weight: 600;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  background: var(--mc-surface);
  border-bottom: 1px solid var(--mc-border);
  padding: 14px 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-content {
  padding: 24px;
  flex: 1;
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--mc-border);
  color: var(--mc-text);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.avatar-circle {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--mc-accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: .85rem;
}

.notif-dot {
  display: none; /* toggled on by app.js when unread notifications exist */
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--mc-accent);
  border-radius: 50%;
}

.metric-card {
  background: var(--mc-surface);
  border: 1px solid var(--mc-border);
  border-radius: 14px;
  padding: 20px;
  height: 100%;
}

.metric-card .metric-value {
  font-size: 1.9rem;
  font-weight: 700;
}

.metric-card .metric-label {
  color: var(--mc-text-secondary);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.score-ring {
  width: 120px;
  height: 120px;
}

.table {
  color: var(--mc-text);
}

.severity-critical { color: #ff3b3b; }
.severity-high { color: #ff8a3b; }
.severity-medium { color: #ffd23b; }
.severity-low { color: #3bd671; }
.severity-info { color: #3b9dff; }

@media (max-width: 991.98px) {
  .app-sidebar {
    position: fixed;
    left: -280px;
    z-index: 1050;
    transition: left .2s ease;
  }
  .app-sidebar.open {
    left: 0;
  }
}

/* =====================================================================
   Phase 7 — AI Security Agent
   ===================================================================== */

.alert-sm {
  padding: .5rem .75rem;
}

/* Reclaim the app-content padding so the chat shell can be full-bleed
   and manage its own internal scroll regions/safe-area padding. */
.ai-shell {
  margin: -24px;
  height: calc(100vh - 65px); /* viewport minus the sticky topbar */
  display: flex;
  overflow: hidden;
}

.ai-layout {
  display: flex;
  flex: 1;
  min-width: 0;
  min-height: 0;
}

.ai-sidebar {
  width: 280px;
  flex-shrink: 0;
  border-right: 1px solid var(--mc-border);
  background: var(--mc-surface);
  overflow-y: auto;
}

.ai-convo-offcanvas {
  background: var(--mc-surface);
  color: var(--mc-text);
  width: 300px;
}

.ai-convo-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid var(--mc-border);
  padding: 12px 16px;
  color: var(--mc-text);
}

.ai-convo-item:hover {
  background: var(--mc-surface-2);
}

.ai-convo-item.active {
  background: var(--mc-accent-soft);
}

.ai-convo-title {
  font-size: .85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.ai-topbar {
  padding: 10px 16px;
  border-bottom: 1px solid var(--mc-border);
  background: var(--mc-surface);
}

.ai-module-select {
  max-width: 220px;
}

.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.ai-msg {
  display: flex;
  gap: 12px;
  max-width: 820px;
}

.ai-msg-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.ai-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--mc-surface-2);
  border: 1px solid var(--mc-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ai-msg-user .ai-msg-avatar {
  background: var(--mc-accent-soft);
  color: var(--mc-accent);
}

.ai-msg-body {
  background: var(--mc-surface);
  border: 1px solid var(--mc-border);
  border-radius: 14px;
  padding: 12px 16px;
  min-width: 0;
}

.ai-msg-user .ai-msg-body {
  background: var(--mc-accent-soft);
}

.ai-msg-content {
  font-size: .92rem;
  line-height: 1.55;
  word-wrap: break-word;
}

.ai-msg-content pre {
  background: var(--mc-surface-2);
  border: 1px solid var(--mc-border);
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  font-size: .82rem;
}

.ai-msg-content code {
  font-size: .85em;
}

.ai-msg-content p:last-child {
  margin-bottom: 0;
}

.ai-msg-meta {
  margin-top: 6px;
  font-size: .72rem;
}

.ai-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.ai-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--mc-text-secondary);
  animation: ai-typing-bounce 1.2s infinite ease-in-out;
}

.ai-typing span:nth-child(2) { animation-delay: .15s; }
.ai-typing span:nth-child(3) { animation-delay: .3s; }

@keyframes ai-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.ai-composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--mc-border);
  background: var(--mc-surface);
}

.ai-composer-input {
  resize: none;
  max-height: 200px;
  border-radius: 12px;
}

.ai-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-disclaimer {
  border-top: 1px solid var(--mc-border);
  background: var(--mc-surface);
}

.ai-empty-state {
  margin: auto;
}

.ai-context-banner {
  margin: 10px 16px 0;
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--mc-accent-soft);
  color: var(--mc-accent);
  font-size: .82rem;
}

.ai-quick-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 560px;
  margin: 18px auto 0;
}

.ai-chip {
  border: 1px solid var(--mc-border);
  background: var(--mc-surface);
  color: var(--mc-text);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: .8rem;
  white-space: normal;
  text-align: left;
}

.ai-chip:hover {
  background: var(--mc-surface-2);
  border-color: var(--mc-accent);
}

/* ---------------------------------------------------------------------
   Mobile responsiveness (phone/tablet widths). Applies across the app,
   not just the AI Assistant, so anything using .metric-card / .table /
   .app-topbar tightens up consistently on small screens.
   --------------------------------------------------------------------- */
@media (max-width: 767.98px) {
  .app-content {
    padding: 14px;
  }

  .app-topbar {
    padding: 10px 14px;
  }

  .metric-card {
    padding: 14px;
    border-radius: 12px;
  }

  h5 {
    font-size: 1.05rem;
  }

  .ai-shell {
    margin: -14px;
    height: calc(100vh - 57px);
  }

  .ai-topbar {
    padding: 8px 10px;
  }

  .ai-module-select {
    max-width: none;
    flex: 1 1 auto;
    order: 1;
  }

  #newChatBtn {
    order: 2;
  }

  .ai-messages {
    padding: 14px 12px;
    gap: 14px;
  }

  .ai-msg {
    max-width: 100%;
  }

  .ai-msg-body {
    padding: 10px 12px;
  }

  .ai-context-banner {
    margin: 8px 10px 0;
  }

  .ai-quick-prompts {
    max-width: none;
    padding: 0 8px;
  }

  .ai-composer {
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom, 0px));
  }

  /* Bootstrap modals/off-canvases already reflow at this width; just
     make sure our provider settings modal never exceeds the viewport. */
  .modal-dialog {
    margin: 8px;
  }
}

@media (max-width: 575.98px) {
  .ai-disclaimer {
    font-size: .68rem;
    padding-left: 8px;
    padding-right: 8px;
  }

  .sidebar-brand {
    padding: 16px;
  }
}
