/* VARIABLES */
:root {
  --qs-blue: #3775b8;
  --qs-blue-dark: #22577e;
  --qs-blue-light: #50B6FF;
  --qs-teal: #2DCCCD;
  --qs-gray: #5b5b60;
  --bg: #f6f9fd;
  --card: #ffffff;
  --border: #e6eef8;
  --shadow: 0 14px 40px rgba(34, 87, 126, .12);
  --shadow-soft: 0 10px 26px rgba(34, 87, 126, .10);
  --radius: 18px;
  --radius-lg: 26px;
  --ok: #1f9d55;
  --warn: #c27803;
  --danger: #b00020;
  --info: #0b6bd6;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
}

/* BASE RESET (Scoped) */
.iconbar *,
.modal-content-wrapper * {
  box-sizing: border-box;
}

/* NAV LAYOUT REDESIGN */
.iconbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  width: 100%;
}

.iconbar .wrap {
  max-width: 98%;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: nowrap;
}

/* LOGO */
.header-logo-img {
  height: 44px;
  /* Fix height to match avatar */
  width: auto;
  display: block;
}

/* CENTER NAV */
.nav-center {
  display: flex;
  gap: 8px;
  /* Slightly tighter gap */
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  flex: 1;
  /* Take mainly center space */
}

/* ICON BUTTONS */
.iconbtn {
  width: 70px;
  height: auto;
  /* Remove fixed height */
  min-height: 60px;
  /* Ensure sufficient touch area but not too tall */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* Center vertically */
  gap: 4px;
  padding: 6px 4px;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
  user-select: none;
  text-decoration: none !important;
  color: inherit;
}

.iconbtn:hover {
  background: rgba(55, 117, 184, .06);
  border-color: rgba(55, 117, 184, .18);
  transform: translateY(-1px);
}

.iconbtn.active {
  background: rgba(55, 117, 184, .10);
  border-color: rgba(55, 117, 184, .35);
  box-shadow: 0 10px 24px rgba(34, 87, 126, .10);
}

.icon {
  width: 24px;
  height: 24px;
  color: var(--qs-blue);
  flex-shrink: 0;
}

.label {
  text-align: center;
  font-size: 8px;
  /* Slightly smaller to fit compactly */
  letter-spacing: .2px;
  color: var(--qs-blue);
  font-weight: 800;
  line-height: 1.1;
  text-transform: uppercase;
}

/* AVATAR (IA) */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(55, 117, 184, .18), rgba(34, 87, 126, .18));
  border: 1px solid rgba(55, 117, 184, .25);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(34, 87, 126, .12);
}

.avatar span {
  font-size: 10px;
  color: var(--qs-blue-dark);
  font-weight: 800;
}

/* USER PROFILE MENU */
.qs-user-wrapper {
  position: relative;
  margin-left: 10px;
  display: flex;
  align-items: center;
  /* Ensure vertical center */
}

.qs-user-avatar {
  width: 44px;
  /* Matches Logo Height */
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--qs-blue), var(--qs-blue-dark));
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(34, 87, 126, .2);
  transition: transform 0.2s;
  user-select: none;
}

.qs-user-avatar:hover {
  transform: scale(1.05);
}

