/* ══════════════════════════════════
   IA JUSTICIA — Estilos
══════════════════════════════════ */

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

:root {
    --bg:         #0f1117;
    --bg2:        #13151f;
    --bg3:        #1a1d2e;
    --border:     #1e2030;
    --border2:    #2a2d40;
    --blue:       #2a7cff;
    --blue-hover: #1a6ce8;
    --text:       #e8ecf4;
    --text-muted: #888ea8;
    --text-dim:   #4a5068;
}

body { background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; height: 100vh; overflow: hidden; }

/* ── SCROLLBAR ──────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ══════════════════════════════════
   LOGIN
══════════════════════════════════ */
.login-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1.5rem; background: var(--bg); }

.login-card { background: var(--bg3); border: 1px solid var(--border2); border-radius: 16px; padding: 2.5rem; width: 100%; max-width: 420px; }

.login-icon  { font-size: 3.5rem; text-align: center; margin-bottom: 1rem; }
.login-title { font-size: 1.8rem; font-weight: 700; text-align: center; color: var(--text); }
.login-sub   { color: var(--text-muted); text-align: center; font-size: .9rem; margin-bottom: 2rem; }
.login-footer{ color: var(--text-dim); font-size: .78rem; text-align: center; margin-top: 1.5rem; line-height: 1.6; }

.field { margin-top: 1.2rem; }
.field label { display: block; font-size: .85rem; color: var(--text-muted); margin-bottom: .4rem; }
.field input  { width: 100%; background: var(--bg); border: 1px solid var(--border2); border-radius: 8px; padding: .75rem 1rem; color: var(--text); font-size: .9rem; transition: border-color .2s; }
.field input:focus { outline: none; border-color: var(--blue); }

