:root{
  --bg:#f4f5f7;
  --card:#ffffff;
  --muted:#6b7280;
  --accent:#D9B300;
  --accent-dark:#b89500;
  --accent-faint:rgba(217,179,0,0.10);
  --radius:14px;
  --max-width:1400px;
  --sidebar-width:280px;
}

*{box-sizing:border-box}
html,body{margin:0;padding:0;height:100%;overflow:hidden}

body{
  font-family:Inter, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
  background:var(--bg);
  color:#111827;
  display:flex;
  justify-content:center;
  padding:0;
  height:100%;
  overflow:hidden;
}

.container{
  width:100%;
  max-width:var(--max-width);
  background:linear-gradient(180deg, rgba(255,255,255,0.97), rgba(250,250,251,0.97));
  border-radius:18px;
  box-shadow:0 10px 30px rgba(2,6,23,0.12);
  overflow:hidden;
  display:flex;
  flex-direction:column;
  height:100%;
  overflow-y:auto;
}

/* ── HEADER ── */
header.header{
  padding:12px 28px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  background:linear-gradient(90deg,var(--accent-dark), var(--accent) 60%);
  color:#111827;
  flex-shrink:0;
  z-index:10;
}

.brand{display:flex;align-items:center;gap:14px}

.logo-favicon{
  width:48px; height:48px;
  background:rgba(255,255,255,0.22);
  border-radius:10px;
  display:flex; align-items:center; justify-content:center;
  overflow:hidden; flex-shrink:0;
}
.logo-favicon img{width:36px;height:36px;object-fit:contain}
.meta{font-size:13px;color:rgba(0,0,0,0.75);text-align:right}

/* ── LAYOUT PRINCIPAL ── */
.main-layout{
  display:flex;
  flex:1;
  min-height:0;
  overflow:hidden;
  transition:all .3s ease;
}

/* ── SIDEBAR ── */
.sidebar{
  width:var(--sidebar-width);
  background:#fff;
  border-right:1px solid rgba(15,23,42,0.07);
  display:flex;
  flex-direction:column;
  flex-shrink:0;
  transition:width .3s cubic-bezier(.4,0,.2,1);
  overflow:hidden;
  position:relative;
  z-index:5;
  height:100%;
}

.sidebar.collapsed{
  width:48px;
  border-right:1px solid rgba(15,23,42,0.07);
}

/* Rail: hide text content when collapsed */
.sidebar.collapsed .sidebar-footer-note,
.sidebar.collapsed .category-nav{
  opacity:0;
  pointer-events:none;
}

/* Expand tab on collapsed sidebar — now replaced by header button */
.sidebar-expand-tab{
  display:none !important;
}

.sidebar-header{
  padding:16px 16px 12px;
  display:flex;
  align-items:center;
  gap:10px;
  border-bottom:1px solid rgba(15,23,42,0.06);
  flex-shrink:0;
}

.sidebar-title{
  font-family:Montserrat, sans-serif;
  font-weight:700;
  font-size:13px;
  color:#111827;
  letter-spacing:0.02em;
  white-space:nowrap;
}

.sidebar-toggle-btn{
  width:28px; height:28px;
  background:transparent;
  border:1px solid rgba(15,23,42,0.08);
  border-radius:7px;
  cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  color:#6b7280;
  flex-shrink:0;
  transition:background .15s, color .15s;
}
.sidebar-toggle-btn:hover{background:var(--accent-faint);color:var(--accent-dark)}
.sidebar-toggle-btn svg{
  width:14px;height:14px;
  transition:transform .3s cubic-bezier(.4,0,.2,1);
}

/* When collapsed, flip the arrow to point right (>) */
.sidebar.collapsed .sidebar-toggle-btn svg{
  transform:rotate(180deg);
}

/* When collapsed, hide title and keep only the button centered */
.sidebar.collapsed .sidebar-header{
  justify-content:center;
  padding:10px 0;
}
.sidebar.collapsed .sidebar-title{
  display:none;
}

