:root {
  --bg:#0d0d0d; 
  --panel:#171717; 
  --panel-hover:#212121; 
  --panel-active:#2f2f2f;
  --border:#4e4e4e; 
  --brand:#19c37d; 
  --text:#ececec; 
  --text-muted:#8e8ea0;
  --ai-bg:var(--panel);
  --user-bg:var(--panel-active);
  --scrollbar-bg:#2f2f2f; 
  --scrollbar-thumb:#5c5c5c; 
  --scrollbar-thumb-hover:#8e8ea0; 
}

*{box-sizing:border-box;margin:0;padding:0}

body{
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  background:var(--bg);
  color:var(--text);
  height:100vh;
  display:flex;
  overflow:hidden
}

.sidebar{
  width:300px;
  background:var(--panel);
  display:flex;
  flex-direction:column;
  border-right:1px solid var(--border)
}

.sidebar-header{
  padding:16px 12px;
  border-bottom:1px solid var(--border);
  display:flex;
  align-items:center;
  justify-content:center;
  gap:12px;
  height:52px
}

.sidebar-header .logo{
  font-size:20px;
  font-weight:700;
  color:var(--brand);
  text-transform:uppercase;
  letter-spacing:1px
}

.sidebar-header .logo-img{
  width:32px;
  height:32px;
  border-radius:50%;
  object-fit:cover;
  display:block
}

.sidebar-top{
  padding:12px;
  border-bottom:1px solid var(--border);
  display:flex;
  flex-direction:column;
  gap:8px;
  position:relative
}

.sidebar-top::before{
  content:'\f002';
  font-family:'Font Awesome 6 Free';
  font-weight:900;
  position:absolute;
  left:24px;
  top:23px;
  color:var(--text-muted);
  font-size:14px;
  pointer-events:none;
  z-index:1;
  transition:color .2s
}

#chatSearchInput{
  width:100%;
  padding:10px 12px 10px 36px;
  border:1px solid var(--border);
  background:var(--panel-hover);
  color:var(--text);
  border-radius:8px;
  font-size:14px;
  font-family:inherit;
  transition:all .2s
}

#chatSearchInput::placeholder{color:var(--text-muted)}

#chatSearchInput:focus,
#chatSearchInput:not(:placeholder-shown){
  outline:none;
  border-color:var(--brand);
  background:var(--panel-active)
}

#chatSearchInput:focus{box-shadow:0 0 0 3px rgba(25,195,125,.1)}

#chatSearchInput:focus~.sidebar-top::before,
#chatSearchInput:not(:placeholder-shown)~.sidebar-top::before{
  color:var(--brand)
}

.new-chat-btn{
  width:100%;
  background:transparent;
  border:1px solid var(--border);
  color:var(--text);
  padding:10px;
  border-radius:8px;
  cursor:pointer;
  font-size:14px;
  font-weight:500;
  transition:all .2s
}

.new-chat-btn:hover{background:var(--panel-hover)}

.chats-list{
  flex:1;
  overflow-y:auto;
  padding:8px;
  min-height:0
}

.chat-item{
  padding:10px 12px;
  border-radius:8px;
  cursor:pointer;
  margin-bottom:4px;
  display:flex;
  align-items:center;
  gap:8px;
  transition:background .2s;
  position:relative;
  overflow:hidden;
  animation:fadeInSlide .2s ease-out
}

.chat-item::before{
  content:'';
  position:absolute;
  left:0;
  top:0;
  height:100%;
  width:3px;
  background:var(--brand);
  transform:translateX(-3px);
  transition:transform .2s
}

.chat-item:hover{background:var(--panel-hover)}

.chat-item.active{background:var(--panel-active)}

.chat-item.active::before{transform:translateX(0)}

.chat-item:has(.chat-title-edit){
  background:var(--panel-active);
  border-left:3px solid var(--brand);
  padding-left:9px
}

.chat-title{
  flex:1;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  font-weight:500;
  font-size:14px;
  color:var(--text)
}

.chat-title mark{
  background:var(--brand);
  color:#000;
  padding:2px 4px;
  border-radius:3px;
  font-weight:700;
  animation:highlightPulse .3s ease-out
}

.chat-actions{
  display:flex;
  gap:4px;
  opacity:0;
  transition:opacity .2s;
  flex-shrink:0;
  margin-left:auto
}

.chat-item:hover .chat-actions,
.chat-item.active .chat-actions{opacity:1}

.chat-action-btn{
  width:28px;
  height:28px;
  padding:0;
  background:transparent;
  border:none;
  border-radius:6px;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  transition:all .2s;
  color:var(--text-muted);
  font-size:14px
}

.chat-action-btn:hover{
  background:var(--panel-active);
  transform:scale(1.1)
}

.chat-action-btn.edit-btn:hover{
  background:rgba(25,195,125,.15);
  color:var(--brand)
}

.chat-action-btn.delete-btn:hover{
  background:rgba(239,68,68,.15);
  color:#ef4444
}

