/* ══════════════════════════════════════════════
   CommFlow — CSS Minimalista Funcional
   Diseño limpio sin íconos, tipografía Montserrat + Inter
══════════════════════════════════════════════ */

/* ── FONTS ────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600&family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── DESIGN TOKENS ────────────────────────── */
:root {
  /* Colors - Light Mode */
  --bg: #ffffff;
  --fg: #0a0a0a;
  --muted: #f5f5f5;
  --muted-fg: #737373;
  --border: #e5e5e5;
  --primary: #0a0a0a;
  --primary-fg: #ffffff;
  
  /* Fonts */
  --font-heading: 'Montserrat', sans-serif;
  --font-sans: 'Inter', sans-serif;
  
  /* Radius */
  --r: 0.375rem;
  --r-lg: 0.5rem;
  
  /* Layout */
  --topbar-h: 3.75rem;
  --drawer-w: 18rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0a;
    --fg: #ffffff;
    --muted: #1a1a1a;
    --muted-fg: #a3a3a3;
    --border: #2a2a2a;
    --primary: #ffffff;
    --primary-fg: #0a0a0a;
  }
}

/* ── RESET & BASE ─────────────────────────── */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 400;
  line-height: 1.2;
  color: var(--fg);
}

button {
  font-family: inherit;
}

/* ── UTILITIES ────────────────────────────── */
.hidden { display: none !important; }

/* ── BUTTONS ──────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  background: none;
  border: none;
  border-radius: var(--r);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--fg);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  outline: none;
}

.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-fg);
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-outline {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
}

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

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg);
}

.btn-ghost:hover {
  background: var(--muted);
  border-color: var(--primary);
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
}

.btn-icon-xs {
  width: 2rem;
  height: 2rem;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--fg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: all 0.15s;
}

.btn-icon-xs:hover {
  background: var(--muted);
}

/* ── LOGIN SCREEN ─────────────────────────── */
#loginScreen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-box {
  width: 100%;
  max-width: 24rem;
  padding: 0 1.5rem;
}

.login-logo {
  text-align: center;
  margin-bottom: 1rem;
}

.logo-symbol {
  font-size: 2rem;
  color: var(--fg);
  margin-bottom: 1rem;
}

.login-title {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 300;
  text-align: center;
  margin-bottom: 0.5rem;
  color: var(--fg);
}

.login-subtitle {
  text-align: center;
  font-size: 0.9375rem;
  color: var(--muted-fg);
  margin-bottom: 2rem;
}

.login-form {
  width: 100%;
}

.login-tabs {
  display: flex;
  gap: 2rem;
  justify-content: center;
  margin-bottom: 2rem;
}

.login-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 0.5rem 0;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  color: var(--muted-fg);
  cursor: pointer;
  transition: all 0.2s;
}

.login-tab.active {
  border-bottom-color: var(--primary);
  color: var(--fg);
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--fg);
  margin-bottom: 0.5rem;
}

.form-group small {
  display: block;
  font-size: 0.75rem;
  color: var(--muted-fg);
  margin-top: 0.375rem;
}

.input,
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"] {
  width: 100%;
  padding: 0.75rem 0;
  font-size: 1rem;
  font-family: var(--font-sans);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
  outline: none;
  transition: border-color 0.2s;
}

.input:focus,
.form-group input[type="text"]:focus,
.form-group input[type="email"]:focus,
.form-group input[type="password"]:focus {
  border-bottom-color: var(--primary);
}

.input::placeholder,
.form-group input::placeholder {
  color: var(--muted-fg);
}

.btn-login-continue {
  width: 100%;
  padding: 0.875rem;
  background: transparent;
  border: none;
  border-radius: var(--r);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 400;
  color: #4a5568;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.btn-login-continue:hover {
  color: var(--primary);
}

.btn-login-continue:hover .arrow {
  transform: translateX(0.375rem);
}

.arrow {
  transition: transform 0.3s ease;
}