/* ── CATEGORY NAV ── */
.category-nav{
  flex:1;
  overflow-y:auto;
  overflow-x:hidden;
  padding:8px 0;
  scrollbar-width:thin;
  scrollbar-color:rgba(217,179,0,0.5) transparent;
  min-height:0;
}
.category-nav::-webkit-scrollbar{width:5px}
.category-nav::-webkit-scrollbar-track{background:transparent}
.category-nav::-webkit-scrollbar-thumb{background:rgba(217,179,0,0.45);border-radius:4px}
.category-nav::-webkit-scrollbar-thumb:hover{background:rgba(217,179,0,0.7)}

/* ── NAV GROUP ── */
.nav-group{
  margin-bottom:2px;
}

.nav-group-header{
  width:100%;
  background:transparent;
  border:none;
  padding:10px 16px;
  display:flex;
  align-items:center;
  gap:9px;
  cursor:pointer;
  text-align:left;
  transition:background .15s;
  border-radius:0;
}
.nav-group-header:hover{background:rgba(15,23,42,0.03)}
.nav-group.open .nav-group-header{background:var(--accent-faint)}

.nav-group-icon{
  font-size:16px;
  flex-shrink:0;
  width:22px;
  text-align:center;
}

.nav-group-label{
  flex:1;
  font-size:12.5px;
  font-weight:700;
  color:#374151;
  letter-spacing:0.01em;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.nav-group.open .nav-group-label{color:#111827}

.nav-group-count{
  font-size:10px;
  font-weight:700;
  color:#9ca3af;
  background:#f3f4f6;
  padding:2px 6px;
  border-radius:10px;
  flex-shrink:0;
  min-width:20px;
  text-align:center;
}
.nav-group.open .nav-group-count{
  background:rgba(217,179,0,0.18);
  color:var(--accent-dark);
}

.nav-group-chevron{
  width:14px; height:14px;
  color:#9ca3af;
  flex-shrink:0;
  transition:transform .25s cubic-bezier(.4,0,.2,1);
}
.nav-group.open .nav-group-chevron{
  transform:rotate(90deg);
  color:var(--accent-dark);
}

/* ── NAV GROUP LIST (acordeón) ── */
.nav-group-list{
  max-height:0;
  overflow:hidden;
  transition:max-height .3s cubic-bezier(.4,0,.2,1);
  border-top:0px solid transparent;
}
.nav-group.open .nav-group-list{
  max-height:1000px;
  border-top:1px solid rgba(15,23,42,0.05);
}

/* ── NAV ITEM ── */
.nav-item{
  width:100%;
  background:transparent;
  border:none;
  padding:9px 16px 9px 20px;
  display:flex;
  align-items:center;
  gap:10px;
  cursor:pointer;
  text-align:left;
  transition:background .15s, border-left .15s;
  border-left:3px solid transparent;
  position:relative;
}
.nav-item:hover:not(.wip){
  background:rgba(217,179,0,0.07);
  border-left-color:rgba(217,179,0,0.4);
}
.nav-item.active{
  background:var(--accent-faint);
  border-left-color:var(--accent);
}
.nav-item.wip{
  opacity:0.45;
  cursor:default;
}

.nav-item-icon{
  font-size:16px;
  flex-shrink:0;
  width:22px;
  text-align:center;
}

.nav-item-text{
  flex:1;
  display:flex;
  flex-direction:column;
  gap:2px;
  min-width:0;
}

.nav-item-name{
  font-size:12px;
  font-weight:600;
  color:#111827;
  line-height:1.3;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  display:block;
}
.nav-item.active .nav-item-name{color:var(--accent-dark)}

.nav-item-desc{
  font-size:10.5px;
  color:#9ca3af;
  line-height:1.3;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  display:block;
}

.nav-item-arrow{
  width:13px; height:13px;
  color:#d1d5db;
  flex-shrink:0;
  transition:color .15s, transform .15s;
}
.nav-item:hover:not(.wip) .nav-item-arrow{
  color:var(--accent);
  transform:translateX(2px);
}
.nav-item.active .nav-item-arrow{color:var(--accent)}

.nav-item-wip{
  font-size:9px;
  font-weight:700;
  letter-spacing:0.04em;
  text-transform:uppercase;
  color:#9ca3af;
  background:#f3f4f6;
  padding:2px 6px;
  border-radius:8px;
  flex-shrink:0;
}

/* ── SIDEBAR FOOTER ── */
.sidebar-footer{
  padding:12px 16px;
  border-top:1px solid rgba(15,23,42,0.06);
  flex-shrink:0;
}
.sidebar-footer-note{
  font-size:10px;
  color:#9ca3af;
  text-align:center;
}

/* ── CONTENT AREA ── */
.content-area{
  flex:1;
  display:flex;
  flex-direction:column;
  min-width:0;
  overflow:hidden;
}

/* ── WELCOME SCREEN ── */
.welcome-screen{
  flex:1;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:14px;
  padding:60px 40px;
  text-align:center;
  animation:fadeInUp .4s ease both;
}

@keyframes fadeInUp{
  from{opacity:0;transform:translateY(16px)}
  to{opacity:1;transform:translateY(0)}
}

.welcome-icon{
  font-size:52px;
  line-height:1;
  filter:drop-shadow(0 4px 12px rgba(217,179,0,0.3));
}

.welcome-title{
  font-family:Montserrat, sans-serif;
  font-size:22px;
  font-weight:700;
  color:#111827;
  margin:0;
}

.welcome-sub{
  font-size:14px;
  color:var(--muted);
  max-width:400px;
  margin:0;
  line-height:1.6;
}

.welcome-chips{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  justify-content:center;
  margin-top:8px;
}

.welcome-chip{
  background:#fff;
  border:1px solid rgba(15,23,42,0.08);
  color:#374151;
  font-size:12px;
  font-family:Inter, sans-serif;
  padding:8px 14px;
  border-radius:20px;
  cursor:pointer;
  transition:all .15s;
  box-shadow:0 2px 8px rgba(15,23,42,0.05);
}
.welcome-chip:hover{
  border-color:var(--accent);
  color:var(--accent-dark);
  background:var(--accent-faint);
  box-shadow:0 4px 12px rgba(217,179,0,0.15);
  transform:translateY(-1px);
}

/* ── VIEWER ── */
.viewer{
  flex:1;
  display:flex;
  flex-direction:column;
  animation:fadeInUp .3s ease both;
}

.viewer-topbar{
  padding:10px 18px;
  background:#fff;
  border-bottom:1px solid rgba(15,23,42,0.07);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-shrink:0;
}

.viewer-breadcrumb{
  display:flex;
  align-items:center;
  gap:6px;
  font-size:13px;
  flex:1;
  min-width:0;
  overflow:hidden;
  white-space:nowrap;
}
.bc-cat{color:var(--muted)}
.bc-sep{color:#d1d5db}
.bc-item{font-weight:600;color:#111827;overflow:hidden;text-overflow:ellipsis}

.viewer-actions{
  display:none;
}

/* Fullscreen button overlay on iframe */
.iframe-fullscreen-btn{
  position:absolute;
  top:10px;
  right:14px;
  z-index:10;
  width:32px; height:32px;
  background:rgba(255,255,255,0.92);
  border:1px solid rgba(15,23,42,0.12);
  border-radius:8px;
  cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  color:#374151;
  box-shadow:0 2px 8px rgba(15,23,42,0.1);
  transition:background .15s, color .15s, box-shadow .15s;
}
.iframe-fullscreen-btn:hover{
  background:#fff;
  color:var(--accent-dark);
  box-shadow:0 4px 14px rgba(217,179,0,0.25);
  border-color:rgba(217,179,0,0.4);
}
.iframe-fullscreen-btn svg{width:15px;height:15px}

.viewer-action-btn{
  display:none;
}

iframe{
  width:100%;
  height:calc(100vh - 112px);
  border:0;
  display:block;
  flex:1;
}

/* When wrapper is in fullscreen, fill completely */
#iframeWrapper:-webkit-full-screen { width:100vw; height:100vh; }
#iframeWrapper:-moz-full-screen    { width:100vw; height:100vh; }
#iframeWrapper:fullscreen          { width:100vw; height:100vh; }
#iframeWrapper:fullscreen iframe   { height:100%; }

/* When iframe itself is in fullscreen, fill completely */
iframe:-webkit-full-screen { width:100vw; height:100vh; border:0; }
iframe:-moz-full-screen    { width:100vw; height:100vh; border:0; }
iframe:fullscreen          { width:100vw; height:100vh; border:0; }

/* ── FOOTER ── */
footer{
  padding:14px 28px;
  background:transparent;
  border-top:1px solid rgba(15,23,42,0.05);
  display:flex;
  justify-content:space-between;
  align-items:center;
  flex-shrink:0;
}
footer p{margin:0;color:var(--muted);font-size:13px}

/* ── UTILS ── */
.muted{color:var(--muted);font-size:13px}
.center{text-align:center}

/* ── RESPONSIVE ── */
@media(max-width:900px){
  :root{--sidebar-width:240px}
}

@media(max-width:700px){
  .main-layout{flex-direction:column}
  .sidebar{
    width:100% !important;
    border-right:none;
    border-bottom:1px solid rgba(15,23,42,0.07);
  }
  .sidebar.collapsed{
    width:100% !important;
    max-height:52px;
    overflow:hidden;
  }
  .viewer-topbar{flex-wrap:wrap;gap:8px}
  .bc-cat,.bc-sep{display:none}
  iframe{height:60vh}
  .welcome-screen{padding:40px 20px}
}

@media(max-width:420px){
  header.header{flex-direction:column;align-items:flex-start;gap:10px}
  .viewer-action-btn span{display:none}
  iframe{height:56vh}
}

/* ══════════════════════════════════════════════
   CHATBOT SSENDA
   ══════════════════════════════════════════════ */

#ssenda-chatbot-root { font-family: Inter, system-ui, sans-serif; }

/* ── Botón flotante ── */
#chat-fab {
  position: fixed;
  bottom: 28px; right: 28px;
  width: 58px; height: 58px;
  background: linear-gradient(135deg, #b89500 0%, #D9B300 100%);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(217,179,0,0.5);
  display: flex; align-items: center; justify-content: center;
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .25s;
  z-index: 9000;
}
#chat-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 28px rgba(217,179,0,0.7);
}
#chat-fab svg { width: 24px; height: 24px; }

.fab-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: #111827;
  color: #D9B300;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 2px 5px;
  border-radius: 10px;
  border: 1.5px solid #D9B300;
}

/* ── Ventana del chat ── */
#chat-window {
  position: fixed;
  bottom: 100px; right: 28px;
  width: 370px;
  max-height: 420px;
  background: #fff;
  border-radius: 18px;
  border: 1px solid rgba(217,179,0,0.25);
  box-shadow: 0 20px 60px rgba(2,6,23,0.15), 0 0 0 1px rgba(217,179,0,0.1);
  display: flex; flex-direction: column;
  overflow: hidden;
  z-index: 8999;
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px) scale(0.97);
  transition: opacity .25s ease, transform .28s cubic-bezier(.34,1.2,.64,1);
}
#chat-window.open {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0) scale(1);
}

