/* ==========================================================================
   MIRA Insights -- Main Stylesheet
   Mercedes-Benz Logistics Knowledge Platform
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Custom Properties
   -------------------------------------------------------------------------- */
:root {
  /* Brand palette */
  --color-bg:            #0b1a26;
  --color-bg-alt:        #0e2030;
  --color-sidebar:       #0a1520;
  --color-card:          #112233;
  --color-card-hover:    #152a3e;
  --color-topnav:        #0d1f2d;
  --color-ticker:        #091620;
  --color-border:        #1a3a50;
  --color-border-subtle: #142e42;

  /* Accents */
  --color-teal:          #00c9a7;
  --color-teal-dark:     #00a88c;
  --color-teal-glow:     rgba(0, 201, 167, .12);
  --color-teal-glow-md:  rgba(0, 201, 167, .20);

  /* Semantic */
  --color-success:       #00c9a7;
  --color-warning:       #f0b429;
  --color-danger:        #e5484d;
  --color-info:          #3b82f6;
  --color-new:           #00c9a7;
  --color-development:   #f0b429;
  --color-backlog:       #64748b;
  --color-review:        #3b82f6;
  --color-updated:       #a78bfa;
  --color-deprecated:    #e5484d;
  --color-launched:      #22c55e;

  /* Typography */
  --color-text:          #e0e0e0;
  --color-text-muted:    #8899aa;
  --color-text-dim:      #5a6f82;
  --color-heading:       #f0f4f8;

  /* Layout */
  --sidebar-width:       260px;
  --sidebar-collapsed:   60px;
  --topnav-height:       56px;
  --ticker-height:       36px;
  --content-offset:      calc(var(--topnav-height) + var(--ticker-height));

  /* Depth */
  --shadow-sm:  0 1px 3px rgba(0, 0, 0, .3);
  --shadow-md:  0 4px 12px rgba(0, 0, 0, .4);
  --shadow-lg:  0 8px 30px rgba(0, 0, 0, .5);
  --shadow-glow: 0 0 20px var(--color-teal-glow);

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  /* Transitions */
  --ease: cubic-bezier(.4, 0, .2, 1);
  --duration: 200ms;
  --duration-slow: 350ms;

  /* Font */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", "SF Mono", Menlo, monospace;
}

/* --------------------------------------------------------------------------
   2. Reset / Normalize
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: var(--color-teal);
  text-decoration: none;
  transition: color var(--duration) var(--ease);
}
a:hover {
  color: var(--color-teal-dark);
}

img { max-width: 100%; height: auto; }
button { cursor: pointer; font-family: inherit; }
ul, ol { list-style: none; }

/* --------------------------------------------------------------------------
   3. Scrollbar
   -------------------------------------------------------------------------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--color-bg); }
::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--color-text-dim); }

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) var(--color-bg);
}

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

/* --------------------------------------------------------------------------
   5. Sidebar
   -------------------------------------------------------------------------- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--color-sidebar);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: width var(--duration-slow) var(--ease);
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

/* Logo area */
.sidebar__logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  min-height: var(--topnav-height);
}

.sidebar__logo-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--color-teal), var(--color-teal-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #0b1a26;
  flex-shrink: 0;
}

.sidebar__logo-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-heading);
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--duration) var(--ease);
}
.sidebar.collapsed .sidebar__logo-text { opacity: 0; width: 0; }

/* Toggle button */
.sidebar__toggle {
  position: absolute;
  top: 14px;
  right: -14px;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-card);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  z-index: 1001;
  transition: background var(--duration) var(--ease),
              color var(--duration) var(--ease),
              transform var(--duration) var(--ease);
}
.sidebar__toggle:hover {
  background: var(--color-teal);
  color: #0b1a26;
}
.sidebar.collapsed .sidebar__toggle {
  transform: rotate(180deg);
}

/* Nav area */
.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0;
}

/* Navigation items -- shared */
.nav-item {
  position: relative;
}