/* ── CLIENT PICKER ────────────────────────── */
.client-picker {
  position: absolute;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.picker-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.picker-topbar {
  height: var(--topbar-h);
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.picker-user {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--fg);
}

.picker-role-tag {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.125rem 0.5rem;
  border-radius: var(--r);
  background: var(--muted);
  color: var(--muted-fg);
}

.picker-logout {
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  color: var(--fg);
  cursor: pointer;
  transition: all 0.2s;
}

.picker-logout:hover {
  background: var(--muted);
}

.picker-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: 80%;
  margin: 0 auto;
  padding-bottom: 5rem;
}

.picker-label {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 2rem;
  color: var(--fg);
}

.picker-search-wrap {
  width: 40%;
  margin: 0 auto 2rem;
}

.picker-search-input {
  width: 100%;
  padding: 0.75rem 0;
  font-size: 1rem;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
  outline: none;
  transition: border-color 0.2s;
  text-align: center;
}

.picker-search-input:focus {
  border-bottom-color: var(--primary);
}

.picker-search-input::placeholder {
  color: var(--muted-fg);
}

.picker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  width: 100%;
}

.picker-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.5rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  min-height: 5rem;
}

.picker-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  border-color: var(--primary);
  transform: translateY(-2px);
}

.picker-card-name {
  font-size: 0.9375rem;
  font-weight: 400;
  color: var(--fg);
}

/* ── MAIN APP LAYOUT ──────────────────────── */
.app-container {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.workspace-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── TOPBAR ───────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.btn-drawer-toggle {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--fg);
  cursor: pointer;
  padding: 0.5rem;
  line-height: 1;
}

.topbar-client-name {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--fg);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.btn-ai-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--fg);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-ai-badge:hover {
  background: var(--muted);
}

.ai-symbol {
  font-size: 1rem;
}

.ai-badge-count {
  font-size: 0.8125rem;
  font-weight: 600;
}

/* ── DRAWER ───────────────────────────────── */
.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--drawer-w);
  background: var(--bg);
  border-right: 1px solid var(--border);
  z-index: 100;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
}

.drawer.open {
  transform: translateX(0);
}

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,10,10,0.5);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.drawer-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.drawer-header {
  height: var(--topbar-h);
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.drawer-close {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--fg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: all 0.15s;
}

.drawer-close:hover {
  background: var(--muted);
}

.drawer-title {
  font-size: 1rem;
  font-weight: 400;
  color: var(--fg);
}

.drawer-body {
  flex: 1;
  padding: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.drawer-user,
.drawer-user-info {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--muted);
}

.drawer-user-name {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--fg);
}

.drawer-user-role {
  font-size: 0.75rem;
  color: var(--muted-fg);
  margin-top: 0.375rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.drawer-section {
  padding: 0;
}

.drawer-spacer {
  flex: 1;
  min-height: 2rem;
}

.drawer-section-bottom {
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
}

.drawer-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  padding: 1.25rem 1.5rem;
  background: transparent;
  border: none;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 400;
  color: var(--fg);
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
}

.drawer-item:hover {
  background: var(--muted);
}

.drawer-item + .drawer-item {
  margin-top: 0.125rem;
}

.drawer-item-logout {
  color: var(--muted-fg);
}

.drawer-item-logout:hover {
  color: var(--fg);
}

.drawer-item-config {
  /* Same styles as drawer-item */
}

/* ── WORKSPACE ────────────────────────────── */
.workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.timeline-wrapper {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 1.5rem;
  display: flex;
  justify-content: center;
  align-items: flex-start; /* la altura del timeline = su contenido real */
}

.timeline {
  max-width: 56rem;
  width: 100%;
  margin: 0 auto;
  padding: 0 1.5rem 3rem; /* padding-bottom para que la línea cierre bien */
  position: relative;
  z-index: 0;
}

/* Timeline vertical line — via pseudo-element, siempre cubre todo el contenido */
.timeline-line {
  display: none; /* El elemento DOM ya no se usa */
}

