:root {
  --bg: #f5f5f5;
  --panel: #ffffff;
  --panel-strong: #f3f4f6;
  --border: #e5e7eb;
  --text: #232323;
  --muted: #6b7280;
  --accent: #c3131c;
  --accent-strong: #c1101e;
  --danger: #c20e1a;
  --success: #22c55e;
  --warning: #f59e0b;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  --radius: 14px;
  --radius-sm: 10px;
  --gap: 14px;
  --inclusion: #c20e1a;
}

* {
  box-sizing: border-box;
}

/* header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  gap: 14px;
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
} */

.branding {
  display: flex;
  align-items: center;
  gap: 12px;
}

.branding .avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #c3131c, #c1101e);
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #ffffff;
  box-shadow: var(--shadow);
}

.branding h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.4px;
}

.subline {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);

}

.pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.15);

}

.hi-button {
  border: none;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: linear-gradient(130deg, var(--accent), var(--accent-strong));
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

.hi-button.secondary {
  background: #f3f4f6;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}

.hi-button:hover {
  transform: translateY(-1px);
  color: #ffffff !important;
}

.hi-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.disabled {
  display: none;
}

#layoutRoot {
  flex: 1;
  padding: 18px;
  display: grid;
  gap: var(--gap);
  min-height: 0;
  grid-template-rows: 1fr;
  height: calc(100vh - 140px);
  /* min-height: 600px */
}

/* Layouts */
.layout.company {
  grid-template-columns: 340px 1fr 340px;
  grid-template-areas:
    "side chat assigned";
}

.layout.student {
  grid-template-columns: 360px 1fr 360px;
  grid-template-areas:
    "companies chat conversations";
}

section.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  position: relative;
}

section header.panel-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.panel-title {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-title span.badge {
  background: rgba(6, 182, 212, 0.1);
  color: var(--accent);
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.panel-body {
  padding: 12px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.search {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  outline: none;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: linear-gradient(135deg, #ffffff, #f5f5f5);
  cursor: pointer;
  transition: border 120ms ease, transform 120ms ease;
  display: flex;
  align-items: center;
  gap: 12px;
}

.card:hover {
  border-color: #c20e1a;
  transform: translateY(-1px);
}

.card .title {
  font-weight: 700;
  margin: 0;
  text-transform: capitalize;
}

.card .subtitle {
  color: var(--muted);
  margin: 2px 0 0;
  font-size: 13px;
}

.pill-small {
  padding: 4px 10px;
  background: #f5f5f5;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
}

.badge-unread {
  background: rgba(193, 17, 30, 0.12);
  color: var(--danger);
  border: 1px solid rgba(193, 17, 30, 0.3);
  min-width: 44px;
  justify-content: center;
}

.status-dot.disabled-status {
  display: none;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.15);
  background: var(--success);
  flex-shrink: 0;
}

.status-dot.offline {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(197, 34, 34, 0.15);
}



.unread-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(193, 17, 30, 0.15);
  flex-shrink: 0;
}

.chat-window {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: white;
}

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.unread-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.unread-divider::before,
.unread-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.bubble {
  width: fit-content;
  max-width: 76%;
  padding: 10px 12px;
  border-radius: 14px;
  line-height: 1.4;
  position: relative;
  border: 1px solid transparent;
}

.chat-body .bubble .bubble-message-text {
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: normal;
  hyphens: none;
  min-width: 0;
}

.bubble.me {
  margin-left: auto;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #ffffff;
  /* font-weight: 700; */
  border-color: rgba(0, 0, 0, 0.08);
}

.bubble.other {
  background: #f3f4f6;
  border-color: var(--border);
}

.bubble .meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.bubble.me .meta,
.bubble.me .chip {
  color: white;
}

.bubble .author {
  font-weight: 700;
  color: var(--text);
  text-transform: capitalize;
}

.bubble.me .author {
  font-weight: 700;
  color: #fff;
  text-transform: capitalize;
}

.input-area {
  padding: 12px;
  border-top: 1px solid var(--border);
  background: #fff;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
}

#messageInput {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  color: var(--text);
  outline: none;
  height: 20px !important;
  resize: vertical;
}

.empty-chat {
  flex: 1;
  display: grid;
  place-items: center;
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

.chip {
  border-radius: 999px;
  border: 1px dashed var(--border);
  padding: 6px 10px;
  color: var(--muted);
  font-size: 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.stat-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: #f3f4f6;
}

.stat-card h4 {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.stat-card .value {
  font-size: 22px;
  font-weight: 800;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.preview {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}

.pill-assign {
  background: rgba(6, 182, 212, 0.08);
  color: var(--accent);
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.pill-assign.other {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.4);
  color: var(--warning);
}

.pill-assign.none {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border);
  color: var(--muted);
}

.btn-open-profile {
  background: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.3);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s;
}

.btn-open-profile:hover {
  background: rgba(59, 130, 246, 0.2);
}

/* .row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
} */

.small {
  font-size: 12px;
  color: var(--muted);
}

.call-container {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  min-height: 220px;
  background: rgba(255, 255, 255, 0.02);
  display: none;
}

.call-container.active {
  display: block;
}

.toast {
  position: fixed;
  left: 18px;
  top: 24px;
  background: rgba(0, 0, 0, 0.7);
  color: #ffffff;
  border: 1px solid white;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  display: none;
  z-index: 9999;
}

.toast.show {
  display: block;
}

.container-avatar-title {
  display: flex;
  align-items: center;
  gap: 8px;

}

.container-avatar-title .avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: contain;
}

.sound-toggle-container {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.sound-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  padding-right: 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  transition: all 0.2s ease;
}

.sound-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

.sound-toggle input[type="checkbox"] {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 40px;
  height: 20px;
  background: #6b7280;
  border-radius: 10px;
  position: relative;
  cursor: pointer;
  transition: background 0.3s ease;
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  border: none;
  outline: none;
}

.sound-toggle input[type="checkbox"]:checked {
  background: var(--inclusion);
}

.sound-toggle input[type="checkbox"]::before {
  content: '' !important;
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  top: 2px;
  left: 2px;
  transition: transform 0.3s ease;
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
}

.sound-toggle input[type="checkbox"]:checked::before {
  transform: translateX(20px);
}


.toggle-label {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}


.assignment-warning {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: rgba(251, 251, 251, 0.166);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: slideDown 0.3s ease;
  flex-direction: column;
  height: 100%;
  justify-content: center;
  text-align: center;
  position: absolute;
  top: 52.59px;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.assignment-warning#cvWarning {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: rgba(251, 251, 251, 0.166);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: slideDown 0.3s ease;
  flex-direction: column;
  height: 100%;
  justify-content: center;
  text-align: center;
  position: absolute;
  top: 66.59px;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}


.warning-icon {
  font-size: 28px;
  flex-shrink: 0;
  margin-top: -60px;
}



.warning-title {
  font-weight: 600;
  font-size: 24px;
  margin-bottom: 4px;
}

.warning-subtitle {
  font-size: 20px;
  opacity: 0.9;
}


.warning-btn {
  padding: 8px 16px;
  font-size: 18px;
  font-weight: 500;
}

@media (max-width: 1400px) {
  .layout.company {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "assigned chat"
      "side chat";
  }
}

@media (max-width: 980px) {
  /* header {
    position: static;
    flex-direction: column;
    align-items: flex-start;
  } */

  html,
  body {
    height: auto;
    overflow: auto;
  }

  #layoutRoot {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: auto;
  }

  section.panel {
    display: flex !important;
    order: 2;
    min-height: 220px;

  }

  .chat-panel {
    order: 1;
    min-height: 420px;
  }

  #sidePanel {
    order: 2;
  }

  #assignedPanel {
    order: 3;
  }

  #companiesPanel {
    order: 2;
  }

  #activeConversationsPanel {
    order: 3;
  }

  .chat-body {
    min-height: 260px;
  }
}