.qs-user-dropdown {
  position: absolute;
  top: 55px;
  /* Below avatar */
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  width: 180px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1000;
  animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.qs-user-dropdown.hidden {
  display: none;
}

.qs-user-dropdown a {
  padding: 12px 16px;
  text-decoration: none;
  color: var(--qs-blue-dark);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.1s;
  border-bottom: 1px solid rgba(0, 0, 0, 0.03);
  display: block;
}

.qs-user-dropdown a:hover {
  background: rgba(55, 117, 184, .06);
}

.qs-user-dropdown a.logout {
  color: var(--danger);
  border-top: 1px solid var(--border);
  border-bottom: none;
}

/* RESPONSIVE */
/* MOBILE ELEMENTS DEFAULT (Hidden on Desktop) */
.mobile-toggle,
.mobile-menu {
  display: none !important;
}

@media (max-width: 1024px) {
  .label {
    display: none;
  }

  .iconbtn {
    width: 45px;
    height: 45px;
    padding: 0;
    justify-content: center;
  }

  .nav-center {
    gap: 8px;
  }
}

@media (max-width: 768px) {

  /* Prevent content from being hidden behind fixed top nav */
  body {
    padding-top: 70px !important;
    padding-bottom: 0 !important;
  }

  /* FIXED TOP NAVBAR */
  .iconbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    border-bottom: 1px solid var(--border);
    border-top: none;
    background: #fff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    height: 70px;
    padding: 0;
  }

  .iconbar .wrap {
    width: 100%;
    max-width: 100%;
    height: 100%;
    padding: 0 16px;
    margin: 0;
    justify-content: space-between;
    /* Spread items */
    align-items: center;
    flex-wrap: nowrap;
  }

  /* 1. LOGO: Visible but smaller */
  .header-logo-img {
    /* Ensure original class works or add mobile specific rule if needed */
    height: 32px;
    width: auto;
    display: block;
  }

  .brand-logo-link {
    display: block;
    margin-right: auto;
    /* Push everything else to the right, or keep spaced */
    flex-shrink: 0;
  }

  /* 2. DESKTOP USER PROFILE: Hidden */
  .qs-user-wrapper {
    display: none;
  }

  /* 3. CENTER NAV: Reset for mobile to be just icons on the right */
  .nav-center {
    width: auto;
    height: 100%;
    flex: 0 1 auto;
    /* Don't grow */
    order: 0;
    margin: 0;
    gap: 4px;
    overflow: visible;
    /* No scroll needed now */
  }

  /* HIDE ALL ICONS BY DEFAULT ON MOBILE */
  .iconbtn {
    display: none;
    min-width: 0;
    width: 48px;
    /* Smaller touch target for bar */
    height: 100%;
    padding: 0;
    border: none;
  }

  /* SHOW ONLY KEY ICONS */
  .iconbtn[data-id="inicio"],
  .iconbtn[data-id="recetar"],
  .iconbtn[data-id="assistant"] {
    display: flex;
    /* Show these */
  }

  /* HIDE LABELS ON BAR TO SAVE SPACE */
  .iconbtn .label {
    display: none;
  }

  /* 4. HAMBURGER BUTTON */
  .mobile-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 100%;
    background: transparent;
    border: none;
    color: var(--qs-blue);
    cursor: pointer;
    margin-left: 4px;
  }

  /* 5. MOBILE MENU DRAWER */
  .mobile-menu {
    position: fixed;
    top: 70px;
    right: 0;
    width: 260px;
    background: #fff;
    border: 1px solid var(--border);
    box-shadow: -4px 10px 30px rgba(0, 0, 0, 0.15);
    border-radius: 0 0 0 16px;
    display: flex;
    flex-direction: column;
    padding: 10px 0;
    z-index: 9998;
    max-height: calc(100vh - 70px);
    overflow-y: auto;
    animation: slideInRight 0.2s ease-out;
  }

  @keyframes slideInRight {
    from {
      transform: translateX(100%);
      opacity: 0;
    }

    to {
      transform: translateX(0);
      opacity: 1;
    }
  }

  .mobile-menu.hidden {
    display: none;
  }

  .mobile-menu a {
    padding: 14px 20px;
    text-decoration: none;
    color: var(--qs-blue-dark);
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
  }

  .mobile-menu a:hover {
    background: rgba(55, 117, 184, .06);
  }

  .mobile-menu a svg {
    width: 20px;
    height: 20px;
    color: var(--qs-blue);
    opacity: 0.8;
  }

  .mobile-menu .separator {
    height: 1px;
    background: var(--border);
    margin: 8px 0;
  }

  .mobile-menu a.logout {
    color: var(--danger);
    font-weight: 700;
  }

  .mobile-menu a.logout svg {
    color: var(--danger);
  }

  /* ADJUST MODAL Z-INDEX TO BE ABOVE NAV */
  #ia-doctor-modal-overlay {
    z-index: 100000;
    /* Higher than nav */
  }
}

/* DESKTOP: Hide Mobile specific elements */



/* ================= MODAL STYLES (Copied & Adapted) ================= */

.topbar {
  background: #eef5ff;
  border-bottom: 1px solid var(--border);
}

.topbar .wrap {
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  height: 32px;
  width: auto;
  object-fit: contain;
}

.brand-text h1 {
  margin: 0;
  font-size: 15px;
  color: var(--qs-blue-dark);
  font-weight: 900;
}

.brand-text span {
  font-size: 11px;
  color: var(--qs-gray);
}

.spacer {
  flex: 1;
}

