/* MamontCall Supervisor Console — shared stylesheet */

/* The HTML `hidden` attribute must always win over layout display rules
   (.layout/.login-wrapper set display, which would otherwise override it).
   Without this, the logged-in board can show next to the login form. */
[hidden] { display: none !important; }

/* ── Custom properties ───────────────────────────────────────────────── */
:root {
  --color-bg:       #0f1117;
  --color-sidebar:  #16191f;
  --color-surface:  #1e2128;
  --color-border:   #2a2d35;
  --color-primary:  #3b82f6;
  --color-primary-hover: #2563eb;
  --color-danger:   #ef4444;
  --color-danger-hover: #dc2626;
  --color-success:  #22c55e;
  --color-warning:  #f59e0b;
  --color-text:     #e2e8f0;
  --color-muted:    #94a3b8;
  --color-live:     #22c55e;
  --font-sans:      system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono:      "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  --radius-sm:      4px;
  --radius-md:      8px;
  --radius-lg:      12px;
  --shadow:         0 2px 8px rgba(0,0,0,.4);
}

/* ── Reset ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  line-height: 1.5;
}
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }

/* ── Layout ──────────────────────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--color-sidebar);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  gap: .75rem;
}
.sidebar-brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: .5rem;
  letter-spacing: -.01em;
}
.sidebar-brand span { color: var(--color-primary); }
.sidebar nav { display: flex; flex-direction: column; gap: .25rem; }
.sidebar nav a {
  display: block;
  padding: .5rem .75rem;
  border-radius: var(--radius-sm);
  color: var(--color-muted);
  font-size: .9rem;
  transition: background .15s, color .15s;
}
.sidebar nav a:hover,
.sidebar nav a.active { background: var(--color-surface); color: var(--color-text); text-decoration: none; }
.sidebar-footer {
  margin-top: auto;
  font-size: .8rem;
  color: var(--color-muted);
}
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-sidebar);
  gap: 1rem;
}
.topbar-title { font-size: 1rem; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: .75rem; }
.content { padding: 1.5rem; flex: 1; }

/* ── Login page ──────────────────────────────────────────────────────── */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--color-bg);
}
.login-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}
.login-card h1 {
  font-size: 1.4rem;
  margin-bottom: .25rem;
}
.login-card .subtitle {
  font-size: .875rem;
  color: var(--color-muted);
  margin-bottom: 1.75rem;
}

/* ── Form elements ───────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1rem; }
label { font-size: .85rem; color: var(--color-muted); }
input[type="text"],
input[type="password"],
input[type="search"] {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: .95rem;
  padding: .55rem .75rem;
  width: 100%;
  outline: none;
  transition: border-color .15s;
}
input:focus { border-color: var(--color-primary); }
input::placeholder { color: var(--color-muted); }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-weight: 500;
  padding: .55rem 1.1rem;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary   { background: var(--color-primary);  color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); }
.btn-danger    { background: var(--color-danger);   color: #fff; }
.btn-danger:hover:not(:disabled)  { background: var(--color-danger-hover); }
.btn-ghost     { background: transparent; color: var(--color-muted); border: 1px solid var(--color-border); }
.btn-ghost:hover:not(:disabled)   { background: var(--color-surface); color: var(--color-text); }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }
.btn-full { width: 100%; }

/* ── 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: .9rem;
}
thead { background: var(--color-sidebar); }
th {
  text-align: left;
  padding: .75rem 1rem;
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-muted);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
td {
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,.03); }
.mono { font-family: var(--font-mono); font-size: .85em; }

/* ── Status chips ────────────────────────────────────────────────────── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  border-radius: 99px;
  padding: .2rem .65rem;
  font-size: .78rem;
  font-weight: 500;
  line-height: 1.4;
}
.chip-green  { background: rgba(34,197,94,.15);  color: var(--color-success); }
.chip-yellow { background: rgba(245,158,11,.15); color: var(--color-warning); }
.chip-blue   { background: rgba(59,130,246,.15); color: var(--color-primary); }
.chip-red    { background: rgba(239,68,68,.15);  color: var(--color-danger);  }
.chip-muted  { background: var(--color-surface); color: var(--color-muted);   }
/* Removable member chip */
.chip-remove {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  border-radius: 99px;
  padding: .2rem .5rem .2rem .75rem;
  font-size: .82rem;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}
.chip-remove .rm {
  background: none;
  border: none;
  color: var(--color-muted);
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  transition: color .1s;
}
.chip-remove .rm:hover { color: var(--color-danger); }

/* ── Live indicator ──────────────────────────────────────────────────── */
.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-live);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .35; }
}

/* ── Toast notifications ─────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  z-index: 9999;
}
.toast {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-md);
  padding: .75rem 1rem;
  min-width: 260px;
  max-width: 380px;
  font-size: .9rem;
  box-shadow: var(--shadow);
  animation: toast-in .2s ease;
}
.toast.toast-error   { border-left-color: var(--color-danger); }
.toast.toast-success { border-left-color: var(--color-success); }
.toast.toast-warn    { border-left-color: var(--color-warning); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Misc helpers ────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-muted);
  font-size: .95rem;
}
.empty-state .icon { font-size: 2rem; margin-bottom: .5rem; }
.text-muted  { color: var(--color-muted); }
.text-danger { color: var(--color-danger); }
.text-success{ color: var(--color-success); }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem;  }
.mt-3 { margin-top: 1.5rem;}
.gap-1 { gap: .5rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.error-msg { color: var(--color-danger); font-size: .85rem; margin-top: .5rem; min-height: 1.2em; }

/* ── Team card (admin) ───────────────────────────────────────────────── */
.team-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}
.team-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.team-name { font-weight: 600; font-size: 1rem; }
.members-section { margin-bottom: .75rem; }
.members-label {
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--color-muted);
  margin-bottom: .4rem;
}
.members-chips { display: flex; flex-wrap: wrap; gap: .4rem; min-height: 28px; }
.search-box { position: relative; max-width: 320px; }
.search-box input { padding-right: 2rem; }
.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 100;
  max-height: 200px;
  overflow-y: auto;
}
.search-result-item {
  padding: .55rem .75rem;
  cursor: pointer;
  font-size: .9rem;
  transition: background .1s;
}
.search-result-item:hover { background: var(--color-bg); }