.nav-item__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  color: var(--color-text-muted);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  border-left: 3px solid transparent;
  transition: background var(--duration) var(--ease),
              color var(--duration) var(--ease),
              border-color var(--duration) var(--ease);
  cursor: pointer;
  user-select: none;
}
.nav-item__link:hover {
  background: rgba(0, 201, 167, .06);
  color: var(--color-text);
}
.nav-item__link.active {
  background: var(--color-teal-glow);
  color: var(--color-teal);
  border-left-color: var(--color-teal);
}

/* Level indentation */
.nav-item[data-level="GROUP"]  > .nav-item__link { padding-left: 28px; }
.nav-item[data-level="ITEM"]   > .nav-item__link { padding-left: 42px; }
.nav-item[data-level="SUBITEM"]> .nav-item__link { padding-left: 56px; }

/* Module headers */
.nav-item[data-level="MODULE"] > .nav-item__link {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--color-text-dim);
  padding: 16px 16px 6px;
}
.nav-item[data-level="MODULE"] > .nav-item__link:hover {
  background: transparent;
  color: var(--color-text-muted);
}

/* Expand / collapse chevron */
.nav-item__chevron {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 10px;
  transition: transform var(--duration) var(--ease);
  color: var(--color-text-dim);
}
.nav-item.expanded > .nav-item__link > .nav-item__chevron {
  transform: rotate(90deg);
}

/* Children container */
.nav-item__children {
  display: none;
  overflow: hidden;
}
.nav-item.expanded > .nav-item__children {
  display: block;
}

/* Status dot */
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  display: inline-block;
}
.status-dot--launched    { background: var(--color-launched); }
.status-dot--new         { background: var(--color-new); }
.status-dot--development { background: var(--color-development); }
.status-dot--review      { background: var(--color-review); }
.status-dot--updated     { background: var(--color-updated); }
.status-dot--backlog     { background: var(--color-backlog); }
.status-dot--deprecated  { background: var(--color-deprecated); }

/* Sidebar collapsed: hide labels */
.sidebar.collapsed .nav-item__link span,
.sidebar.collapsed .nav-item__chevron,
.sidebar.collapsed .status-dot {
  opacity: 0;
  width: 0;
  overflow: hidden;
}
.sidebar.collapsed .nav-item[data-level="MODULE"] > .nav-item__link {
  padding: 12px 0;
  justify-content: center;
}
.sidebar.collapsed .nav-item__link {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}
.sidebar.collapsed .nav-item__children {
  display: none !important;
}

/* --------------------------------------------------------------------------
   6. Main Content Area
   -------------------------------------------------------------------------- */
.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--duration-slow) var(--ease);
}
.sidebar.collapsed ~ .main {
  margin-left: var(--sidebar-collapsed);
}

/* --------------------------------------------------------------------------
   7. Top Navbar
   -------------------------------------------------------------------------- */
.topnav {
  position: sticky;
  top: 0;
  z-index: 900;
  height: var(--topnav-height);
  background: var(--color-topnav);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  backdrop-filter: blur(8px);
}

/* Mobile hamburger -- hidden on desktop */
.topnav__hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--color-text);
  font-size: 20px;
  padding: 4px;
}

.topnav__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  color: var(--color-heading);
  white-space: nowrap;
}

.topnav__brand-accent {
  color: var(--color-teal);
}

/* Search */
.topnav__search {
  flex: 1;
  max-width: 480px;
  position: relative;
}

.topnav__search-input {
  width: 100%;
  height: 36px;
  padding: 0 14px 0 36px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  color: var(--color-text);
  font-size: 13px;
  outline: none;
  transition: border-color var(--duration) var(--ease),
              box-shadow var(--duration) var(--ease);
}
.topnav__search-input::placeholder { color: var(--color-text-dim); }
.topnav__search-input:focus {
  border-color: var(--color-teal);
  box-shadow: 0 0 0 3px var(--color-teal-glow);
}

.topnav__search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-dim);
  font-size: 14px;
  pointer-events: none;
}

/* Right-side actions */
.topnav__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

/* Notification bell */
.notif-bell {
  position: relative;
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 18px;
  padding: 6px 8px;
  border-radius: var(--radius-md);
  transition: background var(--duration) var(--ease),
              color var(--duration) var(--ease);
}
.notif-bell:hover {
  background: var(--color-teal-glow);
  color: var(--color-teal);
}