.chat-title-edit{
  flex:1;
  padding:6px 8px;
  background:var(--panel-active);
  border:2px solid var(--brand);
  border-radius:6px;
  color:var(--text);
  font-size:14px;
  font-weight:500;
  font-family:inherit;
  outline:none;
  box-shadow:0 0 0 3px rgba(25,195,125,.1)
}

.chat-title-edit::selection{
  background:var(--brand);
  color:#000
}

.edit-actions{
  display:flex;
  gap:4px;
  flex-shrink:0;
  margin-left:8px
}

.edit-action-btn{
  width:28px;
  height:28px;
  padding:0;
  border:none;
  border-radius:6px;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  transition:all .2s;
  font-size:14px;
  font-weight:600
}

.edit-action-btn.confirm{
  background:var(--brand);
  color:#000
}

.edit-action-btn.confirm:hover{
  opacity:.85;
  transform:scale(1.1)
}

.edit-action-btn.cancel{
  background:var(--panel-hover);
  color:var(--text-muted);
  border:1px solid var(--border)
}

.edit-action-btn.cancel:hover{
  background:rgba(239,68,68,.15);
  color:#ef4444;
  border-color:#ef4444;
  transform:scale(1.1)
}

.search-results-counter{
  padding:8px 12px;
  text-align:center;
  font-size:11px;
  color:var(--brand);
  background:rgba(25,195,125,.1);
  border:1px solid rgba(25,195,125,.2);
  border-radius:6px;
  margin-bottom:8px;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:.5px;
  animation:slideDown .3s ease-out
}

.sidebar-bottom{
  padding:10px;
  border-top:0px solid var(--border);
  display:flex;
  flex-direction:column;
  gap:8px
}

.profile-menu-container{
  position:relative;
  cursor:pointer;
  padding:10px;
  border-radius:10px;
  display:flex;
  align-items:center;
  gap:12px;
  transition:background .2s;
  user-select:none
}

.profile-menu-container.logged-in:hover,
.profile-menu-container:not(.logged-in):hover{
  background:var(--panel-hover)
}

.profile-menu-container:not(.logged-in) .avatar{
  animation:pulse 2s infinite
}

.profile-menu-container .avatar{
  width:36px;
  height:36px;
  border-radius:50%;
  background:var(--brand);
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:16px;
  font-weight:700;
  color:#000;
  flex-shrink:0;
  text-transform:uppercase
}

.profile-menu-container .avatar-img{
  width:36px;
  height:36px;
  border-radius:50%;
  object-fit:cover;
  flex-shrink:0;
  border:2px solid var(--brand);
  transition:all .3s;
  opacity:0;
  animation:fadeInAvatar .3s ease-out forwards
}

.profile-menu-container:hover .avatar-img{
  border-color:var(--text);
  transform:scale(1.05)
}

.profile-menu-container .info{
  flex:1;
  min-width:0;
  display:flex;
  flex-direction:column
}

.profile-menu-container .info .email{
  font-size:13px;
  font-weight:600;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  color:var(--text)
}

.profile-menu-container .chevron{
  color:var(--text-muted);
  transition:transform .2s;
  flex-shrink:0
}

.profile-menu-container.open .chevron{
  transform:rotate(180deg)
}

.dropdown-menu{
  position:absolute!important;
  bottom:70px!important;
  left:8px!important;
  right:8px!important;
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:8px;
  box-shadow:0 4px 10px rgba(0,0,0,.5);
  z-index:2000!important;
  opacity:0;
  visibility:hidden;
  transform:translateY(10px);
  transition:opacity .2s,transform .2s,visibility .2s;
  min-width:200px;
  max-width:280px;
  padding:8px
}

.dropdown-menu.visible{
  opacity:1!important;
  visibility:visible!important;
  transform:translateY(0)!important;
  display:block!important
}

.dropdown-menu button,.dropdown-menu a{
  display:flex;
  width:100%;
  padding:10px 15px;
  text-align:left;
  background:none;
  border:none;
  color:var(--text);
  font-size:14px;
  cursor:pointer;
  text-decoration:none;
  align-items:center;
  gap:10px;
  transition:background .2s;
  font-family:inherit
}

.dropdown-menu button:hover,.dropdown-menu a:hover{
  background:var(--panel-hover)
}

.dropdown-menu .logout{
  color:#ff5050;
  border-top:1px solid var(--border)
}

.dropdown-menu .login-btn{
  background:var(--brand);
  color:#000;
  font-weight:600;
  border-radius:8px;
  margin:8px;
  padding:10px;
  justify-content:center;
  transition:opacity .2s
}

.dropdown-menu .login-btn:hover{opacity:.9}

.content{
  flex:1;
  display:flex;
  flex-direction:column;
  background:var(--bg)
}

.header{
  height:52px;
  border-bottom:1px solid var(--border);
  display:flex;
  align-items:center;
  justify-content:center;
  background:var(--panel);
  position:relative
}

.header-content{
  display:flex;
  align-items:center;
  gap:12px;
  width:100%;
  max-width:900px;
  margin:0 auto;
  padding:0 16px
}

