/* LH by MOV — Panel CRM (pixel-matched al diseño de bandeja) */

html, body {
    height: 100%;
    background: #fff;
    font-family: var(--font-display);
    overflow: hidden;
}

button, input { font-family: var(--font-display); }

/* ============ TOPBAR ============ */

.topbar {
    height: 78px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 28px;
    background: linear-gradient(90deg, #cac6c6 0%, #ffffff 50%, #cac6c6 100%);
    position: relative;
    z-index: 5;
}

.topbar-left { }

.topbar-logo {
    display: flex;
    align-items: center;
    justify-content: center;
}
.topbar-logo img {
    width: 72px;
    height: 72px;
    object-fit: contain;
    background: #fff;
    border-radius: 50%;
    padding: 8px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.12);
    margin-top: 18px;
}

.topbar-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 22px;
    font-size: 13px;
    color: #666363;
}

.status-chip { display: flex; align-items: center; gap: 6px; font-weight: 600; color: #454242; }
.dot-online {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--online-green);
    box-shadow: 0 0 0 3px rgba(43,228,13,0.18);
}

.status-select {
    display: flex; align-items: center; gap: 5px;
    color: #454242; font-weight: 500;
    cursor: default;
}
.status-select .chev, .status-select svg { color: var(--brand-red); }

.role-chip { font-weight: 700; color: var(--text-dark); letter-spacing: 0.02em; }

.btn-salir {
    background: var(--brand-navy);
    color: #fff;
    border: none;
    padding: 9px 22px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.02em;
    cursor: pointer;
}
.btn-salir:hover { background: var(--brand-navy-hover); }

/* ============ LAYOUT ============ */

.app-body {
    height: calc(100vh - 78px);
    display: grid;
    grid-template-columns: 252px 372px 1fr 330px;
    overflow: hidden;
}

.app-body.panel-collapsed { grid-template-columns: 252px 372px 1fr 0; }
.app-body.sidebar-collapsed { grid-template-columns: 0 372px 1fr 330px; }

/* ============ SIDEBAR ============ */