.notif-bell__badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  background: var(--color-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}
.notif-bell__badge:empty,
.notif-bell__badge[data-count="0"] {
  display: none;
}

/* Notification dropdown */
.notif-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 360px;
  max-height: 420px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: none;
  z-index: 1100;
}
.notif-dropdown.open { display: block; }

.notif-dropdown__header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  font-weight: 600;
  font-size: 14px;
  color: var(--color-heading);
}

.notif-dropdown__list {
  overflow-y: auto;
  max-height: 360px;
}

.notif-dropdown__item {
  display: block;
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-border-subtle);
  transition: background var(--duration) var(--ease);
}
.notif-dropdown__item:hover { background: var(--color-bg-alt); }
.notif-dropdown__item.unread { border-left: 3px solid var(--color-teal); }

.notif-dropdown__item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-heading);
  margin-bottom: 2px;
}
.notif-dropdown__item-msg {
  font-size: 12px;
  color: var(--color-text-muted);
  line-height: 1.4;
}
.notif-dropdown__item-time {
  font-size: 11px;
  color: var(--color-text-dim);
  margin-top: 4px;
}

.notif-dropdown__empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--color-text-dim);
  font-size: 13px;
}

/* User menu */
.user-menu {
  position: relative;
}

.user-menu__trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  color: var(--color-text);
  padding: 6px 10px;
  border-radius: var(--radius-md);
  font-size: 13px;
  transition: background var(--duration) var(--ease);
}
.user-menu__trigger:hover { background: var(--color-teal-glow); }

.user-menu__avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-teal), var(--color-teal-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0b1a26;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}

.user-menu__name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.user-menu__dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 200px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: none;
  z-index: 1100;
}
.user-menu__dropdown.open { display: block; }

.user-menu__dropdown a,
.user-menu__dropdown button {
  display: block;
  width: 100%;
  padding: 10px 16px;
  text-align: left;
  font-size: 13px;
  color: var(--color-text);
  background: none;
  border: none;
  border-bottom: 1px solid var(--color-border-subtle);
  transition: background var(--duration) var(--ease);
}
.user-menu__dropdown a:last-child,
.user-menu__dropdown button:last-child { border-bottom: none; }
.user-menu__dropdown a:hover,
.user-menu__dropdown button:hover { background: var(--color-bg-alt); }

/* --------------------------------------------------------------------------
   8. Ticker Bar
   -------------------------------------------------------------------------- */
.ticker {
  height: var(--ticker-height);
  background: var(--color-ticker);
  border-bottom: 1px solid var(--color-border-subtle);
  display: flex;
  align-items: center;
  overflow: hidden;
  position: relative;
}

.ticker__label {
  flex-shrink: 0;
  padding: 0 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--color-teal);
  border-right: 1px solid var(--color-border-subtle);
  height: 100%;
  display: flex;
  align-items: center;
  background: rgba(0, 201, 167, .06);
}

.ticker__track {
  flex: 1;
  overflow: hidden;
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
}

.ticker__scroll {
  display: flex;
  gap: 48px;
  white-space: nowrap;
  animation: ticker-scroll var(--ticker-speed, 30s) linear infinite;
  padding-left: 100%;
}

.ticker__scroll:hover {
  animation-play-state: paused;
}

.ticker__item {
  font-size: 12px;
  color: var(--color-text-muted);
  flex-shrink: 0;
}
.ticker__item a {
  color: var(--color-text-muted);
}
.ticker__item a:hover {
  color: var(--color-teal);
}

.ticker__sep {
  color: var(--color-border);
  flex-shrink: 0;
}

@keyframes ticker-scroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}

/* --------------------------------------------------------------------------
   9. Content
   -------------------------------------------------------------------------- */
.content {
  flex: 1;
  padding: 28px 32px;
}

.content__header {
  margin-bottom: 28px;
}

.content__title {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-heading);
  margin-bottom: 4px;
}

.content__subtitle {
  font-size: 14px;
  color: var(--color-text-muted);
}

/* --------------------------------------------------------------------------
   10. Cards
   -------------------------------------------------------------------------- */