.btn-primary { width: 100%; background: var(--blue); color: #fff; border: none; border-radius: 8px; padding: .85rem; font-size: 1rem; font-weight: 600; cursor: pointer; margin-top: 1.5rem; transition: background .2s; }
.btn-primary:hover    { background: var(--blue-hover); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.alert { border-radius: 8px; padding: .85rem 1rem; font-size: .88rem; margin-bottom: 1rem; }
.alert-error { background: #f871711a; border: 1px solid #f8717144; color: #f87171; }

/* ══════════════════════════════════
   APP LAYOUT
══════════════════════════════════ */
.app-screen { display: flex; height: 100vh; overflow: hidden; }

/* ── SIDEBAR ────────────────────── */
.sidebar { width: 256px; flex-shrink: 0; background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; }

.sidebar-brand { padding: 1rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .75rem; }
.brand-icon    { font-size: 1.5rem; }
.brand-name    { font-size: .85rem; font-weight: 700; color: var(--text); }
.brand-sub     { font-size: .72rem; color: var(--text-dim); }

.sidebar-section       { padding: .75rem; }
.sidebar-chats-label   { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dim); padding: .5rem .75rem .25rem; }

.btn-new-chat { width: 100%; background: var(--blue); color: #fff; border: none; border-radius: 8px; padding: .65rem; font-size: .85rem; font-weight: 600; cursor: pointer; transition: background .2s; }
.btn-new-chat:hover { background: var(--blue-hover); }

/* Chat list */
.chat-list    { flex: 1; overflow-y: auto; padding: 0 .5rem; }
.chat-item    { display: flex; align-items: center; gap: .5rem; padding: .6rem .75rem; border-radius: 8px; cursor: pointer; margin-bottom: 2px; transition: background .15s; color: var(--text-muted); font-size: .8rem; }
.chat-item:hover   { background: var(--bg3); color: var(--text); }
.chat-item.active  { background: var(--border); color: var(--text); }
.chat-item-icon    { flex-shrink: 0; font-size: .9rem; }
.chat-item-title   { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item-del     { opacity: 0; font-size: 1.1rem; line-height: 1; color: var(--text-dim); background: none; border: none; cursor: pointer; padding: 0 2px; transition: all .15s; flex-shrink: 0; }
.chat-item:hover .chat-item-del { opacity: 1; }
.chat-item-del:hover { color: #f87171; }

/* Recursos */
.sidebar-recursos { border-top: 1px solid var(--border); padding: .6rem; }
.recursos-toggle  { width: 100%; display: flex; align-items: center; justify-content: space-between; background: none; border: none; color: var(--text-muted); font-size: .78rem; padding: .4rem .5rem; border-radius: 6px; cursor: pointer; transition: color .15s; }
.recursos-toggle:hover { color: var(--text); }
.recursos-menu  { margin-top: 2px; }
.recurso-item   { display: flex; align-items: center; gap: .5rem; font-size: .78rem; color: var(--text-dim); padding: .4rem .5rem; border-radius: 6px; text-decoration: none; transition: all .15s; }
.recurso-item:hover { color: var(--text); background: var(--border); }

/* Cuota */
.cuota-bar   { border-top: 1px solid var(--border); padding: .75rem; }
.cuota-label { display: flex; justify-content: space-between; font-size: .72rem; color: var(--text-dim); margin-bottom: .4rem; }
.cuota-track { background: var(--border); border-radius: 99px; height: 4px; }
.cuota-fill  { background: var(--blue); height: 4px; border-radius: 99px; transition: width .3s, background .3s; }
.cuota-fill.warn   { background: #f59e0b; }
.cuota-fill.danger { background: #f87171; }

/* Usuario */
.user-panel  { border-top: 1px solid var(--border); padding: .75rem; display: flex; align-items: center; gap: .6rem; }
.user-avatar { width: 32px; height: 32px; background: var(--blue); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; flex-shrink: 0; }
.user-info   { flex: 1; min-width: 0; }
.user-name   { font-size: .8rem; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-rol    { font-size: .72rem; color: var(--text-dim); text-transform: capitalize; }
.btn-logout  { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: .9rem; transition: color .15s; flex-shrink: 0; }
.btn-logout:hover { color: #f87171; }

.admin-link  { border-top: 1px solid var(--border); padding: .6rem; text-align: center; }
.admin-link a { font-size: .75rem; color: var(--text-dim); text-decoration: none; transition: color .15s; }
.admin-link a:hover { color: var(--blue); }

/* ── MAIN ───────────────────────── */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.main-header    { border-bottom: 1px solid var(--border); padding: .75rem 1.5rem; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.header-left    { display: flex; align-items: center; gap: .6rem; }
.header-dot     { width: 8px; height: 8px; background: #22c55e; border-radius: 50%; }
.header-title   { font-size: .9rem; font-weight: 600; color: var(--text); }
.header-actions { display: flex; gap: .5rem; }
.header-btn     { font-size: .75rem; color: var(--text-dim); border: 1px solid var(--border2); border-radius: 6px; padding: .3rem .65rem; text-decoration: none; transition: all .15s; }
.header-btn:hover { color: var(--text); border-color: var(--text-muted); }

/* Mensajes */
.messages { flex: 1; overflow-y: auto; padding: 1.5rem; display: flex; flex-direction: column; gap: 1.25rem; }

/* Welcome */
.welcome         { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; flex: 1; padding: 2rem; }
.welcome-icon    { font-size: 4rem; margin-bottom: 1rem; }
.welcome h2      { font-size: 1.3rem; font-weight: 700; margin-bottom: .6rem; }
.welcome p       { color: var(--text-muted); font-size: .9rem; max-width: 480px; line-height: 1.6; margin-bottom: 1.25rem; }
.welcome-tags    { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin-bottom: 1.25rem; }
.welcome-tags span { font-size: .78rem; background: var(--bg3); border: 1px solid var(--border2); color: var(--text-muted); border-radius: 99px; padding: .3rem .9rem; }
.welcome-disclaimer { font-size: .78rem; color: var(--text-dim); max-width: 400px; line-height: 1.5; }

/* Burbujas */
.msg          { display: flex; align-items: flex-start; }
.msg.user     { justify-content: flex-end; }
.msg.ai       { justify-content: flex-start; }

.msg-avatar   { width: 28px; height: 28px; background: #2a7cff22; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .8rem; margin-right: .65rem; flex-shrink: 0; margin-top: 2px; }

.msg-bubble { max-width: 72%; border-radius: 16px; padding: .85rem 1.1rem; font-size: .88rem; line-height: 1.6; }
.msg.user .msg-bubble { background: var(--blue); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai   .msg-bubble { background: var(--bg3); border: 1px solid var(--border2); border-bottom-left-radius: 4px; }

.msg-fuentes  { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .6rem; padding-top: .6rem; border-top: 1px solid var(--border2); }
.fuente-badge { font-size: .72rem; background: var(--bg); color: var(--blue); border-radius: 4px; padding: .15rem .5rem; }

/* Typing */
.msg-typing .msg-bubble { padding: .75rem 1.1rem; }
.typing-dots { display: flex; gap: 4px; align-items: center; }
.typing-dots span { width: 7px; height: 7px; background: var(--blue); border-radius: 50%; animation: bounce 1s infinite; }
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%,100%{transform:translateY(0)}50%{transform:translateY(-5px)} }

/* Respuestas HTML de Claude */
.ia-html h2      { font-size: 1rem; font-weight: 600; color: var(--text); margin: 1rem 0 .4rem; }
.ia-html h2:first-child { margin-top: 0; }
.ia-html p       { color: #b0b8cc; line-height: 1.7; margin-bottom: .5rem; }
.ia-html ul      { padding-left: 1.3rem; margin-bottom: .6rem; }
.ia-html li      { color: #b0b8cc; line-height: 1.7; margin-bottom: .2rem; }
.ia-html strong  { color: var(--text); }
.ia-html em      { color: var(--text-dim); font-size: .85rem; }

/* Error burbuja */
.msg-error .msg-bubble { background: #f871711a; border-color: #f8717144; color: #f87171; }

/* Input */
.input-area       { border-top: 1px solid var(--border); padding: 1rem 1.5rem; flex-shrink: 0; }
.input-box        { display: flex; align-items: flex-end; gap: .65rem; background: var(--bg3); border: 1px solid var(--border2); border-radius: 16px; padding: .75rem 1rem; transition: border-color .2s; }
.input-box:focus-within { border-color: var(--blue); }
.input-box textarea { flex: 1; background: transparent; border: none; color: var(--text); font-size: .88rem; resize: none; outline: none; line-height: 1.5; max-height: 160px; font-family: inherit; }
.input-box textarea::placeholder { color: var(--text-dim); }
.btn-send  { background: var(--blue); color: #fff; border: none; border-radius: 10px; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; transition: background .2s; font-size: .9rem; }
.btn-send:hover    { background: var(--blue-hover); }
.btn-send:disabled { opacity: .4; cursor: not-allowed; }
.input-disclaimer  { font-size: .72rem; color: var(--text-dim); text-align: center; margin-top: .5rem; }