/* Header */
.chat-header {
  background: linear-gradient(90deg, #b89500, #D9B300 60%);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.chat-header-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255,255,255,0.22);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; flex-shrink: 0;
}
.chat-header-info { flex: 1; }
.chat-header-name {
  font-family: Montserrat, sans-serif;
  font-weight: 700; font-size: 13px; color: #fff;
}
.chat-header-sub { font-size: 10px; color: rgba(255,255,255,0.8); margin-top: 1px; }
.chat-status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #4ade80; box-shadow: 0 0 6px #4ade80;
  flex-shrink: 0;
}

/* Mensajes */
.chat-messages {
  flex: 1; overflow-y: auto;
  padding: 14px 12px;
  display: flex; flex-direction: column; gap: 10px;
  scrollbar-width: thin; scrollbar-color: #e5e7eb transparent;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 4px; }

.chat-msg {
  display: flex; gap: 7px; align-items: flex-end;
  animation: chatMsgIn .22s cubic-bezier(.34,1.2,.64,1) both;
}
@keyframes chatMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-msg.user { flex-direction: row-reverse; }

.chat-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: #f3f4f6; border: 1px solid #e5e7eb;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0;
}
.chat-msg.user .chat-avatar {
  background: rgba(217,179,0,0.15);
  border-color: rgba(217,179,0,0.35);
}