.card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: border-color var(--duration) var(--ease),
              box-shadow var(--duration) var(--ease),
              transform var(--duration) var(--ease);
}
.card:hover {
  border-color: var(--color-teal);
  box-shadow: var(--shadow-glow);
}
.card--clickable:hover {
  transform: translateY(-2px);
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card__title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-heading);
}

.card__meta {
  font-size: 12px;
  color: var(--color-text-dim);
  margin-top: 8px;
}

.card__body {
  font-size: 14px;
  color: var(--color-text-muted);
  line-height: 1.6;
}

.card__footer {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Card grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

/* --------------------------------------------------------------------------
   11. Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: background var(--duration) var(--ease),
              color var(--duration) var(--ease),
              border-color var(--duration) var(--ease),
              box-shadow var(--duration) var(--ease),
              transform 100ms var(--ease);
  outline: none;
  text-decoration: none;
  cursor: pointer;
}
.btn:active { transform: scale(.97); }
.btn:focus-visible {
  box-shadow: 0 0 0 3px var(--color-teal-glow);
}

/* Primary */
.btn--primary {
  background: var(--color-teal);
  color: #0b1a26;
  border-color: var(--color-teal);
}
.btn--primary:hover {
  background: var(--color-teal-dark);
  border-color: var(--color-teal-dark);
  color: #0b1a26;
}

/* Secondary / outline */
.btn--secondary {
  background: transparent;
  color: var(--color-teal);
  border-color: var(--color-teal);
}
.btn--secondary:hover {
  background: var(--color-teal-glow);
  color: var(--color-teal);
}

/* Danger */
.btn--danger {
  background: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
}
.btn--danger:hover {
  background: #d13438;
  border-color: #d13438;
  color: #fff;
}

/* Ghost */
.btn--ghost {
  background: transparent;
  color: var(--color-text-muted);
  border-color: transparent;
}
.btn--ghost:hover {
  background: var(--color-teal-glow);
  color: var(--color-teal);
}

/* Sizes */
.btn--sm { padding: 6px 14px; font-size: 12px; }
.btn--lg { padding: 14px 28px; font-size: 15px; }

/* --------------------------------------------------------------------------
   12. Forms
   -------------------------------------------------------------------------- */
.form-group {
  margin-bottom: 18px;
}

.form-group label,
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  font-size: 14px;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color var(--duration) var(--ease),
              box-shadow var(--duration) var(--ease);
}
.form-control::placeholder { color: var(--color-text-dim); }
.form-control:focus {
  border-color: var(--color-teal);
  box-shadow: 0 0 0 3px var(--color-teal-glow);
}
.form-control:disabled {
  opacity: .5;
  cursor: not-allowed;
}

textarea.form-control { resize: vertical; min-height: 100px; }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238899aa' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.form-hint {
  font-size: 12px;
  color: var(--color-text-dim);
  margin-top: 4px;
}

.form-error {
  font-size: 12px;
  color: var(--color-danger);
  margin-top: 4px;
}

/* Error list (Django) */
.errorlist {
  list-style: none;
  padding: 0;
  margin: 4px 0 0;
}
.errorlist li {
  font-size: 12px;
  color: var(--color-danger);
  padding: 2px 0;
}

/* --------------------------------------------------------------------------
   13. Tables
   -------------------------------------------------------------------------- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: var(--color-bg-alt);
  padding: 10px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

tbody td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-border-subtle);
  color: var(--color-text);
}

tbody tr:nth-child(even) { background: rgba(17, 34, 51, .3); }
tbody tr:hover { background: var(--color-teal-glow); }

/* --------------------------------------------------------------------------
   14. Badges / Pills
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-full);
  letter-spacing: .02em;
  text-transform: uppercase;
}

.badge--launched    { background: rgba(34, 197, 94, .15); color: var(--color-launched); }
.badge--new         { background: var(--color-teal-glow); color: var(--color-new); }
.badge--development { background: rgba(240, 180, 41, .15); color: var(--color-development); }
.badge--review      { background: rgba(59, 130, 246, .15); color: var(--color-review); }
.badge--updated     { background: rgba(167, 139, 250, .15); color: var(--color-updated); }
.badge--backlog     { background: rgba(100, 116, 139, .15); color: var(--color-backlog); }
.badge--deprecated  { background: rgba(229, 72, 77, .15); color: var(--color-deprecated); }

.badge--info    { background: rgba(59, 130, 246, .15); color: var(--color-info); }
.badge--success { background: rgba(34, 197, 94, .15); color: var(--color-success); }
.badge--warning { background: rgba(240, 180, 41, .15); color: var(--color-warning); }
.badge--danger  { background: rgba(229, 72, 77, .15); color: var(--color-danger); }

/* Category badges for news */
.badge--UPDATE  { background: rgba(59, 130, 246, .15); color: var(--color-info); }
.badge--RELEASE { background: rgba(34, 197, 94, .15); color: var(--color-success); }
.badge--INSIGHT { background: rgba(167, 139, 250, .15); color: var(--color-updated); }
.badge--ALERT   { background: rgba(229, 72, 77, .15); color: var(--color-danger); }