.btn {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 8px 14px;
  font-weight: 800;
  cursor: pointer;
  background: var(--qs-blue);
  color: #fff;
  box-shadow: 0 6px 14px rgba(55, 117, 184, .18);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.btn.secondary {
  background: #fff;
  color: var(--qs-blue-dark);
  border-color: rgba(55, 117, 184, .25);
  box-shadow: none;
}

.btn.ok {
  background: var(--ok);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.container {
  padding: 20px;
}

/* SHELL & TABS */
.agents-shell {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.shell-hd {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(90deg, rgba(55, 117, 184, .05), transparent);
}

.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tab {
  padding: 8px 12px;
  border-radius: 99px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--qs-gray);
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: 0.2s;
}

.tab:hover {
  background: rgba(0, 0, 0, 0.03);
}

.tab.active {
  background: #fff;
  border-color: var(--border);
  color: var(--qs-blue-dark);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.tab svg {
  width: 16px;
  height: 16px;
  opacity: 0.8;
}

.shell-body {
  padding: 20px;
}

/* PANELS */
.panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  margin-bottom: 20px;
}

.panel-hd {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-hd h2 {
  margin: 0;
  font-size: 13px;
  text-transform: uppercase;
  color: var(--qs-blue-dark);
  font-weight: 800;
}

.panel-hd .hint {
  font-size: 11px;
  color: var(--qs-gray);
  font-weight: 600;
}

.panel-body {
  padding: 16px;
}

/* FORMS */
.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.field label {
  font-size: 11px;
  font-weight: 800;
  color: var(--qs-gray);
  text-transform: uppercase;
}

textarea,
input {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  background: #fff;
}

textarea:focus,
input:focus {
  border-color: var(--qs-blue);
}

textarea {
  min-height: 80px;
  resize: vertical;
}

/* DROP ZONES */
.drop {
  border: 2px dashed var(--border);
  background: #fdfdfd;
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  transition: 0.2s;
  cursor: pointer;
}

.drop:hover {
  border-color: var(--qs-blue);
  background: rgba(55, 117, 184, 0.02);
}

.drop-icon {
  color: var(--qs-blue-light);
  margin-bottom: 10px;
  display: flex;
  justify-content: center;
}

.drop b {
  display: block;
  color: var(--qs-blue-dark);
  margin-bottom: 4px;
}

.drop p {
  font-size: 12px;
  color: var(--qs-gray);
  margin: 0;
}

/* RECORDING */
.statusline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--qs-gray);
}

.mic {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
}

.mic.on {
  background: var(--ok);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.5;
    transform: scale(1.2);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* TOAST */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 12px 20px;
  border-radius: 30px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 999999;
  opacity: 0;
  pointer-events: none;
  transition: 0.3s;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-10px);
}

.toast-icon svg {
  width: 20px;
  height: 20px;
}

/* LOADER */
.loader {
  display: none;
  justify-content: center;
  padding: 20px;
}

.loader.show {
  display: flex;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--qs-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* AUTHORS AGENTS */
.agent-list {
  display: grid;
  gap: 14px;
}

.agent-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.agent-header {
  padding: 12px;
  display: flex;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: #fbfbfb;
}

.agent-avatar {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--qs-teal), var(--qs-blue));
  border-radius: 8px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
}

.agent-info {
  flex: 1;
}

.agent-name {
  font-weight: 800;
  color: var(--qs-blue-dark);
  font-size: 14px;
}

.agent-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.meta-badge {
  font-size: 10px;
  padding: 2px 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--qs-gray);
  font-weight: 600;
}

.meta-badge.concordance {
  background: #e0fbfb;
  border-color: #bdfdfd;
  color: #008888;
}

.agent-body {
  padding: 12px;
  font-size: 13px;
  line-height: 1.5;
  color: #444;
}

.section-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--qs-blue);
  margin-bottom: 6px;
}

/* CHIPS */
.chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.chip {
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px dashed var(--qs-blue-light);
  font-size: 12px;
  cursor: pointer;
  color: var(--qs-blue-dark);
  background: #f0f9ff;
}

.chip:hover {
  background: #e0f2fe;
}

.chip.on {
  background: var(--qs-blue);
  color: #fff;
  border-style: solid;
  border-color: var(--qs-blue);
}

/* TOGGLE */
.toggle-row {
  display: flex;
  gap: 10px;
  align-items: center;
  background: #f4f8fb;
  padding: 10px;
  border-radius: 10px;
  margin: 10px 0;
}

.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 22px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked+.slider {
  background-color: var(--qs-blue);
}

input:checked+.slider:before {
  transform: translateX(18px);
}

/* UTILS */
.hidden {
  display: none !important;
}

.muted {
  color: #999;
}

.small {
  font-size: 12px;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* MAP */
.concordance-map {
  padding: 16px;
  background: #fcfcfc;
  border: 1px solid var(--border);
  border-radius: 16px;
  margin-bottom: 16px;
}

.bubble-container {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  min-height: 100px;
  align-items: center;
}

.bubble {
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(55, 117, 184, 0.1);
  border: 2px solid var(--qs-blue);
  transition: 0.2s;
}

.bubble:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.bubble-pct {
  font-weight: 800;
  font-size: 16px;
  color: var(--qs-blue-dark);
}

.bubble-name {
  font-size: 9px;
  max-width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* URGENCY */
.urgency-bar {
  height: 12px;
  background: linear-gradient(90deg, #4fd1c5, #f6e05e, #f56565);
  border-radius: 6px;
  position: relative;
  margin-top: 6px;
}

.urgency-needle {
  width: 2px;
  height: 16px;
  background: #333;
  position: absolute;
  top: -2px;
  transition: 0.5s;
}