.chat-bubble {
  max-width: 82%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 12.5px;
  line-height: 1.55;
  word-break: break-word;
}
.chat-msg.bot .chat-bubble {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  color: #111827;
  border-bottom-left-radius: 4px;
}
.chat-msg.user .chat-bubble {
  background: linear-gradient(135deg, #b89500, #D9B300);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Typing dots */
.chat-typing-dots {
  display: flex; gap: 4px; align-items: center; padding: 2px 0;
}
.chat-typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: #9ca3af;
  animation: chatBounce 1.1s infinite;
}
.chat-typing-dots span:nth-child(2) { animation-delay: .18s; }
.chat-typing-dots span:nth-child(3) { animation-delay: .36s; }
@keyframes chatBounce {
  0%,80%,100% { transform: translateY(0); background: #9ca3af; }
  40% { transform: translateY(-5px); background: #D9B300; }
}

/* Sugerencias */
.chat-suggestions {
  padding: 4px 12px 8px;
  display: flex; flex-wrap: wrap; gap: 5px;
  flex-shrink: 0;
}
.chat-suggestions button {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  color: #374151;
  font-size: 10.5px;
  font-family: Inter, sans-serif;
  padding: 4px 9px;
  border-radius: 20px;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.chat-suggestions button:hover {
  border-color: #D9B300;
  color: #7a6100;
  background: rgba(217,179,0,0.07);
}

/* Input */
.chat-input-area {
  padding: 10px 12px;
  border-top: 1px solid #f3f4f6;
  display: flex; gap: 7px; align-items: flex-end;
  flex-shrink: 0;
  background: #fff;
}
#chat-input {
  flex: 1;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 8px 11px;
  color: #111827;
  font-family: Inter, sans-serif;
  font-size: 12.5px;
  resize: none;
  min-height: 36px;
  max-height: 110px;
  outline: none;
  line-height: 1.4;
  transition: border-color .15s;
}
#chat-input:focus { border-color: rgba(217,179,0,0.6); }
#chat-input::placeholder { color: #9ca3af; }

#chat-send {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #b89500, #D9B300);
  border: none; border-radius: 9px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: opacity .15s, transform .15s;
}
#chat-send:hover { opacity: .88; transform: scale(1.05); }
#chat-send:disabled { opacity: .35; cursor: not-allowed; transform: none; }
#chat-send svg { width: 15px; height: 15px; }

.chat-footer-note {
  font-size: 9.5px; color: #9ca3af;
  text-align: center; padding: 4px 12px 8px;
}

/* ── Responsive chatbot ── */
@media(max-width: 420px) {
  #chat-window { width: calc(100vw - 24px); right: 12px; bottom: 90px; }
  #chat-fab { bottom: 18px; right: 18px; }
}

/* ── Autocompletado ── */
.chat-autocomplete {
  position: relative;
  margin: 0 12px 4px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  flex-shrink: 0;
  max-height: 200px;
  overflow-y: auto;
}
.ac-item {
  padding: 8px 12px;
  font-size: 12px;
  color: #374151;
  cursor: pointer;
  border-bottom: 1px solid #f3f4f6;
  transition: background .12s;
  font-family: Inter, sans-serif;
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.active {
  background: rgba(217,179,0,0.08);
  color: #7a6100;
}