/* Entity type badges */
.badge--concept      { background: rgba(0, 201, 167, .15); color: var(--color-teal); }
.badge--process      { background: rgba(59, 130, 246, .15); color: var(--color-info); }
.badge--tech_process { background: rgba(167, 139, 250, .15); color: var(--color-updated); }
.badge--data_object  { background: rgba(240, 180, 41, .15); color: var(--color-warning); }
.badge--actor        { background: rgba(34, 197, 94, .15); color: var(--color-success); }
.badge--system       { background: rgba(229, 72, 77, .15); color: var(--color-danger); }

/* Relationship badge */
.badge--rel { background: rgba(100, 116, 139, .2); color: var(--color-text-muted); font-family: var(--font-mono); letter-spacing: .04em; }

/* BPMN node type badges */
.badge--task              { background: rgba(0, 201, 167, .15); color: var(--color-teal); }
.badge--gateway           { background: rgba(240, 180, 41, .15); color: var(--color-warning); }
.badge--start_event       { background: rgba(34, 197, 94, .15); color: var(--color-success); }
.badge--end_event         { background: rgba(229, 72, 77, .15); color: var(--color-danger); }
.badge--intermediate_event{ background: rgba(59, 130, 246, .15); color: var(--color-info); }
.badge--subprocess        { background: rgba(167, 139, 250, .15); color: var(--color-updated); }

/* KB lifecycle badges */
.badge--DRAFT      { background: rgba(100, 116, 139, .15); color: var(--color-backlog); }
.badge--REVIEW     { background: rgba(59, 130, 246, .15); color: var(--color-review); }
.badge--PUBLISHED  { background: rgba(34, 197, 94, .15); color: var(--color-success); }
.badge--DEPRECATED { background: rgba(229, 72, 77, .15); color: var(--color-danger); }
.badge--OFFLINE    { background: rgba(100, 116, 139, .15); color: var(--color-text-dim); }
.badge--ARCHIVED   { background: rgba(100, 116, 139, .15); color: var(--color-text-dim); }

/* BPMN status badges */
.badge--PUBLIC     { background: rgba(0, 201, 167, .1); color: var(--color-teal); }
.badge--RESTRICTED { background: rgba(240, 180, 41, .15); color: var(--color-warning); }

/* Requirements state badges */
.badge--IMPACT_ANALYSIS { background: rgba(167, 139, 250, .15); color: var(--color-updated); }
.badge--SME_APPROVAL    { background: rgba(240, 180, 41, .15); color: var(--color-warning); }
.badge--APPROVED        { background: rgba(34, 197, 94, .15); color: var(--color-success); }
.badge--INTEGRATED      { background: rgba(0, 201, 167, .1); color: var(--color-teal); }
.badge--REJECTED        { background: rgba(229, 72, 77, .15); color: var(--color-danger); }

/* Change type badges */
.badge--ADD_ENTITY         { background: rgba(34, 197, 94, .15); color: var(--color-success); }
.badge--MODIFY_ENTITY      { background: rgba(59, 130, 246, .15); color: var(--color-info); }
.badge--REMOVE_ENTITY      { background: rgba(229, 72, 77, .15); color: var(--color-danger); }
.badge--ADD_RELATIONSHIP   { background: rgba(34, 197, 94, .15); color: var(--color-success); }
.badge--MODIFY_RELATIONSHIP{ background: rgba(59, 130, 246, .15); color: var(--color-info); }
.badge--REMOVE_RELATIONSHIP{ background: rgba(229, 72, 77, .15); color: var(--color-danger); }
.badge--ADD_PROCESS        { background: rgba(34, 197, 94, .15); color: var(--color-success); }
.badge--MODIFY_PROCESS     { background: rgba(59, 130, 246, .15); color: var(--color-info); }