.sim-bar {
  margin: 12px 18px 0;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.02);
  display: grid;
  gap: 8px;
  /* display: none; */
}

.sim-title {
  font-weight: 700;
  font-size: 14px;
}

.sim-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px;
}

.sim-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.sim-grid input,
.sim-grid select {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  outline: none;
}

#simFirebaseConfig {
  width: 100%;
  min-height: 90px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 10px;
  resize: vertical;
  font-family: "Karbon", "Inter", monospace;
}

.sim-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.stats-wrapper {
  margin: 0 18px 18px;
}

.side-tabs {
  display: flex;
  gap: 24px;
}

.tab-btn {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  position: relative;
}

.tab-btn.active {
  background: rgba(193, 17, 30, 0.12);
  color: var(--danger);
  border: 1px solid rgba(193, 17, 30, 0.3);
}

.tab-btn:hover {
  border: 1px solid rgba(193, 17, 30, 0.3);
}



.dot-indicator {
  position: absolute;
  top: -8px;
  right: -12px;
  background-color: var(--inclusion);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;


}

.container-pill-badge {
  display: flex;
  align-items: center;
  gap: 8px;

}

.number-unread {
  background-color: red;
  color: white;
  border-radius: 50%;
  width: 25px;
  aspect-ratio: 1/1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: max(20px, fit-content);
  position: relative;
}

.tmp {
  position: absolute;
  top: 46%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 14px;

}


#chatTitle {
  text-transform: capitalize !important;
}

.container-toolbar {
  width: 100%;
  padding: 18px;
  padding-bottom: 0;
}

.general-toolbar {
  width: 100%;
  min-height: 50px;
  background-color: #fff;
  border-radius: var(--radius);
  border: 1px solid;
  border-color: var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  gap: 10px;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar-company-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-btn {
  font-size: 13px !important;
  padding: 6px 12px !important;
}

.chat-header-actions {
  margin-left: auto;
}

#cvBannerAzienda {
  display: none;
  background: #c59101;
  color: #fff;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  width: 100%;
  box-sizing: border-box;
}

.author{
  display: none;
}