/* ── New team form ───────────────────────────────────────────────────── */
.new-team-form {
  display: flex;
  gap: .5rem;
  align-items: flex-end;
  margin-bottom: 1.5rem;
}
.new-team-form input { max-width: 280px; margin-bottom: 0; }

/* ── Section heading ─────────────────────────────────────────────────── */
.section-heading {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .6rem;
}

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .sidebar { display: none; }
  .content { padding: 1rem; }
  .topbar  { padding: .75rem 1rem; }
}

/* ── Admin v2: Org hierarchy ─────────────────────────────────────────── */

/* Org selector bar */
.org-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.org-list { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.org-btn {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 99px;
  color: var(--color-text);
  font-size: .85rem;
  padding: .3rem .75rem .3rem .9rem;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}
.org-btn:hover { background: var(--color-bg); }
.org-btn.active {
  background: rgba(59,130,246,.12);
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.org-btn .del-org {
  background: none;
  border: none;
  color: var(--color-muted);
  font-size: .8rem;
  cursor: pointer;
  padding: 0 0 0 .2rem;
  line-height: 1;
  flex-shrink: 0;
}
.org-btn .del-org:hover { color: var(--color-danger); }

/* Selected org label */
.selected-org-label {
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--color-muted);
  margin-bottom: 1rem;
}

/* Panel card */
.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 1.25rem;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .8rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-sidebar);
  gap: .75rem;
  flex-wrap: wrap;
}
.panel-title { font-size: .95rem; font-weight: 700; }
.panel-body  { padding: .2rem 0; }
.panel-empty {
  padding: 1.1rem 1.25rem;
  font-size: .88rem;
}
.panel-add-row {
  padding: .85rem 1.25rem;
  border-top: 1px solid var(--color-border);
}

/* Member rows (teams, agents, managers share this) */
.member-row {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .65rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}
.member-row:last-child { border-bottom: none; }
.member-info  { flex: 1; min-width: 0; }
.member-name  { font-size: .9rem; font-weight: 500; }
.member-ext   { font-family: var(--font-mono); font-size: .8rem; color: var(--color-muted); margin-top: .1rem; }
.member-actions { display: flex; align-items: center; gap: .4rem; flex-shrink: 0; margin-left: auto; }

/* Role badge inside member-name */
.member-role-badge {
  display: inline-block;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: .1rem .45rem;
  border-radius: 4px;
  margin-left: .5rem;
  vertical-align: middle;
}
.role-org  { background: rgba(59,130,246,.15);  color: var(--color-primary); }
.role-team { background: rgba(245,158,11,.15);  color: var(--color-warning); }

/* Team checkboxes per agent */
.team-checks {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem .75rem;
  margin-top: .45rem;
}
.team-check-label {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .8rem;
  color: var(--color-muted);
  cursor: pointer;
  user-select: none;
}
.team-check-label input[type="checkbox"] {
  accent-color: var(--color-primary);
  width: 13px;
  height: 13px;
  cursor: pointer;
}

/* Manager teams sub-section */
.mgr-teams-wrap {
  margin-top: .5rem;
  width: 100%;
}
.mgr-teams-wrap label { font-size: .78rem; color: var(--color-muted); }
.mgr-teams-select {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: .85rem;
  padding: .3rem;
  outline: none;
  min-width: 160px;
  max-width: 320px;
  cursor: pointer;
}
.mgr-teams-select:focus { border-color: var(--color-primary); }

/* Role select in manager row */
.role-select {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: .8rem;
  padding: .3rem .5rem;
  outline: none;
  cursor: pointer;
  transition: border-color .15s;
}
.role-select:focus { border-color: var(--color-primary); }

/* Pending-add confirmation form */
.pending-add {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  margin-top: .6rem;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: .65rem;
}
.pending-add .form-group { margin: 0; }
.pending-add .form-group label { font-size: .78rem; }
.pending-add input[type="text"] { max-width: 200px; }
.pending-role-select,
.pending-add select {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: .9rem;
  padding: .5rem .6rem;
  outline: none;
  transition: border-color .15s;
  cursor: pointer;
  width: 100%;
}
.pending-role-select:focus,
.pending-add select:focus { border-color: var(--color-primary); }
.pending-add select[multiple] { padding: .3rem; }
.pending-teams { min-width: 160px; max-width: 240px; }

/* Inline form (org + team create) */
.inline-form {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: nowrap;
}
.inline-form input { max-width: 200px; margin: 0; }

/* Inline edit (rename) */
.inline-edit-wrap { display: flex; align-items: center; gap: .4rem; }
.inline-edit-input {
  max-width: 200px;
  padding: .3rem .5rem !important;
  font-size: .88rem !important;
}