.timeline::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 1px;
  background: var(--border);
  z-index: 0;
  pointer-events: none;
}

.tl-date {
  text-align: center;
  margin: 2rem 0 1.5rem;
  position: relative;
  z-index: 2;
}

.tl-date span {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-fg);
  background: var(--bg);
  padding: 0.5rem 1rem;
  position: relative;
  z-index: 3;
}

.tl-row {
  display: grid;
  grid-template-columns: 1fr 2.5rem 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
  align-items: start;
}

.tl-cell-l,
.tl-cell-r {
  display: flex;
}

.tl-cell-l {
  justify-content: flex-end;
}

.tl-cell-r {
  justify-content: flex-start;
}

.tl-cell-c {
  display: flex;
  justify-content: center;
  padding-top: 0.5rem;
  position: relative;
  z-index: 1;
}

.tl-node {
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
  background: #93c5fd;
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 1px #3b82f6;
  position: relative;
  z-index: 2;
}

/* ── EVENT CARDS ──────────────────────────── */
.ev-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  max-width: 24rem;
  width: 100%;
}

.ev-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  border-color: var(--primary);
}

/* Diferenciación por dirección */
.ev-card.dir-in {
  background: #f0f9ff;
  border-color: #e0f2fe;
}

.ev-ch-label {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-fg);
  margin-bottom: 0.5rem;
}

.ev-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 0.5rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ev-summary {
  font-size: 0.75rem;
  color: var(--muted-fg);
  line-height: 1.5;
  margin-bottom: 0.75rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ev-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.6875rem;
  color: var(--muted-fg);
}

.ev-foot-left,
.ev-foot-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.flag-important {
  font-size: 1rem;
  color: #fbbf24;
  line-height: 1;
  flex-shrink: 0;
}

.flag-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #3b82f6;
}

.ev-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  gap: 0.5rem;
}

.ev-time {
  font-size: 0.6875rem;
  color: var(--muted-fg);
}

.ev-manager {
  font-size: 0.6875rem;
  color: var(--muted-fg);
  font-weight: 500;
}

/* Botón toggle respuestas */
.ev-toggle-replies {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.5rem 0;
  cursor: pointer;
  display: block;
  width: 100%;
  text-align: left;
  margin-top: 0.5rem;
}

.ev-toggle-replies:hover {
  text-decoration: underline;
}

/* Contenedor de respuestas */
.ev-replies {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-left: 1rem;
  border-left: 2px solid var(--border);
}

.ev-replies.hidden {
  display: none;
}

/* Card de respuesta (simplificada) */
.ev-reply {
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 0.75rem;
  font-size: 0.8125rem;
}

.ev-reply-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.6875rem;
  color: var(--muted-fg);
}

.ev-reply-sender {
  font-weight: 500;
  color: var(--fg);
}

.ev-reply-title {
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.ev-reply-summary {
  font-size: 0.75rem;
  color: var(--muted-fg);
  line-height: 1.4;
}

/* Botón responder rápido */
.ev-quick-reply {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.6875rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  margin-right: 0.75rem;
}

.ev-quick-reply:hover {
  text-decoration: underline;
}

.ev-more {
  color: var(--fg);
  text-decoration: none;
  font-weight: 500;
}

.ev-more:hover {
  text-decoration: underline;
}

.ev-att-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.625rem;
  font-weight: 600;
  color: #3b82f6;
  padding: 0.125rem 0.5rem;
  background: #dbeafe;
  border-radius: var(--r);
}