/* Approval decision badges */
.badge--PENDING  { background: rgba(240, 180, 41, .15); color: var(--color-warning); }

/* Impact severity badges */
.badge--severity-low      { background: rgba(100, 116, 139, .15); color: #94a3b8; }
.badge--severity-medium   { background: rgba(240, 180, 41, .15); color: var(--color-warning); }
.badge--severity-high     { background: rgba(249, 115, 22, .15); color: #f97316; }
.badge--severity-critical { background: rgba(229, 72, 77, .20); color: var(--color-danger); border: 1px solid rgba(229, 72, 77, .35); }

/* Conflict badge */
.badge--conflict {
  background: rgba(249, 115, 22, .15);
  color: #f97316;
}

/* --------------------------------------------------------------------------
   15. Footer
   -------------------------------------------------------------------------- */
.footer {
  padding: 16px 32px;
  border-top: 1px solid var(--color-border-subtle);
  font-size: 12px;
  color: var(--color-text-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   16. Auth Pages (centered layout)
   -------------------------------------------------------------------------- */
.auth-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--content-offset) - 60px);
  padding: 40px 20px;
}

.auth-card {
  width: 100%;
  max-width: 460px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-lg);
}

.auth-card__title {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-heading);
  text-align: center;
  margin-bottom: 6px;
}

.auth-card__subtitle {
  font-size: 14px;
  color: var(--color-text-muted);
  text-align: center;
  margin-bottom: 28px;
}

.auth-card__footer {
  margin-top: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--color-text-muted);
}

/* --------------------------------------------------------------------------
   17. Article Detail
   -------------------------------------------------------------------------- */
.article {
  max-width: 800px;
}

.article__header {
  margin-bottom: 28px;
}

.article__title {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-heading);
  line-height: 1.3;
  margin-bottom: 12px;
}

.article__meta {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--color-text-muted);
}

.article__body {
  font-size: 15px;
  line-height: 1.8;
  color: var(--color-text);
}
.article__body p { margin-bottom: 16px; }
.article__body h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-heading);
  margin: 28px 0 12px;
}
.article__body h3 {
  font-size: 17px;
  font-weight: 600;
  color: var(--color-heading);
  margin: 24px 0 8px;
}
.article__body ul,
.article__body ol {
  margin: 12px 0 12px 24px;
}
.article__body li {
  margin-bottom: 6px;
  list-style: disc;
}
.article__body ol li {
  list-style: decimal;
}
.article__body code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--color-bg);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-subtle);
}
.article__body pre {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
  overflow-x: auto;
  margin: 16px 0;
}
.article__body pre code {
  background: none;
  border: none;
  padding: 0;
}
.article__body blockquote {
  border-left: 3px solid var(--color-teal);
  padding: 12px 20px;
  margin: 16px 0;
  background: var(--color-teal-glow);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--color-text-muted);
}

/* --------------------------------------------------------------------------
   18. Profile Page
   -------------------------------------------------------------------------- */
.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.profile-section {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 24px;
}

.profile-section__title {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-heading);
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border-subtle);
}

/* Notification list in profile */
.notif-list__item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border-subtle);
}
.notif-list__item:last-child { border-bottom: none; }

.notif-list__icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.notif-list__icon--INFO    { background: rgba(59, 130, 246, .15); color: var(--color-info); }
.notif-list__icon--WARNING { background: rgba(240, 180, 41, .15); color: var(--color-warning); }
.notif-list__icon--SUCCESS { background: rgba(34, 197, 94, .15); color: var(--color-success); }
.notif-list__icon--ERROR   { background: rgba(229, 72, 77, .15); color: var(--color-danger); }

.notif-list__content { flex: 1; min-width: 0; }
.notif-list__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-heading);
}
.notif-list__msg {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 2px;
}
.notif-list__time {
  font-size: 11px;
  color: var(--color-text-dim);
  margin-top: 4px;
}

