/* ============================================================
   EC Portal Custom Styles - Emergent Coding Studio
   ============================================================ */

/* --- Fonts --- */
body, .navbar, .sidebar {
  font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif;
}
code, pre, .ec-addr-mono, .ec-addr-code, .ec-inline-code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

/* --- Brand colours --- */
:root {
  --ec-primary:    #1c6ef2;
  --ec-dark:       #0f1923;
  --ec-void:       #f59f00;
  --ec-published:  #37b24d;
  --ec-claimed:    #1971c2;
  --ec-byte:       #e03131;
  --ec-data:       #2f9e44;
  --ec-system:     #e67700;
  --ec-behaviour:  #7048e8;
  --ec-bg:         #596a8454; /* main content-wrapper background */
}

/* ─── Content wrapper background ─────────────────────────────────────────── */
/* Body provides the single background layer. content-wrapper is transparent so
   any uncovered gap area (between content and footer) shows the same colour. */
body.hold-transition,
body {
  background: var(--ec-bg) !important;
}
.content-wrapper {
  background: transparent !important;
}

/* ─── Cards — frosted glass against the blue-grey bg ─────────────────────── */
.card {
  background: rgba(255, 255, 255, 0.88) !important;
  border: 1px solid rgba(255, 255, 255, 0.22) !important;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.18) !important;
}
.card-header {
  background: rgba(255, 255, 255, 0.50) !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
  color: #212121 !important;
}
/* Override AdminLTE's white text on coloured card headers — glass bg is always light */
.card-header *:not(.badge):not(.btn):not(i) {
  color: #212121 !important;
}
.card-header .text-muted,
.card-header small { color: rgba(33, 33, 33, 0.55) !important; }
.card-footer {
  background: rgba(255, 255, 255, 0.42) !important;
  border-top: 1px solid rgba(0, 0, 0, 0.07) !important;
}
/* Card outline variants */
.card.card-outline {
  border-top-width: 3px !important;
}

/* ─── Tables — keep rows legible on the glass cards ─────────────────────── */
.table-striped tbody tr:nth-of-type(odd) {
  background: rgba(0, 0, 0, 0.03);
}
.table-hover tbody tr:hover {
  background: rgba(89, 106, 132, 0.08);
}