/* ── MODALS ───────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,10,10,0.5);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  position: relative;
  width: 90%;
  max-width: 32rem;
  max-height: 90vh;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: 0 12px 40px rgba(0,0,0,0.16);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-event {
  width: 80%;
  max-width: none;
}

.modal-header {
  padding: 2rem 2.5rem 1.5rem;
  flex-shrink: 0;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 2rem;
  right: 2.5rem;
}

.modal-type-row {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-fg);
  margin-bottom: 0.75rem;
}

.modal-title-main {
  font-size: 1.75rem;
  font-weight: 300;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
  color: var(--fg);
}

.modal-date-sub {
  font-size: 0.9375rem;
  color: var(--muted-fg);
}

.modal-tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
  padding: 0 2.5rem;
  flex-shrink: 0;
}

.tab-btn {
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted-fg);
  cursor: pointer;
  transition: all 0.15s;
}

.tab-btn:hover {
  color: var(--fg);
}

.tab-btn.active {
  color: var(--fg);
  border-bottom-color: var(--primary);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 2.5rem;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.modal-footer {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem 2.5rem 2rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.mf-left,
.mf-right {
  display: flex;
  gap: 0.75rem;
}

/* Botón marcar importante — sin borde ni fondo */
.btn-important {
  background: none;
  border: none;
  color: var(--muted-fg);
  font-size: 0.875rem;
  font-family: var(--font-sans);
  padding: 0.25rem 0;
  cursor: pointer;
  transition: color 0.15s;
  letter-spacing: 0.01em;
}

.btn-important:hover {
  color: #f59e0b;
}

.btn-important.is-important {
  color: #f59e0b;
  font-weight: 600;
}

/* Estado "Guardado, sin análisis IA" — bloque de acción manual */
.ai-manual-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.875rem;
  padding: 2.5rem 1rem;
  text-align: center;
}

.ai-manual-icon {
  font-size: 2.5rem;
  color: var(--border);
  line-height: 1;
}

.ai-manual-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--fg);
}

.ai-manual-desc {
  font-size: 0.8125rem;
  color: var(--muted-fg);
  line-height: 1.6;
  max-width: 340px;
}

.btn-ai-manual {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--primary);
  color: var(--primary-fg);
  border: none;
  border-radius: var(--r);
  font-size: 0.875rem;
  font-family: var(--font-sans);
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-ai-manual:hover:not(:disabled) {
  opacity: 0.82;
}

.btn-ai-manual:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── MODAL CONTENT ────────────────────────── */
.ai-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 1rem;
}

.badge-beta {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.125rem 0.5rem;
  background: var(--muted);
  border-radius: var(--r);
  color: var(--muted-fg);
}

.ai-summary-text {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--fg);
  margin-bottom: 1rem;
}

.ai-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.ai-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 0.75rem;
  font-weight: 400;
  background: var(--muted);
  color: var(--fg);
}

.ai-section-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ai-actions-preview {
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1rem;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--fg);
  white-space: pre-wrap;
}

.processing-notice {
  padding: 1rem;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--fg);
  font-size: 0.875rem;
}

.ingest-pipeline-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  border-radius: var(--r);
  flex-wrap: wrap;
  margin-top: 1rem;
}

.pip-step {
  font-size: 0.6875rem;
  font-weight: 400;
  color: var(--muted-fg);
  text-transform: lowercase;
}

.pip-step.done {
  color: var(--fg);
  font-weight: 500;
}

.pip-step.active {
  color: var(--primary);
  font-weight: 500;
}

.pip-sep {
  color: var(--muted-fg);
  font-size: 0.75rem;
  margin: 0 0.125rem;
}

.original-block {
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1rem;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--fg);
  white-space: pre-wrap;
}

.output-loop-wrap {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.output-loop-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 1rem;
}

textarea {
  width: 100%;
  padding: 0.75rem;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  resize: vertical;
  min-height: 5rem;
  outline: none;
  transition: border-color 0.2s;
  margin-bottom: 1rem;
}

textarea:focus {
  border-color: var(--primary);
}

/* ── FORM ELEMENTS ────────────────────────── */
.type-selector,
.direction-selector {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.type-btn,
.dir-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.875rem;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted-fg);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.type-btn:hover,
.dir-btn:hover {
  border-color: var(--primary);
  color: var(--fg);
  background: var(--muted);
}

.type-btn.active,
.dir-btn.active {
  border-color: var(--primary);
  color: var(--fg);
  background: var(--muted);
  font-weight: 600;
}