/* --------------------------------------------------------------------------
   Phase 2: Filter Bar
   -------------------------------------------------------------------------- */
.filter-bar { margin-bottom: 20px; }
.filter-bar__form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.filter-bar__group { flex: 0 1 auto; min-width: 0; }

/* --------------------------------------------------------------------------
   Phase 2: Table Variants
   -------------------------------------------------------------------------- */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table--sm { font-size: 12px; }
.table--sm th, .table--sm td { padding: 6px 12px; }
.table__row--clickable { cursor: pointer; }
.table__row--clickable:hover { background: var(--color-teal-glow); }

/* --------------------------------------------------------------------------
   Phase 2: Form Variants
   -------------------------------------------------------------------------- */
.form-control--sm {
  padding: 6px 12px;
  font-size: 13px;
  height: auto;
  min-width: 140px;
}

/* --------------------------------------------------------------------------
   Phase 2: Entity / Ontology Detail
   -------------------------------------------------------------------------- */
.entity-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}
.entity-section {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.entity-section__title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border-subtle);
}
.entity-section__subtitle {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  margin: 12px 0 8px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.entity-description { margin-bottom: 20px; color: var(--color-text-muted); }
.entity-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.entity-image img {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}
.entity-image figcaption {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 6px;
  text-align: center;
}

/* --------------------------------------------------------------------------
   Phase 2: KB Article Detail
   -------------------------------------------------------------------------- */
.article-meta {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 24px;
}
.article-meta__table {
  width: 100%;
  font-size: 13px;
}
.article-meta__table th {
  padding: 4px 12px 4px 0;
  color: var(--color-text-muted);
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
  width: 120px;
}
.article-meta__table td {
  padding: 4px 0;
  color: var(--color-text);
}
.article-toc {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 24px;
}
.article-toc__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-bottom: 8px;
}
.article-toc__list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.article-toc__list li {
  margin-bottom: 4px;
}
.article-toc__list a {
  font-size: 13px;
  color: var(--color-teal);
  text-decoration: none;
}
.article-toc__list a:hover { text-decoration: underline; }
.content__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 8px;
}

/* --------------------------------------------------------------------------
   19. Utility Classes
   -------------------------------------------------------------------------- */
.text-teal   { color: var(--color-teal); }
.text-muted  { color: var(--color-text-muted); }
.text-dim    { color: var(--color-text-dim); }
.text-center { text-align: center; }
.text-right  { text-align: right; }

.mt-0  { margin-top: 0; }
.mt-1  { margin-top: 8px; }
.mt-2  { margin-top: 16px; }
.mt-3  { margin-top: 24px; }
.mt-4  { margin-top: 32px; }
.mb-0  { margin-bottom: 0; }
.mb-1  { margin-bottom: 8px; }
.mb-2  { margin-bottom: 16px; }
.mb-3  { margin-bottom: 24px; }
.mb-4  { margin-bottom: 32px; }

.d-flex        { display: flex; }
.align-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.gap-3 { gap: 24px; }

.w-100 { width: 100%; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* --------------------------------------------------------------------------
   20. Messages (Django messages framework)
   -------------------------------------------------------------------------- */
.messages {
  margin-bottom: 20px;
}

.messages .alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid;
  font-size: 13px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert--success {
  background: rgba(34, 197, 94, .1);
  border-color: rgba(34, 197, 94, .3);
  color: var(--color-success);
}
.alert--error {
  background: rgba(229, 72, 77, .1);
  border-color: rgba(229, 72, 77, .3);
  color: var(--color-danger);
}
.alert--warning {
  background: rgba(240, 180, 41, .1);
  border-color: rgba(240, 180, 41, .3);
  color: var(--color-warning);
}
.alert--info {
  background: rgba(59, 130, 246, .1);
  border-color: rgba(59, 130, 246, .3);
  color: var(--color-info);
}

/* --------------------------------------------------------------------------
   21. Mobile Overlay
   -------------------------------------------------------------------------- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  z-index: 999;
}
.sidebar-overlay.active { display: block; }

/* --------------------------------------------------------------------------
   22. Pinned indicator
   -------------------------------------------------------------------------- */
.pinned-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-teal);
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* --------------------------------------------------------------------------
   Ask MIRA Chat Widget
   -------------------------------------------------------------------------- */
.chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1100;
}
.chat-widget__toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--color-teal);
  color: #0b1a26;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 201, 167, .3);
  transition: transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.chat-widget__toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(0, 201, 167, .4);
}
.chat-widget__toggle--active { display: none; }

.chat-panel {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 400px;
  max-height: 560px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .4);
  overflow: hidden;
}
.chat-panel[hidden] { display: none; }

.chat-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--color-bg-alt);
  border-bottom: 1px solid var(--color-border);
}
.chat-panel__title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-teal);
}
.chat-panel__close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}
.chat-panel__close:hover { color: var(--color-text); }

.chat-panel__messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 300px;
  max-height: 400px;
}

.chat-msg {
  max-width: 85%;
}
.chat-msg--user {
  align-self: flex-end;
}
.chat-msg--assistant {
  align-self: flex-start;
}
.chat-msg__content {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.5;
}
.chat-msg--user .chat-msg__content {
  background: var(--color-teal);
  color: #0b1a26;
}
.chat-msg--assistant .chat-msg__content {
  background: var(--color-bg-alt);
  color: var(--color-text);
  border: 1px solid var(--color-border-subtle);
}

.chat-citation {
  color: var(--color-teal);
  font-weight: 600;
  font-size: 11px;
  vertical-align: super;
  cursor: help;
}

.chat-typing {
  color: var(--color-text-muted);
  font-style: italic;
}

.chat-quick-prompts {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.chat-quick-prompt {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 12px;
  color: var(--color-teal);
  cursor: pointer;
  text-align: left;
  transition: background var(--duration) var(--ease);
}
.chat-quick-prompt:hover {
  background: var(--color-teal-glow);
}

.chat-panel__input {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--color-border);
  background: var(--color-bg-alt);
}
.chat-panel__textbox {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 13px;
  outline: none;
}
.chat-panel__textbox:focus {
  border-color: var(--color-teal);
  box-shadow: 0 0 0 2px var(--color-teal-glow);
}
.chat-panel__send {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--color-teal);
  color: #0b1a26;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-panel__send:hover { background: var(--color-teal-dark); }

/* --------------------------------------------------------------------------
   23. Responsive
   -------------------------------------------------------------------------- */

/* Tablets and below */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 240px;
  }
  .content { padding: 24px 20px; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
  .profile-grid { grid-template-columns: 1fr; }
  .entity-images { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

/* Mobile */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width);
    transition: transform var(--duration-slow) var(--ease);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .sidebar.collapsed {
    width: var(--sidebar-width);
    transform: translateX(-100%);
  }
  .sidebar.collapsed.mobile-open {
    transform: translateX(0);
  }

  .sidebar__toggle { display: none; }

  .main {
    margin-left: 0 !important;
  }

  .topnav__hamburger { display: flex; }
  .topnav__brand { display: none; }
  .topnav { padding: 0 16px; }
  .user-menu__name { display: none; }

  .content { padding: 20px 16px; }
  .footer { padding: 12px 16px; flex-direction: column; gap: 4px; text-align: center; }

  .card-grid { grid-template-columns: 1fr; }
  .profile-grid { grid-template-columns: 1fr; }

  .auth-card { padding: 28px 20px; }

  .notif-dropdown { width: calc(100vw - 32px); right: -60px; }

  /* Phase 2 responsive */
  .filter-bar__form { flex-direction: column; }
  .filter-bar__group { width: 100%; }
  .form-control--sm { width: 100%; min-width: 0; }
  .entity-images { grid-template-columns: 1fr; }
  .article-meta__table th { width: auto; }
  .content__meta { flex-direction: column; align-items: flex-start; gap: 6px; }

  /* Chat widget — fullscreen on mobile */
  .chat-widget { bottom: 16px; right: 16px; }
  .chat-widget__toggle { width: 48px; height: 48px; }
  .chat-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    max-height: 100%;
    border-radius: 0;
  }
  .chat-panel__messages { max-height: none; flex: 1; }
}