.role-selector{position:relative}

.role-selector::after{
  content:'▼';
  position:absolute;
  right:10px;
  top:50%;
  transform:translateY(-50%);
  pointer-events:none;
  color:var(--text-muted);
  font-size:10px
}

.role-select{
  padding:6px 32px 6px 12px;
  border:1px solid var(--border);
  border-radius:8px;
  background:var(--panel-hover);
  color:var(--text);
  font-size:13px;
  font-weight:500;
  cursor:pointer;
  appearance:none;
  min-width:180px;
  transition:all .2s;
  font-family:inherit
}

.role-select:hover{
  background:var(--panel-active);
  border-color:var(--brand)
}

.role-select:focus{
  outline:none;
  border-color:var(--brand);
  box-shadow:0 0 0 2px rgba(25,195,125,.1)
}

.role-select option{
  background:var(--panel);
  color:var(--text);
  padding:8px
}

.role-select option[value="crear_personalidad"]{
  font-weight:700;
  color:var(--brand);
  border-top:1px solid var(--border);
  margin-top:4px;
  padding-top:12px
}

.header .title{
  font-size:14px;
  font-weight:600;
  color:var(--text);
  transition:all .2s;
  flex:1;
  text-align:center
}

.header .title:hover{opacity:.8}

.header .status-price{
  display:flex;
  align-items:center;
  gap:8px;
  font-size:12px;
  color:var(--text-muted)
}

.header .status-price .price-logo{
  width:24px;
  height:24px;
  border-radius:50%;
  object-fit:cover;
  display:block
}

.header .status-price .price-text{
  font-size:12px;
  font-weight:500;
  color:var(--text-muted)
}

.price-text.sin-tokens{
  color:#ef4444!important;
  font-weight:700;
  animation:pulse 2s infinite
}

.price-text.tokens-bajos{
  color:#f59e0b!important;
  font-weight:600
}

.config-menu-container{
  position:relative;
  display:flex;
  align-items:center
}

.config-btn{
  width:32px;
  height:32px;
  border-radius:50%;
  background:transparent;
  border:none;
  color:var(--text-muted);
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  transition:all .3s cubic-bezier(.4,0,.2,1);
  font-size:16px
}

.config-btn:hover{
  background:var(--panel-hover);
  color:var(--text)
}

.config-btn i{
  transition:transform .5s cubic-bezier(.4,0,.2,1)
}

.config-menu-container.open .config-btn i{
  transform:rotate(180deg)
}

.config-dropdown{
  position:absolute;
  top:calc(100% + 8px);
  right:0;
  min-width:260px;
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:12px;
  box-shadow:0 8px 24px rgba(0,0,0,.6);
  z-index:1000;
  opacity:0;
  visibility:hidden;
  transform:translateY(-10px) scale(.95);
  transition:opacity .2s,transform .2s,visibility .2s;
  overflow:hidden
}

.config-dropdown.visible{
  opacity:1;
  visibility:visible;
  transform:translateY(0) scale(1)
}

.config-dropdown-header{
  padding:16px;
  border-bottom:1px solid var(--border);
  display:flex;
  align-items:center;
  gap:10px;
  font-size:14px;
  font-weight:600;
  color:var(--text);
  background:var(--panel-hover)
}

.config-dropdown-header i{
  color:var(--brand);
  font-size:16px
}

.config-option{
  width:100%;
  padding:12px 16px;
  background:none;
  border:none;
  color:var(--text);
  font-size:14px;
  cursor:pointer;
  display:flex;
  align-items:center;
  gap:12px;
  transition:all .2s;
  text-align:left;
  font-family:inherit;
  text-decoration:none
}

.config-option:hover{background:var(--panel-hover)}

.config-option i:first-child{
  width:20px;
  color:var(--text-muted);
  font-size:16px;
  transition:color .2s
}

.config-option:hover i:first-child{color:var(--brand)}

.config-option span{
  flex:1;
  font-weight:500
}

.config-option i.fa-chevron-right,
.config-option i.help-chevron{
  width:16px;
  font-size:12px;
  color:var(--text-muted);
  margin-left:auto;
  transition:transform .3s ease
}

.config-option:not(:last-child){
  border-bottom:1px solid rgba(78,78,78,.3)
}

/* Estilos para el submenú de ayuda */
.config-option-expandable{
  position:relative
}

.config-submenu{
  background:var(--panel-active);
  border-top:1px solid var(--border);
  animation:slideDownSubmenu .3s ease-out
}

.config-suboption{
  padding:10px 16px 10px 40px!important;
  font-size:13px!important;
  border-bottom:none!important
}

.config-suboption i:first-child{
  width:16px!important;
  font-size:14px!important
}

.config-suboption:last-child{
  border-bottom:1px solid rgba(78,78,78,.3)!important
}

#optionLanguage #currentLangIndicator{
  padding:2px 6px;
  background:rgba(25,195,125,.15);
  border-radius:4px;
  font-size:10px;
  letter-spacing:.5px;
  transition:color .3s
}