.picker-card-name {
  font-size: 0.9375rem;
  font-weight: 400;
  color: var(--fg);
}

.attachment-card {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: 0.5rem;
}

.attachment-card-info {
  flex: 1;
}

.attachment-card-name {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--fg);
}

.attachment-card-meta {
  font-size: 0.75rem;
  color: var(--muted-fg);
  margin-top: 0.125rem;
}

/* ── INPUT BAR ────────────────────────────── */
.input-bar {
  height: 3.75rem;
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.5rem;
  flex-shrink: 0;
}

.input-wrapper {
  flex: 1;
}

.input-wrapper input,
#quickInput {
  width: 100%;
  height: 2.5rem;
  padding: 0.5rem 1rem;
  background: var(--muted);
  border: none;
  border-radius: var(--r-lg);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  color: var(--fg);
  outline: none;
  transition: all 0.2s;
}

.input-wrapper input:focus,
#quickInput:focus {
  background: var(--bg);
  box-shadow: 0 0 0 2px var(--border);
}

.input-wrapper input::placeholder,
#quickInput::placeholder {
  color: var(--muted-fg);
}

.btn-send {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-fg);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.btn-send:hover {
  opacity: 0.9;
  transform: scale(1.05);
}

/* ── KNOWLEDGE PANEL ──────────────────────── */
.knowledge-panel {
  width: 22rem;
  background: var(--bg);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.kp-header {
  height: var(--topbar-h);
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.kp-title {
  flex: 1;
  font-size: 0.9375rem;
  font-weight: 400;
  color: var(--fg);
}

.kp-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 1.25rem;
}

.kp-section {
  margin-bottom: 2rem;
}

.kp-section-title {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-fg);
  margin-bottom: 0.875rem;
}

.kp-action-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.875rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: 0.625rem;
  font-size: 0.8125rem;
  color: var(--fg);
  line-height: 1.5;
  cursor: pointer;
  transition: all 0.2s;
}

.kp-action-item:hover {
  border-color: var(--primary);
  background: var(--muted);
}

.kp-action-title {
  font-weight: 500;
  color: var(--fg);
}

.kp-action-source {
  font-size: 0.75rem;
  color: var(--muted-fg);
}

.kp-signal {
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
  line-height: 1.5;
  background: var(--muted);
  color: var(--fg);
}

.kp-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.kp-tag {
  padding: 0.25rem 0.625rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 0.6875rem;
  font-weight: 400;
  color: var(--fg);
}

.kp-mem-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0;
  border-bottom: 1px solid var(--border);
}

.kp-mem-row:last-child {
  border-bottom: none;
}

.kp-mem-n {
  font-size: 1.125rem;
  font-weight: 800;
  color: var(--fg);
  min-width: 1.75rem;
  text-align: right;
}

.kp-mem-label {
  font-size: 0.75rem;
  color: var(--muted-fg);
}

/* ── NEW COMMUNICATION SCREEN ─────────────── */
.new-comm-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.new-comm-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 48rem;
  width: 100%;
  margin: 0 auto;
  padding: 0;
  overflow: hidden;
}

.new-comm-header {
  padding: 2rem 2rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.new-comm-title {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 300;
  color: var(--fg);
  margin: 0;
}

.new-comm-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2rem;
  -webkit-overflow-scrolling: touch;
}

.new-comm-form {
  max-width: 100%;
}

.new-comm-footer {
  padding: 1.5rem 2rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  flex-shrink: 0;
}

/* ── RESPONSIVE ───────────────────────────── */
@media (max-width: 1024px) {
  .picker-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .picker-center {
    max-width: 85%;
  }
  .picker-search-wrap {
    width: 50%;
  }
}

@media (max-width: 768px) {
  .picker-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .picker-center {
    max-width: 90%;
  }
  .picker-search-wrap {
    width: 70%;
  }
  .modal-event {
    width: 95%;
  }
}

