/* GFC WhatsApp Connect — tema claro, limpio y tecnológico (sobre Bootstrap 5.3) */
:root {
  --bs-primary: #2563eb;
  --bs-primary-rgb: 37, 99, 235;
  --bs-link-color: #2563eb;
  --bs-link-hover-color: #1d4ed8;
  --bs-body-bg: #f4f6fb;
  --bs-body-color: #1f2937;
  --bs-border-color: #e3e8f0;
  --bs-body-font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bs-body-font-size: .9rem;
  --gfc-sidebar-w: 248px;
  --gfc-topbar-h: 56px;
  --gfc-accent-soft: #eaf1ff;
  --gfc-muted: #6b7280;
  --gfc-in: #ffffff;
  --gfc-out: #dbeafe;
  --gfc-ai: #ede9fe;
}
.btn-primary { --bs-btn-bg: #2563eb; --bs-btn-border-color: #2563eb; --bs-btn-hover-bg: #1d4ed8; --bs-btn-hover-border-color: #1d4ed8; --bs-btn-active-bg: #1e40af; --bs-btn-active-border-color: #1e40af; }
.btn-outline-primary { --bs-btn-color: #2563eb; --bs-btn-border-color: #2563eb; --bs-btn-hover-bg: #2563eb; --bs-btn-hover-border-color: #2563eb; }
.text-bg-primary { background-color: #2563eb !important; }
.form-control:focus, .form-select:focus, .form-check-input:focus { border-color: #93b4f6; box-shadow: 0 0 0 .2rem rgba(37, 99, 235, .15); }
.form-check-input:checked { background-color: #2563eb; border-color: #2563eb; }

/* ---------- Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--gfc-sidebar-w); background: #fff; border-right: 1px solid var(--bs-border-color); display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 1030; transition: transform .2s; }
.sidebar-brand { height: var(--gfc-topbar-h); display: flex; align-items: center; gap: .6rem; padding: 0 1.1rem; border-bottom: 1px solid var(--bs-border-color); font-weight: 650; letter-spacing: -.01em; color: #0f172a; text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, #2563eb, #22c1c3); color: #fff; display: grid; place-items: center; font-size: 1rem; }
.sidebar-nav { padding: .9rem .7rem; flex: 1; overflow-y: auto; }
.nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #9aa3b2; padding: .8rem .7rem .35rem; }
.sidebar .nav-link { display: flex; align-items: center; gap: .7rem; color: #475569; padding: .5rem .7rem; border-radius: .55rem; font-weight: 500; }
.sidebar .nav-link i { font-size: 1.05rem; color: #94a3b8; width: 1.2rem; text-align: center; }
.sidebar .nav-link:hover { background: #f1f5f9; color: #0f172a; }
.sidebar .nav-link.active { background: var(--gfc-accent-soft); color: #1d4ed8; }
.sidebar .nav-link.active i { color: #2563eb; }
.sidebar-footer { padding: .8rem 1.1rem; border-top: 1px solid var(--bs-border-color); font-size: .72rem; color: var(--gfc-muted); }
.main { flex: 1; margin-left: var(--gfc-sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar { height: var(--gfc-topbar-h); background: #fff; border-bottom: 1px solid var(--bs-border-color); display: flex; align-items: center; gap: .75rem; padding: 0 1.25rem; position: sticky; top: 0; z-index: 1020; }
.topbar h1 { font-size: 1.05rem; font-weight: 650; margin: 0; letter-spacing: -.01em; }
.content { padding: 1.4rem 1.25rem 2rem; flex: 1; }
.content.flush { padding: 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--gfc-accent-soft); color: #1d4ed8; display: inline-grid; place-items: center; font-weight: 600; font-size: .78rem; flex: none; }
.avatar-sm { width: 30px; height: 30px; font-size: .72rem; }
.avatar-lg { width: 56px; height: 56px; font-size: 1.1rem; }
.env-badge { font-size: .65rem; letter-spacing: .06em; }
.demo-banner { background: #fff7ed; border-bottom: 1px solid #fed7aa; color: #9a3412; font-size: .78rem; padding: .35rem 1.25rem; }

/* ---------- Cards / stats ---------- */
.card { border: 1px solid var(--bs-border-color); border-radius: .8rem; box-shadow: 0 1px 2px rgba(15, 23, 42, .03); }
.card-header { background: transparent; border-bottom: 1px solid var(--bs-border-color); font-weight: 600; padding: .8rem 1rem; }
.stat-card .stat-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; font-size: 1.2rem; background: var(--gfc-accent-soft); color: #2563eb; }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; }
.stat-card .stat-label { color: var(--gfc-muted); font-size: .8rem; }
.table > :not(caption) > * > * { padding: .65rem .85rem; }
.table thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--gfc-muted); font-weight: 600; background: #fafbfd; border-bottom-color: var(--bs-border-color); }
.dot { display: inline-block; width: .55rem; height: .55rem; border-radius: 50%; background: #cbd5e1; }
.dot.ok { background: #22c55e; } .dot.warn { background: #f59e0b; } .dot.bad { background: #ef4444; }
.kv dt { color: var(--gfc-muted); font-weight: 500; font-size: .8rem; }
.kv dd { margin-bottom: .6rem; }
code.token { background: #f1f5f9; padding: .1rem .4rem; border-radius: .35rem; font-size: .8rem; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: radial-gradient(1200px 500px at 10% -10%, #dbeafe 0, transparent 60%), radial-gradient(900px 500px at 100% 110%, #cffafe 0, transparent 55%), #f4f6fb; }
.login-card { width: 100%; max-width: 400px; }

/* ---------- Inbox ---------- */
.inbox { display: flex; height: calc(100vh - var(--gfc-topbar-h)); background: #fff; position: relative; }
.inbox-list { width: 340px; border-right: 1px solid var(--bs-border-color); flex-direction: column; flex: none; }
.inbox-filters { padding: .75rem; border-bottom: 1px solid var(--bs-border-color); background: #fafbfd; }
.conv-scroll { overflow-y: auto; flex: 1; }
.conv-item { display: flex; gap: .7rem; padding: .7rem .85rem; border-bottom: 1px solid #f0f3f8; color: inherit; text-decoration: none; }
.conv-item:hover { background: #f8fafc; color: inherit; }
.conv-item.active { background: var(--gfc-accent-soft); }
.conv-item .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .preview { color: var(--gfc-muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .meta { font-size: .7rem; color: var(--gfc-muted); white-space: nowrap; }
.conv-item .body { min-width: 0; flex: 1; }
.unread { background: #2563eb; color: #fff; border-radius: 99px; font-size: .68rem; padding: .05rem .45rem; font-weight: 600; }
.inbox-chat { flex: 1; min-width: 0; flex-direction: column; background: #eef2f8; }
.chat-header { background: #fff; border-bottom: 1px solid var(--bs-border-color); padding: .6rem 1rem; display: flex; align-items: center; gap: .75rem; }
.chat-messages { flex: 1; overflow-y: auto; padding: 1rem 1.25rem; display: flex; flex-direction: column; gap: .35rem; }
.msg { max-width: min(560px, 82%); padding: .5rem .7rem .3rem; border-radius: .8rem; box-shadow: 0 1px 1px rgba(15, 23, 42, .06); word-wrap: break-word; overflow-wrap: anywhere; }
.msg-in { background: var(--gfc-in); align-self: flex-start; border-top-left-radius: .2rem; }
.msg-out { background: var(--gfc-out); align-self: flex-end; border-top-right-radius: .2rem; }
.msg-out.msg-ai { background: var(--gfc-ai); }
.msg-sender { font-size: .68rem; font-weight: 600; color: #475569; margin-bottom: .1rem; }
.msg-foot { display: flex; justify-content: flex-end; align-items: center; gap: .3rem; font-size: .68rem; color: var(--gfc-muted); margin-top: .1rem; }
.msg-body { white-space: pre-wrap; }
.msg-img { max-width: 260px; max-height: 260px; border-radius: .5rem; display: block; margin-bottom: .25rem; }
.media-placeholder { display: flex; align-items: center; gap: .6rem; background: rgba(255, 255, 255, .6); border: 1px dashed #b6c2d6; border-radius: .6rem; padding: .6rem .8rem; color: #475569; margin-bottom: .25rem; }
.media-placeholder i { font-size: 1.4rem; }
.day-sep { align-self: center; font-size: .7rem; background: #dfe6f1; color: #475569; padding: .1rem .7rem; border-radius: 99px; margin: .5rem 0; }
.chat-composer { background: #fff; border-top: 1px solid var(--bs-border-color); padding: .7rem 1rem; }
.chat-composer textarea { resize: none; }
.inbox-details { width: 300px; border-left: 1px solid var(--bs-border-color); background: #fff; overflow-y: auto; flex: none; padding: 1rem; }
.empty-state { margin: auto; text-align: center; color: var(--gfc-muted); padding: 2rem; }
.empty-state i { font-size: 2.5rem; color: #cbd5e1; }

/* ---------- Responsive ---------- */
.sidebar-toggle { display: none; }
.sidebar-backdrop { display: none; }
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(15, 23, 42, .25); }
  .sidebar-backdrop.open { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 1025; }
  .main { margin-left: 0; }
  .sidebar-toggle { display: inline-flex; }
  .inbox-list { width: 100%; border-right: 0; }
}
@media (max-width: 1399.98px) {
  .inbox-details { display: none; position: absolute; right: 0; top: 0; bottom: 0; z-index: 5; box-shadow: -10px 0 30px rgba(15, 23, 42, .12); max-width: 92vw; }
  .inbox-details.open { display: block; }
}
@media (min-width: 1400px) { .details-toggle { display: none; } }