.menu-btn{
  display:none;
  position:absolute;
  left:16px;
  background:transparent;
  border:none;
  color:var(--text);
  font-size:20px;
  cursor:pointer
}

.messages{
  flex:1;
  overflow-y:auto;
  padding:24px 16px;
  display:flex;
  flex-direction:column;
  gap:16px
}

.msg-group{
  display:flex;
  flex-direction:column;
  gap:8px;
  max-width:48rem;
  margin:0 auto;
  width:100%
}

.msg-group.user{align-items:flex-end}

.msg-group.assistant{align-items:flex-start}

.msg-content{
  flex:1;
  padding:12px 16px;
  border-radius:12px;
  line-height:1.6;
  white-space:pre-wrap;
  font-size:15px
}

.msg-group.assistant .msg-content{background:var(--ai-bg)}

.msg-group.user .msg-content{background:var(--user-bg)}

.msg-group.from-cache .msg-content{
  border-left:3px solid #10b981;
  background:rgba(16,185,129,.05)
}

.cache-indicator{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:6px 12px;
  background:rgba(16,185,129,.15);
  border:1px solid #10b981;
  border-radius:6px;
  color:#10b981;
  font-size:11px;
  font-weight:700;
  text-transform:uppercase
}

.cache-indicator i{font-size:12px}

.composer{
  border-top:1px solid var(--border);
  padding:16px;
  background:var(--panel);
  margin-top:-1px
}

.composer-inner{
  max-width:48rem;
  margin:0 auto;
  display:flex;
  gap:12px;
  align-items:flex-end
}

.composer textarea{
  flex:1;
  resize:none;
  border:1px solid var(--border);
  border-radius:12px;
  background:var(--panel-hover);
  color:var(--text);
  padding:12px 16px;
  font-size:15px;
  font-family:inherit;
  min-height:52px;
  max-height:200px
}

.composer textarea::placeholder{color:var(--text-muted)}

.composer textarea:focus{
  outline:none;
  border-color:var(--brand)
}

.composer button{
  padding:12px 20px;
  background:var(--brand);
  border:none;
  border-radius:8px;
  color:#000;
  font-weight:600;
  cursor:pointer;
  font-size:14px;
  transition:opacity .2s
}

.composer button:hover{opacity:.9}

.composer button:disabled{
  opacity:.5;
  cursor:not-allowed
}

.empty-state{
  text-align:center;
  color:var(--text-muted);
  margin-top:40px
}

.empty-state h2{
  font-size:32px;
  font-weight:600;
  color:var(--text);
  margin-bottom:16px
}

.empty-state p{font-size:16px}

.chats-list::-webkit-scrollbar,
.messages::-webkit-scrollbar{
  width:8px;
  height:8px
}

.chats-list::-webkit-scrollbar-track,
.messages::-webkit-scrollbar-track{
  background:var(--panel);
  border-radius:4px
}

.chats-list::-webkit-scrollbar-thumb,
.messages::-webkit-scrollbar-thumb{
  background-color:var(--scrollbar-thumb);
  border-radius:4px;
  border:2px solid var(--panel)
}

.chats-list::-webkit-scrollbar-thumb:hover,
.messages::-webkit-scrollbar-thumb:hover{
  background-color:var(--scrollbar-thumb-hover)
}

.chats-list{
  scrollbar-width:thin;
  scrollbar-color:var(--scrollbar-thumb) var(--panel)
}

.messages{
  scrollbar-width:thin;
  scrollbar-color:var(--scrollbar-thumb) var(--bg)
}

.custom-context-modal{
  position:fixed;
  top:0;
  left:0;
  right:0;
  bottom:0;
  background:rgba(0,0,0,.8);
  display:none;
  align-items:center;
  justify-content:center;
  z-index:2000;
  animation:fadeIn .2s ease-out
}

.custom-context-modal.visible{display:flex!important}

.custom-context-content{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:12px;
  padding:24px;
  max-width:500px;
  width:90%;
  box-shadow:0 8px 32px rgba(0,0,0,.6);
  animation:slideUp .3s ease-out
}

.custom-context-content h3{
  margin:0 0 16px 0;
  color:var(--text);
  font-size:18px
}

.custom-context-content p{
  color:var(--text-muted);
  font-size:13px;
  margin-bottom:12px;
  line-height:1.5
}

.custom-context-content textarea{
  width:100%;
  min-height:120px;
  padding:12px;
  border:1px solid var(--border);
  border-radius:8px;
  background:var(--panel-hover);
  color:var(--text);
  font-family:inherit;
  font-size:14px;
  resize:vertical;
  margin-bottom:16px;
  line-height:1.5
}

.custom-context-content textarea:focus{
  outline:none;
  border-color:var(--brand);
  box-shadow:0 0 0 2px rgba(25,195,125,.1)
}

.custom-context-content textarea::placeholder{color:var(--text-muted)}

