/* Chat TR - identidad GRTR: rojo taller / negro acero */
:root {
    --rojo: #C8102E;
    --rojo-oscuro: #9B0C23;
    --negro: #17181C;
    --acero: #24262C;
    --humo: #EFEDE9;
    --papel: #FFFFFF;
    --tinta: #1C1D21;
    --gris: #6B6E76;
    --linea: #DCDAD5;
    --verde: #1F9D55;
    --radio: 10px;
    --fuente: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body { font-family: var(--fuente); background: var(--humo); color: var(--tinta); font-size: 15px; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 15px; }

/* ---------- Marca ---------- */
.brand-mark {
    font-weight: 900; letter-spacing: .06em; font-size: 30px; color: #fff;
    text-transform: uppercase; line-height: 1;
}
.brand-mark span { color: var(--rojo); margin-left: 4px; }
.brand-mark.small { font-size: 20px; }
.brand-mark.ghost { color: var(--linea); font-size: 44px; }
.brand-mark.ghost span { color: #E7B7BF; }

/* ---------- Login ---------- */
.login-body {
    min-height: 100%; display: flex; align-items: center; justify-content: center;
    background:
        linear-gradient(135deg, var(--negro) 0 55%, transparent 55.2%),
        linear-gradient(315deg, var(--rojo) 0 12%, transparent 12.2%),
        var(--humo);
    padding: 24px;
}
.login-card {
    width: 100%; max-width: 400px; background: var(--papel); border-radius: 14px;
    padding: 28px; box-shadow: 0 18px 50px rgba(0,0,0,.35);
    border-top: 6px solid var(--rojo);
}
.brand-block { margin-bottom: 18px; }
.login-card .brand-mark { color: var(--negro); }
.brand-sub { color: var(--gris); font-size: 12.5px; margin-top: 6px; text-transform: uppercase; letter-spacing: .08em; }
.login-title { font-size: 19px; margin: 8px 0 4px; }
.login-hint { color: var(--gris); font-size: 13.5px; margin: 0 0 12px; }
.login-card label { display: block; font-size: 13px; font-weight: 600; color: var(--acero); margin: 12px 0 4px; }
.login-card input {
    width: 100%; margin-top: 4px; padding: 11px 12px; border: 1.5px solid var(--linea);
    border-radius: 8px; background: #FAFAF8;
}
.login-card input:focus { outline: 2px solid var(--rojo); outline-offset: 1px; border-color: var(--rojo); }
.btn-primary {
    width: 100%; margin-top: 18px; padding: 12px; border: 0; border-radius: 8px;
    background: var(--rojo); color: #fff; font-weight: 700; font-size: 15px;
    text-transform: uppercase; letter-spacing: .05em;
}
.btn-primary:hover { background: var(--rojo-oscuro); }
.login-error { background: #FBE9EC; color: var(--rojo-oscuro); border: 1px solid #F0BFC8; padding: 9px 12px; border-radius: 8px; font-size: 13.5px; margin-bottom: 6px; }
.login-notice { margin-top: 20px; font-size: 12px; color: var(--gris); border-top: 1px dashed var(--linea); padding-top: 12px; }

/* ---------- Layout general ---------- */
#app { display: flex; height: 100dvh; overflow: hidden; }

#sidebar {
    width: 330px; min-width: 330px; background: var(--negro); color: #E9E8E6;
    display: flex; flex-direction: column;
}
.side-head { padding: 16px 16px 12px; border-bottom: 1px solid #2E3037; }
.side-user { margin-top: 10px; display: flex; align-items: center; gap: 8px; }
.side-user-name { font-weight: 600; }
.role-chip {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700;
    padding: 2px 8px; border-radius: 99px; background: #3A3D45; color: #CFD1D6;
}
.role-chip.role-admin { background: var(--rojo); color: #fff; }
.role-chip.role-lider { background: #D89A18; color: #1E1500; }
.side-links { margin-top: 8px; display: flex; gap: 14px; }
.side-links a { color: #B9BBC2; font-size: 13px; text-decoration: none; }
.side-links a:hover { color: #fff; text-decoration: underline; }

.side-actions { display: flex; gap: 8px; padding: 12px 14px; }
.side-actions button {
    flex: 1; padding: 9px 8px; border-radius: 8px; border: 1.5px solid #3A3D45;
    background: transparent; color: #E9E8E6; font-weight: 600; font-size: 13px;
}
.side-actions button:hover { border-color: var(--rojo); color: #fff; }

.conv-list { flex: 1; overflow-y: auto; padding: 4px 8px 8px; }
.conv-item {
    display: flex; gap: 10px; align-items: center; width: 100%; text-align: left;
    background: transparent; border: 0; color: #E9E8E6; padding: 10px; border-radius: 9px;
}
.conv-item:hover { background: #23252B; }
.conv-item.active { background: #2C2E35; box-shadow: inset 3px 0 0 var(--rojo); }
.conv-avatar {
    width: 42px; height: 42px; border-radius: 10px; background: var(--acero); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px;
    flex-shrink: 0;
}
.conv-avatar.group { background: var(--rojo-oscuro); }
.conv-body { flex: 1; min-width: 0; }
.conv-name { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-preview { color: #9A9DA5; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.conv-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.conv-time { font-size: 11px; color: #85888F; }
.badge {
    min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--rojo);
    color: #fff; font-size: 11.5px; font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.side-foot { padding: 10px 14px; font-size: 10.5px; color: #7B7E86; border-top: 1px solid #2E3037; }
.empty-hint { color: var(--gris); font-size: 13px; padding: 14px; text-align: center; }
.conv-list .empty-hint { color: #85888F; }

/* ---------- Panel de chat ---------- */
.chat-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--humo); }
.chat-empty { flex: 1; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center; color: var(--gris); }
.chat-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.chat-head {
    display: flex; align-items: center; gap: 10px; padding: 10px 16px;
    background: var(--papel); border-bottom: 2px solid var(--rojo);
}
.chat-head-info { flex: 1; min-width: 0; }
.chat-title { font-weight: 800; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-sub { font-size: 12px; color: var(--gris); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
    border: 1.5px solid var(--linea); background: #fff; border-radius: 8px;
    width: 38px; height: 38px; font-size: 17px; color: var(--acero); flex-shrink: 0;
}
.icon-btn:hover { border-color: var(--rojo); color: var(--rojo); }
.icon-btn.back { display: none; }

.msg-list { flex: 1; overflow-y: auto; padding: 18px 16px 10px; display: flex; flex-direction: column; gap: 4px; }
.day-sep { align-self: center; font-size: 11.5px; font-weight: 700; color: var(--gris); background: #E2E0DB; padding: 3px 12px; border-radius: 99px; margin: 12px 0 6px; text-transform: uppercase; letter-spacing: .05em; }
.msg { max-width: min(72%, 560px); display: flex; flex-direction: column; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg-sender { font-size: 11.5px; font-weight: 700; color: var(--rojo-oscuro); margin: 8px 4px 2px; }
.msg-bubble {
    background: var(--papel); border-radius: var(--radio); padding: 8px 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,.08); white-space: pre-wrap; word-wrap: break-word;
    border-bottom-left-radius: 3px;
}
.msg.mine .msg-bubble {
    background: var(--negro); color: #F2F1EF; border-bottom-left-radius: var(--radio);
    border-bottom-right-radius: 3px; box-shadow: inset 0 -2px 0 var(--rojo), 0 1px 2px rgba(0,0,0,.15);
}
.msg-bubble img, .msg-bubble video { max-width: 100%; border-radius: 7px; display: block; }
.msg-bubble.media { padding: 4px; background: var(--papel); }
.msg.mine .msg-bubble.media { background: var(--negro); }
.msg-bubble.sticker { background: transparent; box-shadow: none; padding: 0; }
.msg-bubble.sticker img { max-width: 140px; max-height: 140px; }
.msg-caption { padding: 6px 8px 4px; }
.msg-time { font-size: 10.5px; color: var(--gris); margin: 3px 6px 4px; }
.msg img.chat-img { cursor: zoom-in; max-height: 320px; }
.file-chip {
    display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit;
    padding: 6px 8px;
}
.file-chip .file-ico { width: 36px; height: 36px; border-radius: 8px; background: var(--rojo); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 10px; }
.file-chip .file-nm { font-weight: 600; font-size: 13.5px; word-break: break-all; }
.file-chip .file-sz { font-size: 11.5px; color: var(--gris); }
.msg.mine .file-chip .file-sz { color: #A9ACB3; }

.composer {
    display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px;
    background: var(--papel); border-top: 1px solid var(--linea);
}
.composer textarea {
    flex: 1; resize: none; border: 1.5px solid var(--linea); border-radius: 10px;
    padding: 10px 12px; max-height: 120px; background: #FAFAF8;
}
.composer textarea:focus { outline: 2px solid var(--rojo); border-color: var(--rojo); }
.send-btn {
    border: 0; background: var(--rojo); color: #fff; font-weight: 800; text-transform: uppercase;
    letter-spacing: .04em; border-radius: 10px; padding: 0 18px; height: 42px; font-size: 13px;
}
.send-btn:hover { background: var(--rojo-oscuro); }
.upload-bar { padding: 6px 14px; background: #FFF6D9; color: #6B5400; font-size: 13px; border-top: 1px solid #EFDFA0; }

/* ---------- Paneles y modales ---------- */
.panel {
    position: fixed; right: 16px; bottom: 76px; width: 320px; max-height: 420px;
    background: var(--papel); border-radius: 12px; box-shadow: 0 14px 40px rgba(0,0,0,.3);
    display: flex; flex-direction: column; overflow: hidden; z-index: 40;
    border: 1px solid var(--linea);
}
.panel-head { padding: 10px 14px; font-weight: 800; display: flex; justify-content: space-between; align-items: center; background: var(--negro); color: #fff; }
.panel-close { border: 0; background: transparent; color: inherit; font-size: 20px; line-height: 1; }
.sticker-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 12px; }
.sticker-grid button { border: 1px solid var(--linea); background: #FAFAF8; border-radius: 10px; padding: 6px; }
.sticker-grid button:hover { border-color: var(--rojo); }
.sticker-grid img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.emoji-row { display: flex; flex-wrap: wrap; gap: 2px; padding: 8px 10px; border-top: 1px solid var(--linea); }
.emoji-row button { border: 0; background: transparent; font-size: 21px; padding: 3px; border-radius: 6px; }
.emoji-row button:hover { background: var(--humo); }

.modal { position: fixed; inset: 0; background: rgba(15,16,20,.55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 18px; }
.modal-card {
    width: 100%; max-width: 420px; max-height: 82dvh; background: var(--papel); border-radius: 14px;
    padding: 16px; display: flex; flex-direction: column; gap: 10px; overflow: hidden;
    border-top: 5px solid var(--rojo);
}
.modal-head { font-weight: 800; font-size: 16px; display: flex; justify-content: space-between; align-items: center; }
.modal-card input[type="search"], .modal-card input[type="text"] {
    padding: 10px 12px; border: 1.5px solid var(--linea); border-radius: 8px; width: 100%; background: #FAFAF8;
}
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--acero); }
.field-label { font-size: 13px; font-weight: 700; color: var(--acero); }
.user-pick-list { overflow-y: auto; display: flex; flex-direction: column; gap: 4px; min-height: 60px; }
.user-pick-list button, .user-pick-list label.pick {
    display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px;
    border: 1px solid var(--linea); background: #fff; text-align: left; font-size: 14px;
}
.user-pick-list button:hover { border-color: var(--rojo); background: #FDF6F7; }
.pick-role { margin-left: auto; font-size: 10.5px; color: var(--gris); text-transform: uppercase; font-weight: 700; }
.mini-x { margin-left: auto; border: 0; background: #F1EFEA; border-radius: 6px; width: 26px; height: 26px; }

.lightbox { position: fixed; inset: 0; background: rgba(10,10,12,.9); display: flex; align-items: center; justify-content: center; z-index: 60; cursor: zoom-out; }
.lightbox img { max-width: 94vw; max-height: 92dvh; border-radius: 8px; }

/* ---------- Consola de administración ---------- */
.admin-body { background: var(--humo); min-height: 100dvh; }
.admin-top {
    background: var(--negro); color: #fff; padding: 14px 20px; display: flex; align-items: center; gap: 18px;
    border-bottom: 4px solid var(--rojo); flex-wrap: wrap;
}
.admin-top a { color: #C6C8CE; text-decoration: none; font-size: 13.5px; }
.admin-top a:hover { color: #fff; }
.admin-tabs { display: flex; gap: 6px; padding: 14px 20px 0; flex-wrap: wrap; }
.admin-tabs button {
    border: 0; background: #E4E2DD; padding: 10px 16px; border-radius: 9px 9px 0 0;
    font-weight: 700; color: var(--acero); font-size: 13.5px;
}
.admin-tabs button.active { background: var(--papel); color: var(--rojo); box-shadow: inset 0 3px 0 var(--rojo); }
.admin-wrap { padding: 0 20px 30px; }
.admin-panel { background: var(--papel); border-radius: 0 12px 12px 12px; padding: 18px; box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.admin-panel[hidden] { display: none; }
.admin-grid { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
.admin-card { border: 1px solid var(--linea); border-radius: 10px; padding: 14px; }
.admin-card h3 { margin: 0 0 10px; font-size: 15px; }
.admin-card label { display: block; font-size: 12.5px; font-weight: 700; color: var(--acero); margin: 10px 0 3px; }
.admin-card input, .admin-card select {
    width: 100%; padding: 9px 10px; border: 1.5px solid var(--linea); border-radius: 8px; background: #FAFAF8;
}
.btn-sm {
    border: 1.5px solid var(--linea); background: #fff; border-radius: 7px; padding: 6px 10px;
    font-size: 12.5px; font-weight: 700; color: var(--acero);
}
.btn-sm:hover { border-color: var(--rojo); color: var(--rojo); }
.btn-red { border: 0; background: var(--rojo); color: #fff; border-radius: 8px; padding: 10px 14px; font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: .03em; }
.btn-red:hover { background: var(--rojo-oscuro); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th { text-align: left; padding: 8px 10px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--gris); border-bottom: 2px solid var(--linea); }
table.tbl td { padding: 9px 10px; border-bottom: 1px solid #EAE8E3; vertical-align: middle; }
table.tbl tr.inactive td { opacity: .5; }
.pw-reveal { background: #FFF6D9; border: 1px solid #EFDFA0; padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-top: 10px; word-break: break-all; }
.sup-layout { display: grid; grid-template-columns: 380px 1fr; gap: 16px; align-items: start; }
.sup-list { max-height: 68dvh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.sup-item { text-align: left; border: 1px solid var(--linea); background: #fff; border-radius: 9px; padding: 10px 12px; }
.sup-item:hover { border-color: var(--rojo); }
.sup-item.active { border-color: var(--rojo); box-shadow: inset 3px 0 0 var(--rojo); }
.sup-item .nm { font-weight: 700; font-size: 14px; }
.sup-item .mm { font-size: 12px; color: var(--gris); margin-top: 2px; }
.sup-view { border: 1px solid var(--linea); border-radius: 10px; display: flex; flex-direction: column; max-height: 68dvh; min-height: 320px; }
.sup-view-head { padding: 10px 14px; background: var(--negro); color: #fff; border-radius: 10px 10px 0 0; font-weight: 700; font-size: 14px; }
.sup-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 4px; background: var(--humo); border-radius: 0 0 10px 10px; }
.sticker-admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; }
.sticker-admin-grid .stk { border: 1px solid var(--linea); border-radius: 10px; padding: 8px; text-align: center; }
.sticker-admin-grid img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.stk.off img { filter: grayscale(1); opacity: .4; }
.stk .stk-nm { font-size: 12px; font-weight: 600; margin: 6px 0; }

/* ---------- Móvil ---------- */
@media (max-width: 760px) {
    #sidebar { width: 100%; min-width: 0; }
    .chat-pane { display: none; }
    body.chat-open #sidebar { display: none; }
    body.chat-open .chat-pane { display: flex; }
    .icon-btn.back { display: flex; align-items: center; justify-content: center; }
    .msg { max-width: 86%; }
    .panel { left: 12px; right: 12px; width: auto; }
    .admin-grid, .sup-layout { grid-template-columns: 1fr; }
    .brand-mark.ghost { font-size: 34px; }
}
@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}
[hidden] { display: none !important; }