@media (max-width: 680px) {
  .picker-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .picker-label {
    font-size: 1.375rem;
  }
  .picker-center {
    max-width: 95%;
  }
  .picker-search-wrap {
    width: 100%;
  }
  .knowledge-panel {
    display: none !important;
  }
  .modal {
    width: 95%;
    padding: 1.5rem;
  }
}

/* ── TOAST ────────────────────────────────── */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 1rem 1.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 0.875rem;
  color: var(--fg);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 200;
  animation: tIn 0.3s ease;
}

@keyframes tIn {
  from {
    opacity: 0;
    transform: translate(-50%, -40%);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

/* ── CHAT ENTRE GESTORES ──────────────────── */
.chat-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.chat-window {
  width: 100%;
  max-width: 600px;
  height: 80vh;
  max-height: 700px;
  background: var(--bg);
  border-radius: var(--r-lg);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--muted);
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.chat-header-left i {
  font-size: 1.25rem;
  color: var(--primary);
}

.chat-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--fg);
}

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.chat-message {
  display: flex;
  flex-direction: column;
  max-width: 75%;
  animation: messageIn 0.2s ease;
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-message.own {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-message.other {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-message-sender {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted-fg);
  margin-bottom: 0.25rem;
  padding: 0 0.5rem;
}

.chat-message-bubble {
  padding: 0.75rem 1rem;
  border-radius: var(--r-lg);
  font-size: 0.875rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.chat-message.own .chat-message-bubble {
  background: var(--primary);
  color: var(--primary-fg);
  border-bottom-right-radius: 0.25rem;
}

.chat-message.other .chat-message-bubble {
  background: var(--muted);
  color: var(--fg);
  border: 1px solid var(--border);
  border-bottom-left-radius: 0.25rem;
}

.chat-message-time {
  font-size: 0.6875rem;
  color: var(--muted-fg);
  margin-top: 0.25rem;
  padding: 0 0.5rem;
}

.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.chat-input-bar input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--r);
  font-size: 0.875rem;
  font-family: var(--font-sans);
  color: var(--fg);
  background: var(--bg);
  outline: none;
  transition: border-color 0.2s;
}

.chat-input-bar input:focus {
  border-color: var(--primary);
}

.btn-send-chat {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-fg);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.2s;
  flex-shrink: 0;
}

.btn-send-chat:hover {
  opacity: 0.8;
}

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted-fg);
  font-size: 0.875rem;
  gap: 0.5rem;
}

.chat-empty i {
  font-size: 3rem;
  opacity: 0.3;
}

/* ══════════════════════════════════════════════
   CONFIGURACIÓN MODAL
══════════════════════════════════════════════ */
.modal-config {
  max-width: 58rem;
  width: 95%;
}

.config-layout {
  display: flex;
  gap: 0;
  min-height: 26rem;
}

/* Nav lateral */
.config-nav {
  width: 11rem;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.config-nav-btn {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.875rem;
  background: transparent;
  border: none;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--muted-fg);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  border-radius: var(--r);
  margin: 0 0.375rem;
  width: calc(100% - 0.75rem);
}

.config-nav-btn:hover {
  background: var(--muted);
  color: var(--fg);
}

.config-nav-btn.active {
  background: var(--muted);
  color: var(--fg);
  font-weight: 600;
}

.config-nav-btn i {
  width: 1rem;
  text-align: center;
  flex-shrink: 0;
}

/* Área de contenido */
.config-content {
  flex: 1;
  padding: 1.75rem 2rem;
  overflow-y: auto;
  max-height: 34rem;
}

.config-section {
  display: none;
}

.config-section.active {
  display: block;
}

.config-section h4 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  padding-bottom: 0.875rem;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
}

/* Tablas de usuarios / clientes */
.users-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1rem;
}

.users-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.users-table thead {
  background: var(--muted);
  border-bottom: 1px solid var(--border);
}

.users-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}

.users-table tbody tr:hover {
  background: var(--muted);
}