.custom-context-content textarea::-webkit-scrollbar{width:6px}

.custom-context-content textarea::-webkit-scrollbar-track{
  background:var(--panel-active);
  border-radius:3px
}

.custom-context-content textarea::-webkit-scrollbar-thumb{
  background:var(--scrollbar-thumb);
  border-radius:3px
}

.custom-context-content textarea::-webkit-scrollbar-thumb:hover{
  background-color:var(--scrollbar-thumb-hover)
}

.custom-context-buttons{
  display:flex;
  gap:8px;
  justify-content:flex-end
}

.custom-context-buttons button{
  padding:10px 20px;
  border:none;
  border-radius:8px;
  cursor:pointer;
  font-size:14px;
  font-weight:600;
  transition:all .2s;
  font-family:inherit
}

.custom-context-buttons .btn-cancel{
  background:var(--panel-hover);
  color:var(--text);
  border:1px solid var(--border)
}

.custom-context-buttons .btn-cancel:hover{
  background:var(--panel-active)
}

.custom-context-buttons .btn-save{
  background:var(--brand);
  color:#000
}

.custom-context-buttons .btn-save:hover{opacity:.9}

.language-option{
  font-family:inherit;
  color:var(--text)
}

.language-option:hover{
  transform:translateY(-2px);
  box-shadow:0 4px 12px rgba(0,0,0,.3)
}

.language-option:active{transform:translateY(0)}

.toast-notification{
  position:fixed;
  bottom:24px;
  right:24px;
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:10px;
  padding:12px 16px;
  display:flex;
  align-items:center;
  gap:10px;
  box-shadow:0 8px 24px rgba(0,0,0,.4);
  z-index:10000;
  opacity:0;
  transform:translateY(20px);
  transition:all .3s cubic-bezier(.4,0,.2,1)
}

.toast-notification.show{
  opacity:1;
  transform:translateY(0)
}

.toast-notification i{font-size:18px}

.toast-notification.toast-success{border-left:4px solid var(--brand)}

.toast-notification.toast-success i{color:var(--brand)}