/* ─── Small stat boxes ───────────────────────────────────────────────────── */
.small-box {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.22) !important;
}
/* Keep inner text fully opaque */
.small-box .inner h3,
.small-box .inner p { color: #fff; }

/* ─── Modals — stay fully opaque ────────────────────────────────────────── */
.modal-content {
  background: #fff !important;
  border: none !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.28) !important;
}
/* Modal headers/footers — glass style overrides all AdminLTE/Bootstrap bg-* colours */
.modal-header {
  background: rgba(0, 0, 0, 0.03) !important;
  border-bottom: 1px solid #dee2e6 !important;
  color: #212121 !important;
}
.modal-header *:not(.badge):not(.btn):not(i) { color: #212121 !important; }
.modal-footer { background: rgba(0, 0, 0, 0.02) !important; border-top: 1px solid #dee2e6 !important; }

/* ─── Dropdowns ──────────────────────────────────────────────────────────── */
.dropdown-menu {
  background: rgba(255, 255, 255, 0.97) !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2) !important;
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
}

/* ─── Footer ─────────────────────────────────────────────────────────────── */
.main-footer {
  background: #596a8433 !important;
  border-top: 1px solid rgba(255, 255, 255, 0.20) !important;
  color: #343a40;
}

/* ─── Callout / alert panels ─────────────────────────────────────────────── */
.callout {
  background: rgba(255, 255, 255, 0.80) !important;
  border-left-width: 4px;
}
.alert-success   { background-color: #d4edda !important; color: #155724 !important; border-color: #c3e6cb !important; }
.alert-danger    { background-color: #f8d7da !important; color: #721c24 !important; border-color: #f5c6cb !important; }
.alert-warning   { background-color: #fff3cd !important; color: #856404 !important; border-color: #ffeeba !important; }
.alert-info      { background-color: #d1ecf1 !important; color: #0c5460 !important; border-color: #bee5eb !important; }
.alert-primary   { background-color: #cce5ff !important; color: #004085 !important; border-color: #b8daff !important; }
.alert-secondary { background-color: #e2e3e5 !important; color: #383d41 !important; border-color: #d6d8db !important; }
.alert-light     { background-color: #fefefe !important; color: #383d41 !important; border-color: #fdfdfe !important; }
.alert-dark      { background-color: #d6d8d9 !important; color: #1b1e21 !important; border-color: #c6c8ca !important; }
/* Ensure all alert text stays dark regardless of inherited colours */
.alert { color: inherit !important; }
.alert * { color: inherit; }

/* ─── Kanban column bodies ───────────────────────────────────────────────── */
.ec-kanban-col-body {
  background: rgba(255, 255, 255, 0.38) !important;
  min-height: 80px;
  flex: 1;
  padding: 4px;
  border-radius: 0 0 4px 4px;
  transition: background .15s;
}
.ec-kanban-col-body.ec-drop-target {
  background: rgba(209, 236, 253, 0.75) !important;
  outline: 2px dashed #74c0fc;
}

/* ─── Navbar ─────────────────────────────────────────────────────────────── */
.ec-navbar { background: var(--ec-dark) !important; }
.ec-navbar .nav-link { color: rgba(255,255,255,0.85) !important; }
.ec-navbar .nav-link:hover { color: #fff !important; }
.ec-navbar-home    { color: rgba(255,255,255,.7); font-size: 14px; padding: 0 6px 0 4px; }
.ec-navbar-home:hover { color: #fff; text-decoration: none; }
.ec-navbar-title   { color: rgba(255,255,255,.92); font-weight: 600; font-size: 15px; }
.ec-navbar-heading { white-space: nowrap; }

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.main-sidebar, .main-sidebar:hover { width: 210px !important; overflow-x: hidden !important; }
@media (min-width: 992px) {
  .content-wrapper, .main-footer, .main-header { margin-left: 210px !important; }
  body.sidebar-collapse .content-wrapper,
  body.sidebar-collapse .main-footer,
  body.sidebar-collapse .main-header { margin-left: 4.6rem !important; }
}
@media (max-width: 991.98px) {
  .content-wrapper, .main-footer, .main-header { margin-left: 0 !important; }
  /* Sidebar slides in as overlay */
  body.sidebar-open .main-sidebar { margin-left: 0 !important; box-shadow: 4px 0 12px rgba(0,0,0,.4) !important; }
  /* Dim backdrop behind open sidebar */
  body.sidebar-open .content-wrapper::before {
    content: ''; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1033; pointer-events: auto;
  }
}
.ec-sidebar { background: #141c25 !important; }
.ec-brand { background: #0f1923 !important; }
.main-sidebar .brand-link { border-bottom: none !important; }
.ec-user-panel { border-top: none !important; }
.ec-sidebar nav, .ec-sidebar .sidebar > nav { border-top: none !important; }
.ec-brand-logo {
  display: inline-block; background: var(--ec-primary);
  color: #fff; font-weight: 900; font-size: 16px; padding: 2px 7px;
  border-radius: 4px; margin-right: 6px; letter-spacing: 1px;
}
.ec-logo-link { display: block; text-decoration: none; }
.ec-logo-ec { font-size: 2.2rem; font-weight: 900; color: var(--ec-primary); }
.ec-logo-studio { font-size: 1.8rem; font-weight: 300; color: #636e72; }
.ec-logo-sub { color: #b2bec3; font-size: 0.8rem; margin: 0; }
.ec-login-bg { background: var(--ec-dark); }
.ec-role-badge { font-size: 0.65rem; }
.ec-avatar-sm { width: 28px; height: 28px; border-radius: 50%; }
.ec-avatar-placeholder {
  width: 28px; height: 28px; border-radius: 50%;
  background: #2d3436; display: inline-flex; align-items: center; justify-content: center;
  color: #b2bec3;
}

/* ─── Layer badges ───────────────────────────────────────────────────────── */
.ec-layer-badge { color: #fff; font-size: 0.7rem; }
.ec-layer-byte      { background: var(--ec-byte); }
.ec-layer-data      { background: var(--ec-data); }
.ec-layer-system    { background: var(--ec-system); }
.ec-layer-behaviour { background: var(--ec-behaviour); }

/* ─── Component address styles ───────────────────────────────────────────── */
.ec-addr-mono, .ec-addr-code {
  font-size: 0.8rem; color: #495057;
  background: rgba(241, 243, 245, 0.75); padding: 2px 6px; border-radius: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 350px;
}
.ec-addr-pill {
  display: inline-block; font-size: 0.72rem;
  font-family: 'JetBrains Mono', monospace;
  padding: 2px 8px; border-radius: 12px;
  background: rgba(233, 236, 239, 0.80); color: #495057; text-decoration: none;
}
.ec-addr-pill.void      { border: 1px dashed var(--ec-void); color: var(--ec-void); }
.ec-addr-pill.published { background: rgba(211, 249, 216, 0.80); color: #2b8a3e; }
.ec-addr-pill.claimed   { background: rgba(208, 235, 255, 0.80); color: #1864ab; }

/* ─── Component status rows ──────────────────────────────────────────────── */
.ec-component-row.ec-status-void       { background: rgba(255, 251, 235, 0.60); }
.ec-component-row.ec-status-published  { }
.ec-component-row.ec-status-deprecated { opacity: 0.55; }

.ec-proto {
  font-size: 0.75rem; color: #7048e8;
  background: rgba(243, 240, 255, 0.75); padding: 1px 5px; border-radius: 3px;
}

/* ─── Use count badge ────────────────────────────────────────────────────── */
.ec-use-badge { font-size: 0.75rem; padding: 2px 6px; border-radius: 10px; color: #fff; }

/* ─── JSON block ─────────────────────────────────────────────────────────── */
.ec-json-block {
  background: rgba(30, 30, 46, 0.92); color: #cdd6f4; border-radius: 6px;
  padding: 12px; font-size: 0.78rem; overflow-x: auto; max-height: 400px;
}
.ec-json-editor { font-family: 'JetBrains Mono', monospace; font-size: 0.82rem; }

/* ─── Project cards ──────────────────────────────────────────────────────── */
.ec-project-card { transition: transform 0.15s, box-shadow 0.15s; }
.ec-project-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.20) !important; }

/* ─── Kanban board ───────────────────────────────────────────────────────── */
.ec-kanban-board {
  display: flex; flex-wrap: nowrap; gap: 12px; overflow-x: auto;
  padding-bottom: 8px; min-height: 500px;
  /* Ensure scrollbar is always reachable */
  -webkit-overflow-scrolling: touch;
}
.ec-kanban-col {
  flex: 0 0 180px; display: flex; flex-direction: column;
}
.ec-kanban-col-header {
  color: #fff; padding: 8px 10px; border-radius: 6px 6px 0 0;
  font-size: 0.8rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.5px; user-select: none;
}
.ec-kanban-card {
  margin-bottom: 6px; cursor: grab; transition: opacity 0.15s, transform 0.1s;
  border: 1px solid rgba(222, 226, 230, 0.70) !important;
  background: rgba(255, 255, 255, 0.88) !important;
  user-select: none;
}
.ec-kanban-card:hover { transform: translateY(-1px); }
.ec-kanban-card.ec-dragging { opacity: 0.25; transform: none; }
body.ec-kanban-dragging { cursor: grabbing !important; }
body.ec-kanban-dragging * { cursor: grabbing !important; }
.ec-task-title { font-size: 0.82rem; color: #343a40; text-decoration: none; }
.ec-task-title:hover { color: var(--ec-primary); }
.ec-priority-badge { font-size: 0.65rem; }

/* ─── Design Tree Legend ─────────────────────────────────────────────────── */
.ec-legend { gap: 8px; }
.ec-legend-item { font-size: 0.75rem; display: flex; align-items: center; gap: 4px; }
.ec-dot {
  width: 12px; height: 12px; border-radius: 50%; display: inline-block;
}
.ec-dot-void {
  width: 12px; height: 12px; border-radius: 50%;
  background: #ffe066; border: 2px dashed #f59f00; display: inline-block;
}

/* ─── Activity feed ──────────────────────────────────────────────────────── */
.ec-activity-feed .timeline-item { font-size: 0.85rem; }

/* ─── Text over light (card) backgrounds ────────────────────────────────── */
.card-title,
.card-body,
.card-text,
.card-body label,
.card-body .form-text,
.table,
.table th,
.table td,
.card-footer,
.card-footer a,
.main-footer,
.main-footer a,
.breadcrumb,
.breadcrumb-item,
.breadcrumb-item a,
.breadcrumb-item.active {
  color: #212121 !important;
}
/* Muted text stays subtler but still readable */
.card-body .text-muted,
.table .text-muted {
  color: rgba(33, 33, 33, 0.55) !important;
}
/* Links inside cards keep a visible hue */
.card-body a:not(.btn),
.table a:not(.btn) {
  color: #1a56cc !important;
}
.card-body a:not(.btn):hover,
.table a:not(.btn):hover {
  color: #0f3d99 !important;
}

/* ─── Page title ─────────────────────────────────────────────────────────── */
.ec-page-title { font-size: 1.3rem; font-weight: 600; color: #212121; }

/* ─── Responsive tweaks ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .ec-kanban-col { flex: 0 0 160px; }
}

/* ─── Mobile UI — compact spacing and smaller text ──────────────────────── */
@media (max-width: 767.98px) {

  /* Content area — allow overflow so tall pages can scroll */
  .content-wrapper { overflow-y: auto !important; overflow-x: hidden !important; }
  .content { padding: 6px 6px 0 !important; }
  .container-fluid { padding-left: 6px !important; padding-right: 6px !important; }
  .section.content { padding-top: 6px !important; }

  /* Cards */
  .card { margin-bottom: 8px !important; }
  .card-header { padding: 6px 10px !important; }
  .card-body   { padding: 8px 10px !important; }
  .card-footer { padding: 6px 10px !important; }
  .card-title  { font-size: 0.9rem !important; }

  /* Grid gutters */
  .row { margin-left: -5px !important; margin-right: -5px !important; }
  .row > [class*="col-"] { padding-left: 5px !important; padding-right: 5px !important; }

  /* Tables */
  .table th,
  .table td { padding: 5px 8px !important; font-size: 0.8rem !important; }
  .table th  { font-size: 0.75rem !important; }

  /* Buttons */
  .btn        { font-size: 0.8rem !important; padding: 4px 10px !important; }
  .btn-sm     { font-size: 0.75rem !important; padding: 3px 8px !important; }
  .btn-xs     { font-size: 0.7rem !important; padding: 2px 6px !important; }
  .btn-block  { margin-bottom: 4px !important; }

  /* Badges */
  .badge { font-size: 0.65rem !important; }

  /* Form elements */
  .form-control  { font-size: 0.85rem !important; padding: 4px 8px !important; height: auto !important; }
  .form-group    { margin-bottom: 8px !important; }
  label          { font-size: 0.82rem !important; margin-bottom: 2px !important; }
  .input-group-text { font-size: 0.82rem !important; padding: 4px 8px !important; }

  /* Typography */
  h1 { font-size: 1.4rem !important; }
  h2 { font-size: 1.2rem !important; }
  h3 { font-size: 1.05rem !important; }
  h4 { font-size: 0.95rem !important; }
  h5 { font-size: 0.88rem !important; }
  p, li, td, th { font-size: 0.83rem; }

  /* Navbar */
  .main-header.navbar { padding: 0 6px !important; min-height: 48px !important; }
  .ec-navbar-title    { max-width: 110px !important; font-size: 0.82rem !important; }

  /* Small stat boxes */
  .small-box .inner h3 { font-size: 1.6rem !important; }
  .small-box .inner p  { font-size: 0.82rem !important; }
  .small-box           { margin-bottom: 8px !important; }

  /* dl rows */
  .row.dl dt, .row.dl dd,
  dl.row dt, dl.row dd { font-size: 0.8rem !important; padding: 2px 4px !important; }

  /* Modals */
  .modal-header { padding: 8px 12px !important; }
  .modal-body   { padding: 10px 12px !important; }
  .modal-footer { padding: 6px 12px !important; }

  /* Direct-chat (comments) */
  .direct-chat-msg   { margin-bottom: 6px !important; }
  .direct-chat-text  { font-size: 0.8rem !important; padding: 5px 8px !important; }
  .direct-chat-infos { font-size: 0.72rem !important; }

  /* Kanban */
  .ec-kanban-col     { flex: 0 0 145px; }
  .ec-kanban-col-header { padding: 5px 7px !important; font-size: 0.7rem !important; }
  .card-body.p-2     { padding: 5px !important; }

  /* Hide less-essential columns in tables */
  .d-none-xs { display: none !important; }
}

/* ─── Team color swatch picker ───────────────────────────────────────────── */
.ec-color-swatch {
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid transparent;
  transition: transform .12s, border-color .12s;
  flex-shrink: 0;
  position: relative;
}
.ec-color-none { background: #f1f3f5; border-color: #dee2e6 !important; }
.ec-color-swatch:hover { transform: scale(1.18); }
.ec-color-selected { border-color: #212529 !important; transform: scale(1.1); }
.ec-color-swatch input[type=radio] { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }

/* ─── Avatar cascade (teams / project sidebar) ──────────────────────────── */
.ec-av-cascade { display: flex; }
.ec-av-cascade-item, .ec-av-cascade-sm {
  border-radius: 50%;
  overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #7048e8, #4a6cf7);
  flex-shrink: 0;
  text-decoration: none;
  transition: transform .12s;
}
.ec-av-cascade-item { width: 34px; height: 34px; font-size: 13px; margin-left: -8px; }
.ec-av-cascade-sm   { width: 22px; height: 22px; font-size:  9px; margin-left: -5px; }
.ec-av-cascade-item:first-child, .ec-av-cascade-sm:first-child { margin-left: 0; }
.ec-av-cascade-item:hover, .ec-av-cascade-sm:hover { transform: translateY(-3px); }
.ec-av-cascade-item img, .ec-av-cascade-sm img { width: 100%; height: 100%; object-fit: cover; }
.ec-av-sm {
  width: 28px; height: 28px; border-radius: 50%; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #7048e8, #4a6cf7);
  flex-shrink: 0; text-decoration: none;
}
.ec-av-sm img { width: 100%; height: 100%; object-fit: cover; }

/* Notification preference toggle — knob rendered as a child span, all critical
   styles are inline so nothing in AdminLTE/Bootstrap can override them. */
.ec-np-toggle { cursor: pointer; user-select: none; }


/* Rich tooltips — sidebar and topbar */
.tooltip-inner {
  max-width: 220px;
  text-align: left;
  padding: 7px 10px;
  line-height: 1.4;
  font-size: 12px;
}
.tooltip-inner strong {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 2px;
  color: #fff;
}
.tooltip-inner small {
  font-size: 11px;
  opacity: .8;
  color: rgba(255,255,255,.85);
}