.sidebar {
    background: linear-gradient(135deg, var(--brand-red) 0%, var(--brand-navy) 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.15s ease;
}

.sidebar-topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 18px 14px;
}
.sidebar-title { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; letter-spacing: 0.01em; }
.sidebar-title .bar { width: 4px; height: 18px; background: #fff; border-radius: 2px; display: inline-block; }
.sidebar-toggle { background: none; border: none; color: #fff; font-size: 16px; cursor: pointer; opacity: 0.85; }
.sidebar-toggle:hover { opacity: 1; }

.sidebar-nav { padding: 0 16px 24px; display: flex; flex-direction: column; gap: 4px; }

.nav-item {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 8px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    color: rgba(255,255,255,0.92);
}
.nav-item:hover { background: rgba(255,255,255,0.08); }
.nav-item.active { background: rgba(255,255,255,0.14); }
.nav-item .nav-label { flex: 1; }
.nav-item .nav-count {
    background: rgba(255,255,255,0.18);
    font-size: 11px; font-weight: 700;
    padding: 1px 8px; border-radius: 999px;
}
.nav-item.is-todas { margin-bottom: 2px; background: #fff; color: var(--brand-navy); }
.nav-item.is-todas .bar { width: 4px; height: 14px; background: var(--brand-navy); border-radius: 2px; }
.nav-item.is-todas .nav-count { background: #eef1f7; color: var(--brand-navy); }
.nav-item.is-todas:hover { background: #fff; }

.nav-item.sub { padding-left: 8px; font-weight: 500; }

.search-box { margin: 6px 0 10px; }
.search-box input {
    width: 100%;
    background: var(--input-bg);
    border: none;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 12px;
    color: var(--text-dark);
    outline: none;
}
.search-box input::placeholder { color: var(--placeholder); }

.filtros-box {
    background: rgba(0,0,0,0.14);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 10px;
}
.filtros-hdr {
    width: 100%;
    display: flex; align-items: center; justify-content: space-between;
    background: none; border: none; color: #fff;
    font-size: 12px; font-weight: 700; letter-spacing: 0.03em;
    padding: 2px 0 8px; cursor: pointer;
}
.filtros-hdr .chev { transition: transform 0.15s ease; }
.filtros-box.collapsed .filtros-hdr .chev { transform: rotate(-90deg); }
.filtros-box.collapsed .filtros-body { display: none; }

.filtro-row, .filtro-sub {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 4px;
    font-size: 12.5px; font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
}
.filtro-row:hover, .filtro-sub:hover { background: rgba(255,255,255,0.08); }
.filtro-row.active, .filtro-sub.active { background: rgba(255,255,255,0.16); }
.filtro-row span:first-child { flex: 1; }
.filtro-sub { padding-left: 14px; font-weight: 500; font-size: 11.5px; opacity: 0.92; }
.filtro-sub span:first-child { flex: 1; }
.filtro-row-mov { margin-top: 2px; }

.pill-count {
    background: var(--brand-navy);
    color: #fff;
    font-size: 10.5px; font-weight: 700;
    min-width: 22px; text-align: center;
    padding: 2px 6px; border-radius: 999px;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.25) inset;
}

.section-pill {
    background: #fff;
    color: var(--text-dark);
    border: none;
    border-radius: 999px;
    padding: 10px 16px;
    font-size: 12.5px; font-weight: 800; letter-spacing: 0.03em;
    text-align: left;
    margin-top: 10px;
    cursor: pointer;
}
.section-pill:hover { background: #f2f2f2; }
.section-pill.active { background: #fff; box-shadow: 0 0 0 2px var(--brand-red) inset; }

.section-body { display: flex; flex-direction: column; gap: 2px; margin: 2px 4px 0; }

/* ============ BANDEJA (lista) ============ */

.convlist-panel {
    background: #fff;
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.convlist-header {
    display: flex; align-items: center; gap: 10px;
    padding: 18px 20px;
    background: var(--panel-bg);
}
.convlist-header .bar { width: 4px; height: 18px; background: var(--brand-navy); border-radius: 2px; }
.convlist-title { font-weight: 800; font-size: 17px; color: var(--brand-navy); letter-spacing: 0.01em; flex: 1; }
.btn-add {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--brand-navy); color: #fff; border: none;
    font-size: 17px; line-height: 1; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.convlist-count { color: #9b9797; font-size: 13px; font-weight: 600; }

.conv-list { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }

.conv-item {
    background: var(--card-bg-pink);
    border-radius: 18px;
    padding: 14px 16px;
    cursor: pointer;
    border: 2px solid transparent;
}
.conv-item:hover { filter: brightness(0.99); }
.conv-item.selected { border-color: var(--brand-navy); }
.conv-item.unread .conv-item-name { font-weight: 800; }

.conv-item-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.conv-item-name { font-weight: 700; font-size: 15px; color: var(--text-dark); }
.conv-item-time { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #8a8686; white-space: nowrap; }
.conv-item-time .dot-unread { width: 8px; height: 8px; border-radius: 50%; background: #e11d3a; }

.conv-item-preview { font-size: 13px; color: #4a4646; font-weight: 600; margin: 4px 0 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.conv-item-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    background: var(--chip-bg);
    color: #7a2430;
    font-size: 10.5px; font-weight: 700;
    padding: 4px 10px; border-radius: 999px;
    white-space: nowrap;
}

.empty-state { padding: 40px 20px; text-align: center; color: #a19d9d; font-size: 13px; }

/* ============ CHAT ============ */

.chat-panel { background: #fff; display: flex; flex-direction: column; overflow: hidden; position: relative; }

.chat-empty {
    flex: 1; display: flex; align-items: center; justify-content: center;
    color: #b3afaf; font-size: 14px;
}

.chat-active { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.chat-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 26px;
    border-bottom: 1px solid var(--line);
}
.chat-name { font-weight: 800; font-size: 20px; color: var(--text-dark); }
.chat-meta { display: flex; gap: 14px; margin-top: 4px; font-size: 12.5px; color: #8a8686; font-weight: 500; }
.chat-header-actions { display: flex; gap: 10px; }

.icon-btn {
    width: 34px; height: 34px; border-radius: 50%;
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; color: #fff;
}
.icon-btn.dark { background: #2b2929; }
.icon-btn.red { background: #d81c3f; }
.icon-btn:hover { filter: brightness(1.12); }

.chat-body {
    flex: 1; overflow-y: auto;
    padding: 22px 26px;
    display: flex; flex-direction: column; gap: 10px;
    background: #fff;
}

.day-separator {
    align-self: center;
    background: var(--panel-bg);
    color: #948f8f;
    font-size: 11px; font-weight: 700; text-transform: capitalize;
    padding: 4px 14px; border-radius: 999px;
    margin: 8px 0;
}

.msg { max-width: 60%; padding: 10px 14px; border-radius: 14px; font-size: 13.5px; line-height: 1.45; position: relative; }
.msg-entrante { align-self: flex-start; background: var(--panel-bg); color: var(--text-dark); border-bottom-left-radius: 4px; }
.msg-saliente { align-self: flex-end; background: var(--brand-navy); color: #fff; border-bottom-right-radius: 4px; }
.msg-meta { font-size: 10.5px; opacity: 0.65; margin-top: 4px; text-align: right; }

.chat-composer {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 26px;
    border-top: 1px solid var(--line);
}
.chat-composer input {
    flex: 1; height: 44px; border: none; border-radius: 999px;
    background: var(--input-bg); padding: 0 18px; font-size: 13.5px;
    color: var(--text-dark); outline: none;
}
.chat-composer input::placeholder { color: var(--placeholder); }
.chat-composer button {
    background: var(--brand-navy); color: #fff; border: none;
    padding: 12px 26px; border-radius: 999px; font-weight: 800;
    font-size: 12.5px; letter-spacing: 0.03em; cursor: pointer;
}
.chat-composer button:hover { background: var(--brand-navy-hover); }
.chat-composer button:disabled { opacity: 0.5; cursor: default; }

/* ============ PANEL CLIENTE ============ */

.client-panel {
    background: var(--panel-bg);
    padding: 22px 26px;
    overflow-y: auto;
    position: relative;
}
.panel-close {
    width: 30px; height: 30px; border-radius: 50%;
    background: #2b2929; color: #fff; border: none;
    font-size: 13px; cursor: pointer; margin-bottom: 18px;
}
.panel-title { color: var(--brand-navy); font-size: 17px; font-weight: 800; margin: 0 0 18px; }

.panel-row { font-size: 13.5px; color: #4a4646; margin-bottom: 15px; line-height: 1.4; }
.panel-row b { color: var(--text-dark); font-weight: 700; }
.panel-empty { color: #a19d9d; font-size: 13px; }

.panel-assign-label { font-weight: 800; color: var(--text-dark); font-size: 13.5px; margin: 22px 0 8px; }
.panel-select {
    width: 100%; height: 42px; border-radius: 10px;
    border: 1px solid #ddd8d8; background: #fff;
    padding: 0 14px; font-size: 13.5px; color: var(--text-dark);
    outline: none; cursor: pointer;
}

/* ============ VISTAS GENÉRICAS ============ */

.generic-view {
    grid-column: 2 / span 3;
    background: #fff;
    display: flex; flex-direction: column; overflow: hidden;
    border-left: 1px solid var(--line);
}
.generic-header { display: flex; align-items: center; gap: 10px; padding: 18px 26px; background: var(--panel-bg); }
.generic-header .bar { width: 4px; height: 18px; background: var(--brand-navy); border-radius: 2px; }
.generic-title { font-weight: 800; font-size: 17px; color: var(--brand-navy); flex: 1; }
.generic-body { flex: 1; overflow-y: auto; padding: 24px 30px; }

.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th { text-align: left; color: #948f8f; font-weight: 700; font-size: 11.5px; letter-spacing: 0.03em; text-transform: uppercase; padding: 10px 12px; border-bottom: 2px solid var(--line); }
.data-table td { padding: 12px; border-bottom: 1px solid var(--line); color: var(--text-dark); }
.data-table tr:hover td { background: #fafafa; }

.btn-mini {
    border: none; border-radius: 999px; padding: 6px 14px;
    font-size: 11.5px; font-weight: 700; cursor: pointer;
}
.btn-mini.primary { background: var(--brand-navy); color: #fff; }
.btn-mini.ghost { background: var(--panel-bg); color: var(--text-dark); }

.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card { background: var(--panel-bg); border-radius: 14px; padding: 18px 20px; }
.stat-card .label { font-size: 11.5px; font-weight: 700; color: #948f8f; letter-spacing: 0.03em; text-transform: uppercase; }
.stat-card .value { font-size: 28px; font-weight: 800; color: var(--brand-navy); margin-top: 6px; }

/* ============ TOASTS ============ */

.toast-container { position: fixed; top: 90px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast {
    background: #fff; border-radius: 12px; padding: 12px 16px;
    box-shadow: 0 12px 28px rgba(0,0,0,0.18);
    min-width: 220px; max-width: 320px;
    border-left: 4px solid var(--brand-navy);
    animation: toast-in 0.2s ease;
}
.toast.error { border-left-color: var(--brand-red); }
.toast-title { font-weight: 700; font-size: 13px; color: var(--text-dark); }
.toast-body { font-size: 12px; color: #6b6767; margin-top: 2px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

/* ============ SCROLLBARS ============ */

.sidebar::-webkit-scrollbar, .conv-list::-webkit-scrollbar, .chat-body::-webkit-scrollbar,
.client-panel::-webkit-scrollbar, .generic-body::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.25); border-radius: 4px; }
.conv-list::-webkit-scrollbar-thumb, .chat-body::-webkit-scrollbar-thumb,
.client-panel::-webkit-scrollbar-thumb, .generic-body::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

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

@media (max-width: 1280px) {
    .app-body { grid-template-columns: 220px 320px 1fr 290px; }
}
