/* ============================================================
   GECOS Backoffice Style — Custom overrides on Bootstrap 5
   ============================================================ */

:root {
  --sidebar-bg: #1D3341;
  --sidebar-width: 250px;
  --accent: #2B84A2;
  --accent-hover: #256f89;
  --body-bg: #F5F7FA;
  --card-shadow: 0 1px 4px rgba(0, 0, 0, .10);
}

/* ---- Typography ---- */
body {
  font-family: 'Inter', sans-serif;
  background-color: var(--body-bg);
  font-size: .925rem;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: transform .25s ease;
}

.sidebar-brand {
  padding: 1.25rem 1.5rem;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .02em;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: .6rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-brand:hover { color: #fff; text-decoration: none; }

.sidebar .nav-section-label {
  padding: .75rem 1.25rem .25rem;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.35);
}

.sidebar .nav-link {
  color: rgba(255,255,255,.75);
  padding: .55rem 1.25rem;
  border-radius: 6px;
  margin: 1px .5rem;
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: .875rem;
  transition: background .15s, color .15s;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
  background: var(--accent);
  color: #fff;
}

.sidebar .nav-link .bi {
  font-size: 1rem;
  opacity: .85;
}

/* ---- Sidebar footer (version) ---- */
.sidebar-footer {
  flex-shrink: 0;
  border-top: 1px solid rgba(255,255,255,.08);
  padding: .75rem 1.25rem;
  margin-top: auto;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ---- Page footer ---- */
.backoffice-footer {
  padding: .65rem 1.5rem;
  text-align: center;
  background: #fff;
  border-top: 1px solid #e8ecf0;
  color: #9ca3af;
  font-size: .78rem;
}

/* ---- Main content wrapper ---- */
.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Top navbar ---- */
.topbar {
  background: #fff;
  border-bottom: 1px solid #e8ecf0;
  padding: .65rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 900;
}

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: #1a2535;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .875rem;
  color: #4a5568;
}

/* ---- Page content ---- */
.page-content {
  padding: 1.75rem 2rem;
  flex: 1;
}

/* ---- Cards ---- */
.card {
  border: none;
  box-shadow: var(--card-shadow);
  border-radius: 8px;
}

.card-header {
  background: #fff;
  border-bottom: 1px solid #f0f3f6;
  font-weight: 600;
  border-radius: 8px 8px 0 0 !important;
}

/* ---- Buttons ---- */
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-outline-primary {
  color: var(--accent);
  border-color: var(--accent);
}
.btn-outline-primary:hover {
  background: var(--accent);
  border-color: var(--accent);
}

/* ---- Tables ---- */
.table th {
  font-weight: 600;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #6b7280;
  border-top: none;
}

.cursor-pointer { cursor: pointer; }

/* ---- Badges ---- */
.badge { font-weight: 500; }

.badge-role-admin    { background: #7c3aed; color: #fff; }
.badge-role-manager  { background: var(--accent); color: #fff; }
.badge-role-supervisor { background: #0891b2; color: #fff; }
.badge-role-agent    { background: #059669; color: #fff; }
.badge-role-auditor  { background: #d97706; color: #fff; }

/* ---- Status badges ---- */
.badge-active  { background: #dcfce7; color: #16a34a; }
.badge-closed  { background: #f1f5f9; color: #64748b; }
.badge-handoff { background: #fef3c7; color: #d97706; }

/* ---- Login page ---- */
.login-page {
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 100%;
  max-width: 400px;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,.25);
}

/* ---- Conversation header ---- */
.conv-header {
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--card-shadow);
  padding: .875rem 1.25rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}

.avatar-circle {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
  text-transform: uppercase;
}

/* ---- Chat bubbles ---- */
#msgContainer {
  background: #f5f7fa;
  max-height: 60vh;
  min-height: 200px;
  overflow-y: auto;
  padding: 1.25rem;
}

.msg-inbound .bubble,
.msg-outbound-bot .bubble,
.msg-outbound-agent .bubble {
  border-radius: 5px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .07);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.msg-inbound .bubble    { background: #e9ecef; }
.msg-outbound-bot .bubble   { background: var(--accent); color: #fff; }
.msg-outbound-agent .bubble { background: #198754; color: #fff; }

.bubble-sender {
  font-size: .7rem;
  font-weight: 600;
  opacity: .6;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.bubble-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.bubble-time {
  font-size: .7rem;
  opacity: .55;
  align-self: flex-end;
}

/* ---- Status dots (agent presence) ---- */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-active  { background: #22c55e; }
.status-idle    { background: #f59e0b; }
.status-offline { background: #9ca3af; }

/* ---- Conversation notes ---- */
.note-internal {
  background: #fefce8;
  border: 1px solid #fde68a;
}
.note-whisper {
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
}

/* ---- Channel type badges ---- */
.channel-whatsapp  { background: #25D366; color: #fff; }
.channel-instagram { background: linear-gradient(45deg,#f09433,#e6683c,#dc2743,#cc2366,#bc1888); color: #fff; }
.channel-messenger { background: #0084FF; color: #fff; }
.channel-telegram  { background: #229ED9; color: #fff; }
.channel-sms       { background: #6b7280; color: #fff; }
.channel-webchat   { background: #6366f1; color: #fff; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.show {
    transform: translateX(0);
  }
  .main-wrapper {
    margin-left: 0;
  }
  .page-content {
    padding: 1rem;
  }
}

/* ---- Severity badges ---- */
.badge-severity-debug    { background: #e5e7eb; color: #374151; }
.badge-severity-info     { background: #dbeafe; color: #1d4ed8; }
.badge-severity-warning  { background: #fef3c7; color: #d97706; }
.badge-severity-error    { background: #fee2e2; color: #dc2626; }
.badge-severity-critical { background: #7f1d1d; color: #fef2f2; }