.toast-notification.toast-info{border-left:4px solid #3b82f6}

.toast-notification.toast-info i{color:#3b82f6}

.toast-notification.toast-error{border-left:4px solid #ef4444}

.toast-notification.toast-error i{color:#ef4444}

.toast-notification span{
  font-size:14px;
  font-weight:500;
  color:var(--text)
}

@keyframes fadeIn{from{opacity:0}to{opacity:1}}

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

@keyframes slideDown{from{max-height:0;opacity:0}to{max-height:200px;opacity:1}}

@keyframes slideDownSubmenu{from{max-height:0;opacity:0}to{max-height:200px;opacity:1}}

@keyframes fadeInSlide{from{opacity:0;transform:translateX(-10px)}to{opacity:1;transform:translateX(0)}}

@keyframes pulse{0%,100%{opacity:1}50%{opacity:.6}}

@keyframes fadeInAvatar{from{opacity:0;transform:scale(.9)}to{opacity:1;transform:scale(1)}}

@keyframes highlightPulse{0%{transform:scale(1);opacity:.7}50%{transform:scale(1.1);opacity:1}100%{transform:scale(1);opacity:1}}

@media (max-width:768px){
  .menu-btn{display:block}
  .sidebar{
    width:100%;
    height:100vh;
    position:fixed;
    top:0;
    left:0;
    z-index:999;
    transform:translateX(-100%);
    transition:transform .3s ease
  }
  .sidebar.open{transform:translateX(0)}
  .config-dropdown{right:-8px;min-width:240px}
  .header-content{flex-direction:column;gap:8px;padding:8px;height:auto}
  .header{height:auto;min-height:52px;padding:8px 0}
  .role-select{min-width:100%;width:100%}
  .header .title{order:-1;width:100%}
  .header .status-price{position:relative;right:auto}
  .custom-context-content{width:95%;padding:20px}
  .sidebar-bottom{padding:8px 12px}
  .profile-menu-container{padding:8px}
  .dropdown-menu{
    position:fixed;
    bottom:20px;
    left:50%;
    right:auto;
    transform:translateX(-50%);
    width:90%;
    max-width:280px;
    z-index:1001
  }
  .toast-notification{bottom:80px;right:16px;left:16px;width:auto}
  .chat-actions{opacity:1}
}

@media (max-width:480px){
  .dropdown-menu{width:95%;left:50%;transform:translateX(-50%)}
  .profile-menu-container{padding:6px}
  .sidebar-bottom{padding:6px 8px}
}

body:has(:root[style*="--bg: #f5f7fa"]) .sidebar{box-shadow:2px 0 8px rgba(0,0,0,.05)}

body:has(:root[style*="--bg: #f5f7fa"]) .header{box-shadow:0 1px 3px rgba(0,0,0,.05)}

body:has(:root[style*="--bg: #f5f7fa"]) .composer{box-shadow:0 -1px 3px rgba(0,0,0,.05)}

body:has(:root[style*="--bg: #f5f7fa"]) #chatSearchInput,
body:has(:root[style*="--bg: #f5f7fa"]) .composer textarea,
body:has(:root[style*="--bg: #f5f7fa"]) .role-select{border:1.5px solid #cbd5e1}

body:has(:root[style*="--bg: #f5f7fa"]) #chatSearchInput:focus,
body:has(:root[style*="--bg: #f5f7fa"]) .composer textarea:focus,
body:has(:root[style*="--bg: #f5f7fa"]) .role-select:focus{
  border-color:#10b981;
  box-shadow:0 0 0 3px rgba(16,185,129,.1)
}

body:has(:root[style*="--bg: #f5f7fa"]) #chatSearchInput:not(:placeholder-shown){
  border-color:#10b981;
  background:#fff
}

body:has(:root[style*="--bg: #f5f7fa"]) .sidebar-top::before{color:#64748b}

body:has(:root[style*="--bg: #f5f7fa"]) #chatSearchInput:focus~.sidebar-top::before,
body:has(:root[style*="--bg: #f5f7fa"]) #chatSearchInput:not(:placeholder-shown)~.sidebar-top::before{
  color:#10b981
}

body:has(:root[style*="--bg: #f5f7fa"]) .new-chat-btn{
  border:1.5px solid #cbd5e1;
  color:#334155;
  font-weight:600
}

body:has(:root[style*="--bg: #f5f7fa"]) .new-chat-btn:hover{
  background:#e8f0fe;
  border-color:#10b981
}

body:has(:root[style*="--bg: #f5f7fa"]) .chat-item:hover{background:#f1f5f9}

body:has(:root[style*="--bg: #f5f7fa"]) .chat-item.active{
  background:#dbeafe;
  border-left:3px solid #10b981
}

body:has(:root[style*="--bg: #f5f7fa"]) .chat-item:has(.chat-title-edit){
  background:#f8fafc;
  border-left:3px solid #10b981
}

body:has(:root[style*="--bg: #f5f7fa"]) .chat-title mark{
  background:#10b981;
  color:#fff;
  box-shadow:0 2px 4px rgba(16,185,129,.2)
}

body:has(:root[style*="--bg: #f5f7fa"]) .search-results-counter{
  background:rgba(16,185,129,.15);
  border-color:rgba(16,185,129,.3);
  color:#059669
}

body:has(:root[style*="--bg: #f5f7fa"]) .chat-action-btn{color:#64748b}

body:has(:root[style*="--bg: #f5f7fa"]) .chat-action-btn:hover{background:#f1f5f9}

body:has(:root[style*="--bg: #f5f7fa"]) .chat-action-btn.edit-btn:hover{
  background:rgba(16,185,129,.1);
  color:#10b981
}

body:has(:root[style*="--bg: #f5f7fa"]) .chat-action-btn.delete-btn:hover{
  background:rgba(239,68,68,.1);
  color:#ef4444
}

body:has(:root[style*="--bg: #f5f7fa"]) .chat-title-edit{
  background:#fff;
  border:2px solid #10b981;
  box-shadow:0 0 0 3px rgba(16,185,129,.1)
}

body:has(:root[style*="--bg: #f5f7fa"]) .edit-action-btn.confirm{
  background:#10b981;
  color:#fff
}

body:has(:root[style*="--bg: #f5f7fa"]) .edit-action-btn.cancel{
  background:#f8fafc;
  color:#64748b;
  border-color:#cbd5e1
}

body:has(:root[style*="--bg: #f5f7fa"]) .config-dropdown,
body:has(:root[style*="--bg: #f5f7fa"]) .dropdown-menu{
  box-shadow:0 4px 20px rgba(0,0,0,.12);
  border:1px solid #cbd5e1
}

body:has(:root[style*="--bg: #f5f7fa"]) .config-dropdown-header{
  background:#f8fafc;
  border-bottom:1px solid #e2e8f0
}

body:has(:root[style*="--bg: #f5f7fa"]) .config-submenu{
  background:#f1f5f9;
  border-top:1px solid #cbd5e1
}

body:has(:root[style*="--bg: #f5f7fa"]) .config-btn:hover,
body:has(:root[style*="--bg: #f5f7fa"]) .profile-menu-container:hover{
  background:#f1f5f9
}

body:has(:root[style*="--bg: #f5f7fa"]) .profile-menu-container .info .email{color:#1e293b}

body:has(:root[style*="--bg: #f5f7fa"]) .profile-menu-container .avatar,
body:has(:root[style*="--bg: #f5f7fa"]) .profile-menu-container .avatar-img{
  box-shadow:0 2px 8px rgba(0,0,0,.1)
}

body:has(:root[style*="--bg: #f5f7fa"]) .status-price .price-text{
  color:#475569;
  font-weight:600
}

body:has(:root[style*="--bg: #f5f7fa"]) .msg-group.assistant .msg-content{
  background:#f1f5f9;
  color:#1e293b;
  border:1px solid #e2e8f0
}

body:has(:root[style*="--bg: #f5f7fa"]) .msg-group.user .msg-content{
  background:#dbeafe;
  color:#1e3a8a;
  border:1px solid #bfdbfe
}

body:has(:root[style*="--bg: #f5f7fa"]) .cache-indicator{
  background:rgba(16,185,129,.1);
  border:1px solid #10b981;
  color:#059669
}

body:has(:root[style*="--bg: #f5f7fa"]) .msg-group.from-cache .msg-content{
  border-left:3px solid #10b981;
  background:#ecfdf5
}

body:has(:root[style*="--bg: #f5f7fa"]) .empty-state h2{color:#0f172a}

body:has(:root[style*="--bg: #f5f7fa"]) .empty-state p{color:#64748b}

body:has(:root[style*="--bg: #f5f7fa"]) .custom-context-modal{background:rgba(15,23,42,.6)}

body:has(:root[style*="--bg: #f5f7fa"]) .custom-context-content{
  box-shadow:0 20px 50px rgba(0,0,0,.25);
  border:1px solid #cbd5e1
}

body:has(:root[style*="--bg: #f5f7fa"]) .custom-context-content h3{color:#0f172a}

body:has(:root[style*="--bg: #f5f7fa"]) .custom-context-content textarea{
  border:1.5px solid #cbd5e1;
  background:#f8fafc
}

body:has(:root[style*="--bg: #f5f7fa"]) .language-option{
  border:1.5px solid #cbd5e1!important;
  background:#fff!important
}

body:has(:root[style*="--bg: #f5f7fa"]) .language-option:hover{
  background:#f8fafc!important;
  border-color:#10b981!important
}

body:has(:root[style*="--bg: #f5f7fa"]) .language-option[style*="border-color: var(--brand)"]{
  background:#ecfdf5!important;
  border-color:#10b981!important
}

body:has(:root[style*="--bg: #f5f7fa"]) .export-option{
  border:1.5px solid #cbd5e1!important;
  background:#fff!important
}

body:has(:root[style*="--bg: #f5f7fa"]) .export-option:hover{
  background:#f8fafc!important;
  border-color:#10b981!important;
  transform:translateY(-2px);
  box-shadow:0 4px 12px rgba(0,0,0,.1)
}

body:has(:root[style*="--bg: #f5f7fa"]) .toast-notification{
  background:#fff;
  border:1px solid #e2e8f0;
  box-shadow:0 8px 24px rgba(0,0,0,.15)
}

body:has(:root[style*="--bg: #f5f7fa"]) .toast-notification.toast-success{border-left:4px solid #10b981}

body:has(:root[style*="--bg: #f5f7fa"]) .toast-notification span{color:#1e293b}

body:has(:root[style*="--bg: #f5f7fa"]) .chats-list::-webkit-scrollbar-track,
body:has(:root[style*="--bg: #f5f7fa"]) .messages::-webkit-scrollbar-track{background:#f1f5f9}

body:has(:root[style*="--bg: #f5f7fa"]) .chats-list::-webkit-scrollbar-thumb,
body:has(:root[style*="--bg: #f5f7fa"]) .messages::-webkit-scrollbar-thumb{
  background-color:#cbd5e1;
  border:2px solid #f1f5f9
}

body:has(:root[style*="--bg: #f5f7fa"]) .chats-list::-webkit-scrollbar-thumb:hover,
body:has(:root[style*="--bg: #f5f7fa"]) .messages::-webkit-scrollbar-thumb:hover{background-color:#94a3b8}

body:has(:root[style*="--bg: #f5f7fa"]) .sidebar-header,
body:has(:root[style*="--bg: #f5f7fa"]) .sidebar-top,
body:has(:root[style*="--bg: #f5f7fa"]) .sidebar-bottom,
body:has(:root[style*="--bg: #f5f7fa"]) .composer{border-color:#e2e8f0}

body:has(:root[style*="--bg: #f5f7fa"]) .composer button{
  background:#10b981;
  color:#fff;
  font-weight:700;
  box-shadow:0 2px 8px rgba(16,185,129,.25)
}

body:has(:root[style*="--bg: #f5f7fa"]) .composer button:hover{
  background:#059669;
  box-shadow:0 4px 12px rgba(16,185,129,.35)
}

/* ========== ESTILOS PARA BOTÓN RAG ========== */

.btn-toggle-rag {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  background: var(--panel-hover);
  border: 2px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn-toggle-rag::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  transition: left 0.5s;
}

.btn-toggle-rag:hover::before {
  left: 100%;
}

.btn-toggle-rag:hover {
  background: var(--panel-active);
  border-color: var(--brand);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(25, 195, 125, 0.2);
}

.btn-toggle-rag.active {
  background: linear-gradient(135deg, rgba(25, 195, 125, 0.25), rgba(25, 195, 125, 0.15));
  border-color: var(--brand);
  color: var(--brand);
  box-shadow: 0 0 20px rgba(25, 195, 125, 0.3);
  animation: pulse-rag 2s infinite;
}

@keyframes pulse-rag {
  0%, 100% {
    box-shadow: 0 0 20px rgba(25, 195, 125, 0.3);
  }
  50% {
    box-shadow: 0 0 30px rgba(25, 195, 125, 0.5);
  }
}

.btn-toggle-rag.active::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(45deg, var(--brand), transparent);
  border-radius: 10px;
  z-index: -1;
  opacity: 0.3;
  animation: rotate-border 3s linear infinite;
}

@keyframes rotate-border {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.btn-toggle-rag i {
  font-size: 18px;
  transition: transform 0.3s;
}

.btn-toggle-rag.active i {
  animation: spin-icon 0.5s ease-out;
}

@keyframes spin-icon {
  0% {
    transform: rotate(0deg) scale(1);
  }
  50% {
    transform: rotate(180deg) scale(1.2);
  }
  100% {
    transform: rotate(360deg) scale(1);
  }
}

/* ========== ESTILOS PARA AUTOCOMPLETADO ========== */

.autocomplete-list {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 0;
  right: 0;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 16px;
  max-height: 400px;
  overflow-y: auto;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.3), 0 -2px 8px rgba(0,0,0,0.2);
  z-index: 1000;
  display: none;
  backdrop-filter: blur(10px);
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.autocomplete-list::-webkit-scrollbar {
  width: 8px;
}

.autocomplete-list::-webkit-scrollbar-track {
  background: var(--scrollbar-bg);
  border-radius: 0 16px 16px 0;
}

.autocomplete-list::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 4px;
}

.autocomplete-list::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

.autocomplete-item {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.autocomplete-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--brand);
  transform: scaleY(0);
  transition: transform 0.2s;
}

.autocomplete-item:hover::before {
  transform: scaleY(1);
}

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

.autocomplete-item:hover {
  background: var(--panel-hover);
  padding-left: 24px;
}

.autocomplete-question {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.4;
}

.autocomplete-question i {
  color: var(--brand);
  font-size: 14px;
  flex-shrink: 0;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.autocomplete-preview {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 6px;
  line-height: 1.5;
  padding-left: 24px;
}

.autocomplete-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  padding-left: 24px;
  font-weight: 500;
}

.autocomplete-meta i {
  font-size: 11px;
}

.autocomplete-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  gap: 12px;
  color: var(--text-muted);
}

.autocomplete-loading i {
  font-size: 28px;
  color: var(--brand);
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.autocomplete-loading span {
  font-size: 14px;
  font-weight: 500;
}

.autocomplete-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  gap: 12px;
  color: var(--text-muted);
  text-align: center;
}

.autocomplete-empty i {
  font-size: 36px;
  opacity: 0.4;
}

.autocomplete-empty p {
  font-size: 13px;
  line-height: 1.6;
  max-width: 280px;
}

/* Efecto de highlight en el texto */
.autocomplete-question mark {
  background: rgba(25, 195, 125, 0.3);
  color: var(--brand);
  padding: 2px 4px;
  border-radius: 4px;
  font-weight: 700;
}

/* ========== ESTILOS PARA COMPOSER ========== */

.composer {
  padding: 20px;
  background: var(--panel);
  border-top: 1px solid var(--border);
}

.composer-inner {
  position: relative;
  display: flex;
  gap: 12px;
  align-items: flex-end;
  max-width: 900px;
  margin: 0 auto;
}

#msgInput {
  flex: 1;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  resize: none;
  min-height: 50px;
  max-height: 200px;
  transition: all 0.2s;
}

#msgInput:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(25, 195, 125, 0.1);
}

#msgInput.rag-mode {
  border-color: var(--brand);
  background: rgba(25, 195, 125, 0.05);
}

#btnSend {
  padding: 14px 24px;
  background: var(--brand);
  color: white;
  border: none;
  border-radius: 12px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

#btnSend:hover {
  background: #17a36a;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(25, 195, 125, 0.3);
}

#btnSend:active {
  transform: translateY(0);
}

#btnSend:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ========== BADGE PARA RESPUESTAS DESDE CACHE/RAG ========== */

.cache-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(25, 195, 125, 0.15);
  border: 1px solid var(--brand);
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--brand);
  margin-top: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  animation: fadeIn 0.3s;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.cache-badge i {
  font-size: 12px;
  animation: pulse 2s infinite;
}

/* Respuestas no encontradas en RAG */
.msg-content.rag-not-found {
  background: rgba(255, 193, 7, 0.1) !important;
  border-left: 4px solid #ffc107 !important;
}

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

@media (max-width: 768px) {
  .btn-toggle-rag {
    padding: 10px 14px;
    font-size: 13px;
    gap: 6px;
  }
  
  .btn-toggle-rag span {
    display: none;
  }
  
  .btn-toggle-rag i {
    font-size: 20px;
  }
  
  .autocomplete-list {
    max-height: 300px;
  }
  
  .composer-inner {
    gap: 8px;
  }
  
  #btnSend {
    padding: 12px 16px;
    font-size: 13px;
  }
}