.users-table tbody tr:last-child {
  border-bottom: none;
}

.users-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--muted-fg);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.users-table td {
  padding: 0.875rem 1rem;
  vertical-align: middle;
  color: var(--fg);
}

/* ── TARJETAS DE INTEGRACIÓN ─────────────── */
.integration-card {
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: 1rem;
  overflow: hidden;
  transition: border-color 0.15s;
}

.integration-card:hover {
  border-color: var(--fg);
}

.int-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--muted);
  border-bottom: 1px solid var(--border);
}

.int-icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--r);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1rem;
  flex-shrink: 0;
}

.int-info {
  flex: 1;
  min-width: 0;
}

.int-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 0.125rem;
}

.int-desc {
  font-size: 0.75rem;
  color: var(--muted-fg);
}

.int-status {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

.int-status-ok      { background: #d1fae5; color: #065f46; }
.int-status-warning { background: #fef3c7; color: #92400e; }
.int-status-disabled{ background: var(--muted); color: var(--muted-fg); border: 1px solid var(--border); }

.int-body {
  padding: 1.25rem;
}

.int-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.75rem;
}

.int-last-check {
  font-size: 0.75rem;
  color: var(--muted-fg);
}

.input-secret {
  display: flex;
  gap: 0.5rem;
}

.input-secret input {
  flex: 1;
}

.btn-eye {
  padding: 0 0.75rem;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--muted-fg);
  cursor: pointer;
  font-size: 0.875rem;
  transition: background 0.15s;
}

.btn-eye:hover {
  background: var(--border);
}

/* ── IA GUARDIAN ─────────────────────────── */
.guardian-status {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: 1.5rem;
}

.gs-icon {
  font-size: 1.5rem;
  color: var(--muted-fg);
  flex-shrink: 0;
}

.gs-info {
  flex: 1;
}

.gs-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--fg);
}

.gs-subtitle {
  font-size: 0.8125rem;
  color: var(--muted-fg);
  margin-top: 0.125rem;
}

.gs-badge {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.375rem 0.875rem;
  border-radius: 999px;
  flex-shrink: 0;
}

.gs-badge-ok   { background: #d1fae5; color: #065f46; }
.gs-badge-warn { background: #fef3c7; color: #92400e; }

.guardian-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.gm-card {
  padding: 1rem;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--r);
  text-align: center;
}

.gm-label {
  font-size: 0.6875rem;
  color: var(--muted-fg);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}

.gm-value {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--fg);
}

.gm-warning { color: #d97706; }
.gm-success { color: #059669; }

.guardian-logs {
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}

.gl-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--muted);
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem;
  font-weight: 600;
}

.gl-body {
  max-height: 14rem;
  overflow-y: auto;
}

.gl-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.8125rem;
}

.gl-item:last-child { border-bottom: none; }

.gl-item i { flex-shrink: 0; margin-top: 0.125rem; }
.gl-success i { color: #059669; }
.gl-info    i { color: #3b82f6; }
.gl-warning i { color: #d97706; }

.gl-content { flex: 1; }
.gl-msg  { color: var(--fg); line-height: 1.4; }
.gl-time { font-size: 0.75rem; color: var(--muted-fg); margin-top: 0.25rem; }

/* ── REVISADO: estado visual en card y botón ─ */
.ev-reviewed {
  opacity: 0.65;
}

.flag-reviewed {
  font-size: 0.75rem;
  font-weight: 700;
  color: #059669;
  line-height: 1;
}

.btn-reviewed {
  background: #d1fae5 !important;
  color: #065f46 !important;
  border-color: #a7f3d0 !important;
  cursor: default;
}

/* Responsive configuración */
@media (max-width: 680px) {
  .config-layout { flex-direction: column; }
  .config-nav {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    overflow-x: auto;
    padding: 0.5rem;
  }
  .config-nav-btn { white-space: nowrap; width: auto; }
  .guardian-metrics { grid-template-columns: repeat(2, 1fr); }
}
