/* =====================================================
   SHEYLA AGENCY — styles.css  (Light Mode Corporativo)
   Paleta basada en el logo "Sheyla software"
   ===================================================== */

:root{
  /* Azules corporativos del logo */
  --blue-electric: #00AEEF;   /* Cian / azul eléctrico — destacados */
  --blue-electric-2:#29ABE2;
  --blue-primary:  #1C7ED6;   /* azul principal botones */
  --blue-soft:     #5B9BD5;   /* azul secundario / textos */
  --blue-deep:     #0F4C81;   /* azul oscuro corporativo (títulos) */
  --blue-ink:      #0A2E50;

  /* Superficies */
  --bg:        #FFFFFF;
  --surface:   #F8FAFC;
  --surface-2: #F1F5F9;
  --border:    #E2E8F0;
  --border-2:  #CBD7E6;

  /* Texto */
  --text:      #1E293B;
  --text-soft: #64748B;
  --text-mute: #94A3B8;

  /* Estados */
  --amber:     #F59E0B;
  --amber-bg:  #FEF3E2;
  --sleep:     #94A3B8;
  --sleep-bg:  #F1F5F9;
  --working-bg:#E2F6FE;
  --danger:    #E03131;

  /* Translúcidos azules */
  --blue-glass: rgba(0,174,239,.08);
  --blue-glass-2: rgba(0,174,239,.14);

  --shadow-sm: 0 1px 2px rgba(15,76,129,.05);
  --shadow:    0 4px 16px rgba(15,76,129,.07);
  --shadow-lg: 0 12px 32px rgba(15,76,129,.10);
  --radius:    16px;
  --radius-sm: 10px;
}

*{ box-sizing:border-box; margin:0; padding:0; }
html,body{ height:100%; }
body{
  font-family:'Inter',system-ui,-apple-system,Segoe UI,Roboto,sans-serif;
  background:var(--bg);
  color:var(--text);
  -webkit-font-smoothing:antialiased;
  overflow:hidden;
}
::-webkit-scrollbar{ width:8px; height:8px; }
::-webkit-scrollbar-thumb{ background:var(--border-2); border-radius:8px; }
::-webkit-scrollbar-track{ background:transparent; }

.app{
  --sidebar-w:230px;
  --roster-w:300px;
  display:grid;
  grid-template-columns:var(--sidebar-w) 1fr;
  height:100vh;
  width:100vw;
  transition:grid-template-columns .28s cubic-bezier(.4,0,.2,1);
}
/* Menú oculto */
.app.sidebar-collapsed{ --sidebar-w:0px; }
.app.sidebar-collapsed .sidebar{
  transform:translateX(-100%);
  opacity:0;
  pointer-events:none;
}

/* ============ SIDEBAR ============ */
.sidebar{
  background:linear-gradient(180deg,#F4F9FE 0%,#EEF4FB 100%);
  border-right:1px solid var(--border);
  display:flex;
  flex-direction:column;
  padding:22px 16px;
  gap:26px;
  overflow:hidden;
  transition:transform .28s cubic-bezier(.4,0,.2,1), opacity .2s ease;
}
.sidebar__logo{
  background:var(--bg);
  border:1px solid var(--border);
  border-radius:var(--radius-sm);
  padding:14px 12px;
  box-shadow:var(--shadow-sm);
  display:flex; align-items:center; justify-content:center;
}
.sidebar__logo img{ max-width:100%; height:34px; object-fit:contain; }

.sidebar__nav{ display:flex; flex-direction:column; gap:6px; }
.nav-btn{
  display:flex; align-items:center; gap:12px;
  padding:11px 13px;
  border:1px solid transparent;
  border-radius:var(--radius-sm);
  background:transparent;
  color:var(--text-soft);
  font:inherit; font-size:14px; font-weight:600;
  cursor:pointer;
  transition:all .18s ease;
}
.nav-btn svg{ width:19px; height:19px; fill:currentColor; flex-shrink:0; }
.nav-btn:hover{ background:var(--bg); color:var(--blue-primary); }
.nav-btn.is-active{
  background:var(--bg);
  color:var(--blue-deep);
  border-color:var(--border);
  box-shadow:var(--shadow-sm);
}
.nav-btn.is-active svg{ fill:var(--blue-electric); }

.sidebar__footer{
  margin-top:auto;
  display:flex; align-items:center; gap:9px;
  font-size:12px; color:var(--text-mute); font-weight:500;
  padding:10px 6px;
}
.online-dot{
  width:9px; height:9px; border-radius:50%;
  background:#22C55E;
  box-shadow:0 0 0 3px rgba(34,197,94,.18);
}

/* ============ MAIN ============ */
.main{ display:flex; flex-direction:column; overflow:hidden; background:var(--bg); }

.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding:18px 26px;
  border-bottom:1px solid var(--border);
}
.topbar__title{ display:flex; align-items:center; gap:14px; min-width:0; }
.icon-btn{
  width:40px; height:40px; flex-shrink:0;
  border:1px solid var(--border);
  background:var(--surface);
  border-radius:11px;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer;
  transition:all .16s ease;
}
.icon-btn svg{ width:20px; height:20px; fill:var(--blue-deep); }
.icon-btn:hover{ background:var(--working-bg); border-color:var(--blue-electric); }
.icon-btn:active{ transform:scale(.94); }

.sidebar-backdrop{
  display:none;
  position:fixed; inset:0; z-index:40;
  background:rgba(15,76,129,.28);
  backdrop-filter:blur(2px);
  opacity:0; transition:opacity .25s ease;
}
.sidebar-backdrop.show{ display:block; opacity:1; }

.topbar__title h1{
  font-size:19px; font-weight:800; color:var(--blue-deep); letter-spacing:-.2px;
  white-space:nowrap;
}
.topbar__title h1 span{ color:var(--text-mute); font-weight:600; }
.topbar__title p{ font-size:12.5px; color:var(--text-soft); margin-top:2px; }
.topbar__meta{ display:flex; align-items:center; gap:14px; }
.pill{
  display:flex; align-items:center; gap:7px;
  background:var(--working-bg); color:var(--blue-primary);
  font-size:11.5px; font-weight:700; letter-spacing:.4px;
  padding:6px 12px; border-radius:999px;
}
.pill__dot{ width:7px; height:7px; border-radius:50%; background:var(--blue-electric); }
.clock{
  font-family:'JetBrains Mono',monospace; font-size:13px;
  color:var(--text-soft); font-weight:500;
  background:var(--surface); padding:7px 12px; border-radius:8px; border:1px solid var(--border);
}

/* ============ GRID ============ */
.grid{
  flex:1;
  display:grid;
  grid-template-columns:var(--roster-w) 1fr 340px;
  gap:18px;
  padding:18px 22px 22px;
  overflow:hidden;
}
.app.is-resizing{ user-select:none; cursor:col-resize; }
.app.is-resizing *{ pointer-events:none; }

.panel{
  background:var(--bg);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  display:flex; flex-direction:column;
  overflow:hidden;
}
.panel__head{
  display:flex; align-items:center; justify-content:space-between;
  padding:16px 18px 12px;
}
.panel__head h2{
  font-size:13px; font-weight:800; letter-spacing:.6px;
  color:var(--blue-deep); text-transform:uppercase;
}
.panel__sub{ font-size:11px; color:var(--text-mute); font-weight:600; }

/* ============ ROSTER ============ */
.roster{ position:relative; }
.roster-resize{
  position:absolute; top:0; right:-3px; bottom:0;
  width:8px; cursor:col-resize; z-index:5;
  display:flex; align-items:center; justify-content:center;
}
.roster-resize::after{
  content:''; width:3px; height:46px; border-radius:3px;
  background:var(--border-2); transition:background .15s, height .15s;
}
.roster-resize:hover::after,
.app.is-resizing .roster-resize::after{ background:var(--blue-electric); height:70px; }

.roster__list{
  padding:6px 12px 14px;
  display:flex; flex-direction:column; gap:8px;
  overflow-y:auto;
}
.agent-row{
  display:flex; align-items:center; gap:12px;
  padding:12px 12px;
  border:1px solid var(--border);
  border-radius:var(--radius-sm);
  background:var(--bg);
  cursor:pointer;
  transition:all .16s ease;
  position:relative;
}
.agent-row:hover{ border-color:var(--border-2); box-shadow:var(--shadow-sm); }
.agent-row.is-selected{
  background:var(--blue-glass);
  border-color:var(--blue-electric);
  box-shadow:0 0 0 1px var(--blue-electric-2) inset, var(--shadow-sm);
}
.agent-row.is-locked{ cursor:default; }
.agent-row.is-locked:hover{ box-shadow:none; border-color:var(--border); }

.agent-row__avatar{
  width:38px; height:38px; flex-shrink:0;
  border-radius:10px;
  display:flex; align-items:center; justify-content:center;
  font-weight:800; font-size:13px; color:#fff;
  background:linear-gradient(135deg,var(--blue-soft),var(--blue-primary));
}
.agent-row.state-sleeping .agent-row__avatar{
  background:linear-gradient(135deg,#CBD5E1,#94A3B8);
}
.agent-row.state-idle .agent-row__avatar{
  background:linear-gradient(135deg,#FBBF77,#F59E0B);
}
.agent-row.state-working .agent-row__avatar{
  background:linear-gradient(135deg,var(--blue-electric),var(--blue-primary));
}

.agent-row__info{ flex:1; min-width:0; }
.agent-row__name{
  font-size:13px; font-weight:700; color:var(--text);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.agent-row__role{ font-size:11px; color:var(--text-mute); font-weight:500; }

.agent-row__state{
  display:flex; align-items:center; gap:6px;
  font-size:10px; font-weight:800; letter-spacing:.4px;
  padding:5px 9px; border-radius:999px;
  white-space:nowrap;
}
.status-led{
  width:7px; height:7px; border-radius:50%; flex-shrink:0;
}
.status-led.working{ background:var(--blue-electric); box-shadow:0 0 0 0 var(--blue-electric); animation:pulse 1.6s infinite; }
.status-led.idle{ background:var(--amber); }
.status-led.sleeping{ background:var(--sleep); }

.state-working  .agent-row__state{ background:var(--working-bg); color:var(--blue-primary); }
.state-idle     .agent-row__state{ background:var(--amber-bg);  color:#B45309; }
.state-sleeping .agent-row__state{ background:var(--sleep-bg);  color:var(--sleep); }

.lock-ic{ position:absolute; top:9px; right:10px; font-size:10px; color:var(--text-mute); opacity:.5; }

@keyframes pulse{
  0%{ box-shadow:0 0 0 0 rgba(0,174,239,.5); }
  70%{ box-shadow:0 0 0 7px rgba(0,174,239,0); }
  100%{ box-shadow:0 0 0 0 rgba(0,174,239,0); }
}

/* ============ CHAT ============ */
.chat{ overflow:hidden; }
.chat__head{
  padding:16px 20px;
  border-bottom:1px solid var(--border);
  background:linear-gradient(180deg,var(--surface),#fff);
}
.chat__head-left{ display:flex; align-items:center; gap:13px; }
.chat__avatar{
  width:44px; height:44px; border-radius:12px;
  display:flex; align-items:center; justify-content:center;
  font-weight:800; color:#fff; font-size:15px;
  background:linear-gradient(135deg,var(--blue-electric),var(--blue-primary));
  box-shadow:var(--shadow-sm);
}
.chat__head h2{ font-size:15px; font-weight:800; color:var(--blue-deep); letter-spacing:-.2px; }
.chat__head p{ font-size:12px; color:var(--text-soft); margin-top:3px; display:flex; align-items:center; gap:7px; }

.chat__body{
  flex:1; overflow-y:auto;
  padding:20px;
  display:flex; flex-direction:column; gap:14px;
  background:
    radial-gradient(circle at 100% 0,var(--blue-glass) 0,transparent 38%),
    var(--bg);
}
.msg{ display:flex; max-width:78%; animation:rise .3s ease; }
.msg__bubble{
  padding:11px 15px; border-radius:14px;
  font-size:13.5px; line-height:1.5;
}
.msg__bubble small{ display:block; font-size:10px; font-weight:700; letter-spacing:.4px; margin-bottom:4px; opacity:.7; }

.msg.agent{ align-self:flex-start; }
.msg.agent .msg__bubble{
  background:var(--blue-glass);
  border:1px solid var(--blue-glass-2);
  color:var(--blue-ink);
  border-bottom-left-radius:5px;
}
.msg.agent .msg__bubble small{ color:var(--blue-primary); }

.msg.user{ align-self:flex-end; }
.msg.user .msg__bubble{
  background:var(--bg);
  border:1px solid var(--border-2);
  color:var(--text);
  border-bottom-right-radius:5px;
  box-shadow:var(--shadow-sm);
}
.msg.error .msg__bubble{
  background:#FEF2F2; border:1px solid #FCC; color:var(--danger);
}

/* Imagen precargada dentro del chat (SHEYLA DESIGN) */
.msg__img-link{ display:block; margin-top:8px; }
.msg__img{
  display:block; width:100%; max-width:280px; height:auto;
  border-radius:10px;
  border:1px solid var(--border-2);
  box-shadow:var(--shadow-sm);
  cursor:zoom-in;
  transition:transform .15s ease, box-shadow .15s ease;
}
.msg__img:hover{ transform:scale(1.015); box-shadow:var(--shadow); }

@keyframes rise{ from{ opacity:0; transform:translateY(8px);} to{ opacity:1; transform:none; } }

.chat__typing{
  display:flex; align-items:center; gap:8px;
  padding:6px 22px 4px;
  color:var(--blue-electric); font-size:12px; font-style:italic;
}
.chat__typing .dot{
  width:7px; height:7px; border-radius:50%; background:var(--blue-electric);
  animation:bounce 1.2s infinite;
}
.chat__typing .dot:nth-child(2){ animation-delay:.18s; }
.chat__typing .dot:nth-child(3){ animation-delay:.36s; }
.chat__typing em{ color:var(--blue-soft); font-style:italic; margin-left:4px; }
@keyframes bounce{ 0%,60%,100%{ transform:translateY(0); opacity:.5;} 30%{ transform:translateY(-5px); opacity:1; } }

.chat__input{
  display:flex; gap:10px; align-items:flex-end;
  padding:14px 18px 18px;
  border-top:1px solid var(--border);
  background:var(--bg);
}
.chat__input textarea{
  flex:1; resize:none;
  font:inherit; font-size:13.5px;
  padding:12px 15px;
  border:1px solid var(--border-2);
  border-radius:14px;
  background:var(--surface);
  color:var(--text);
  max-height:120px;
  transition:border .15s, box-shadow .15s;
}
.chat__input textarea:focus{
  outline:none;
  border-color:var(--blue-electric);
  background:#fff;
  box-shadow:0 0 0 3px var(--blue-glass);
}
.send-btn{
  width:44px; height:44px; flex-shrink:0;
  border:none; border-radius:13px;
  background:linear-gradient(135deg,var(--blue-electric),var(--blue-primary));
  cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  box-shadow:0 4px 12px rgba(0,174,239,.3);
  transition:transform .12s, box-shadow .12s, opacity .12s;
}
.send-btn svg{ width:20px; height:20px; fill:#fff; }
.send-btn:hover{ transform:translateY(-1px); box-shadow:0 6px 16px rgba(0,174,239,.4); }
.send-btn:active{ transform:translateY(0); }
.send-btn:disabled{ opacity:.5; cursor:not-allowed; transform:none; }

/* ============ RIGHT COLUMN ============ */
.rightcol{
  display:flex; flex-direction:column; gap:18px;
  overflow-y:auto; padding-right:2px;
}
.viz{ flex-shrink:0; }

/* Workflow */
.workflow{ padding:8px 18px 20px; display:flex; flex-direction:column; align-items:center; gap:4px; }
.wf-node{
  width:100%;
  border:1px solid var(--border);
  border-radius:12px;
  padding:11px 14px;
  background:var(--surface);
  text-align:center;
  position:relative;
}
.wf-node strong{ display:block; font-size:12px; font-weight:800; color:var(--blue-deep); letter-spacing:.4px; }
.wf-node em{ font-size:10.5px; color:var(--text-mute); font-style:normal; }
.wf-ic{
  position:absolute; left:12px; top:50%; transform:translateY(-50%);
  width:26px; height:26px; border-radius:8px;
  display:flex; align-items:center; justify-content:center;
  font-size:13px; color:#fff;
  background:linear-gradient(135deg,var(--blue-soft),var(--blue-primary));
}
.wf-node--director{ border-color:var(--blue-electric); background:var(--working-bg); }
.wf-node--director .wf-ic{ background:linear-gradient(135deg,var(--blue-electric),var(--blue-primary)); }
.wf-node--active{ border-color:var(--blue-glass-2); }
.wf-node--active .wf-ic{ background:linear-gradient(135deg,var(--blue-electric-2),var(--blue-primary)); }

.wf-arrow{ height:26px; display:flex; align-items:center; justify-content:center; }
.wf-arrow span{
  width:2px; height:100%;
  background:linear-gradient(180deg,var(--blue-electric),var(--blue-soft));
  position:relative;
}
.wf-arrow span::after{
  content:''; position:absolute; bottom:-2px; left:50%; transform:translateX(-50%);
  border-left:5px solid transparent; border-right:5px solid transparent;
  border-top:7px solid var(--blue-soft);
}
.wf-branch{ display:grid; grid-template-columns:1fr 1fr; gap:12px; width:100%; position:relative; }
.wf-branch::before{
  content:''; position:absolute; top:-15px; left:25%; right:25%; height:2px;
  background:var(--blue-soft);
}
.wf-branch .wf-node{ padding-left:42px; text-align:left; }
.wf-branch .wf-node::before{
  content:''; position:absolute; top:-15px; left:50%; width:2px; height:15px;
  background:var(--blue-soft); transform:translateX(-50%);
}

/* Metrics */
.metrics{ padding:6px 18px 20px; display:flex; flex-direction:column; gap:22px; }
.metric__label{ display:flex; justify-content:space-between; font-size:12px; color:var(--text-soft); font-weight:600; margin-bottom:9px; }
.metric__label b{ color:var(--blue-deep); font-weight:800; }
.metric__label--center{ justify-content:center; margin-top:10px; margin-bottom:0; }
.seg-bar{ display:flex; gap:4px; }
.seg-bar i{
  flex:1; height:9px; border-radius:3px; background:var(--surface-2);
  transition:background .3s;
}
.seg-bar i.on{ background:linear-gradient(90deg,var(--blue-electric),var(--blue-primary)); }

.metric--arc{ display:flex; flex-direction:column; align-items:center; }
.arc{
  width:130px; height:130px; border-radius:50%;
  background:conic-gradient(var(--blue-electric) calc(var(--pct)*1%),var(--surface-2) 0);
  display:flex; align-items:center; justify-content:center;
  transition:background .6s ease;
}
.arc__hole{
  width:96px; height:96px; border-radius:50%; background:#fff;
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  box-shadow:inset 0 0 0 1px var(--border);
}
.arc__hole b{ font-size:24px; font-weight:800; color:var(--blue-deep); }
.arc__hole small{ font-size:10px; color:var(--text-mute); font-weight:600; }

/* Logs */
.logs{ flex:1; min-height:160px; }
.console{
  margin:0 14px 14px; flex:1;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:10px;
  padding:12px 14px;
  font-family:'JetBrains Mono',monospace;
  font-size:11px; line-height:1.7;
  color:var(--text-soft);
  overflow-y:auto;
}
.console .line{ display:flex; gap:8px; animation:rise .25s ease; }
.console .ts{ color:var(--blue-electric); flex-shrink:0; }
.console .ok{ color:#16A34A; }
.console .warn{ color:var(--amber); }

/* ============ TOAST ============ */
.toast-container{
  position:fixed; top:18px; right:18px; z-index:9999;
  display:flex; flex-direction:column; gap:10px;
}
.toast{
  display:flex; align-items:center; gap:12px;
  background:#fff;
  border:1px solid var(--border);
  border-left:4px solid var(--blue-electric);
  border-radius:12px;
  padding:13px 16px;
  box-shadow:var(--shadow-lg);
  min-width:280px; max-width:340px;
  animation:toastIn .35s cubic-bezier(.2,.9,.3,1.2);
}
.toast.out{ animation:toastOut .3s ease forwards; }
.toast__ic{
  width:30px; height:30px; border-radius:8px; flex-shrink:0;
  display:flex; align-items:center; justify-content:center;
  background:var(--working-bg); color:var(--blue-primary); font-size:15px;
}
.toast__txt strong{ display:block; font-size:13px; color:var(--blue-deep); font-weight:700; }
.toast__txt span{ font-size:12px; color:var(--text-soft); }
@keyframes toastIn{ from{ opacity:0; transform:translateX(40px); } to{ opacity:1; transform:none; } }
@keyframes toastOut{ to{ opacity:0; transform:translateX(40px); } }

/* ============ RESPONSIVE ============ */

/* --- Pantallas grandes: la columna derecha se apila bajo el chat --- */
@media (max-width:1280px){
  .grid{
    grid-template-columns:var(--roster-w) 1fr;
    grid-template-rows:1fr auto;
  }
  .roster{ grid-row:1 / span 2; }
  .rightcol{
    grid-column:2; grid-row:2;
    flex-direction:row; flex-wrap:wrap;
    overflow:visible;
    max-height:none;
  }
  .rightcol .viz{ flex:1 1 240px; }
  .rightcol .logs{ flex:1 1 100%; min-height:140px; }
}

/* --- Tablets: el roster pasa a ancho fijo cómodo --- */
@media (max-width:1024px){
  .grid{ grid-template-columns:minmax(240px,var(--roster-w)) 1fr; }
}

/* --- Tablet / móvil grande: el menú se vuelve cajón flotante --- */
@media (max-width:860px){
  body{ overflow:auto; }
  .app{ grid-template-columns:1fr; height:auto; min-height:100vh; }
  .sidebar{
    position:fixed; top:0; left:0; bottom:0; z-index:50;
    width:230px;
    box-shadow:var(--shadow-lg);
  }
  /* En móvil el menú arranca oculto y se muestra con el botón */
  .app .sidebar{ transform:translateX(-100%); opacity:0; pointer-events:none; }
  .app.sidebar-open .sidebar{ transform:none; opacity:1; pointer-events:auto; }

  .main{ overflow:visible; }
  .topbar{ position:sticky; top:0; z-index:30; background:#fff; }
  .grid{
    grid-template-columns:1fr;
    grid-template-rows:none;
    overflow:visible;
    height:auto;
  }
  .roster, .panel.chat{ grid-row:auto; grid-column:auto; }
  .roster__list{ max-height:340px; }
  .roster-resize{ display:none; }            /* sin redimensionado táctil manual */
  .panel.chat{ min-height:60vh; }
  .rightcol{ grid-column:auto; grid-row:auto; }
}

/* --- Móvil: todo en una columna, tipografías y paddings compactos --- */
@media (max-width:560px){
  .topbar{ padding:14px 16px; flex-wrap:wrap; gap:10px; }
  .topbar__title h1{ font-size:16px; }
  .topbar__title h1 span{ display:none; }
  .topbar__meta .clock{ display:none; }
  .grid{ padding:14px; gap:14px; }
  .rightcol{ flex-direction:column; }
  .rightcol .viz{ flex:1 1 100%; }
  .msg{ max-width:88%; }
  .chat__head h2{ font-size:13.5px; }
  .arc{ width:120px; height:120px; }
}

/* --- Accesibilidad: respeta reduce-motion --- */
@media (prefers-reduced-motion:reduce){
  *{ animation:none !important; transition:none !important; }
}
