/* ============================================================
   WebC WA - Estilos del panel (BEM sobre Bootstrap 5)
   ============================================================ */

:root {
    --theme-font: "Poppins", sans-serif;
    --theme-gray: #808080;
    --theme-white: #ffffff;
    --theme-base: #A634ED;
    --theme-base-rgb: 166, 52, 237;
    --theme-black: #191919;
    --theme-primary: #EDAB32;
    --theme-primary-rgb: 237, 171, 50;
    --theme-secundary: #22383f;
    --theme-secundary-rgb: 34, 56, 63;
    --theme-bdr-color: #e0dcd3;
    --theme-bg: #f5f3f8;
}

*:focus-visible {
    outline: 3px solid rgba(var(--theme-base-rgb), 0.55);
    outline-offset: 2px;
    border-radius: 4px;
}

body {
    font-family: var(--theme-font);
    background-color: var(--theme-bg);
    color: var(--theme-black);
}

/* ---------- Auth ---------- */
.wcwa-auth-body {
    background: linear-gradient(135deg, var(--theme-secundary) 0%, #16262b 100%);
    min-height: 100vh;
}

.wcwa-auth {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.wcwa-auth__card {
    width: 100%;
    max-width: 420px;
    background: var(--theme-white);
    border-radius: 16px;
    padding: 32px 28px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.wcwa-auth__brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 24px;
}

.wcwa-auth__brand-icon {
    font-size: 30px;
    color: var(--theme-base);
}

.wcwa-auth__brand-name {
    font-weight: 700;
    font-size: 1.4rem;
    color: var(--theme-secundary);
}

.wcwa-auth__title {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.wcwa-auth__subtitle {
    color: var(--theme-gray);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

/* ---------- Shell ---------- */
.wcwa-shell {
    display: flex;
    min-height: 100vh;
}

.wcwa-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.wcwa-content {
    flex: 1;
    background: var(--theme-bg);
}

/* ---------- Sidebar ---------- */
.wcwa-sidebar {
    width: 260px;
    background: var(--theme-secundary);
    color: #dde5e8;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1040;
    transition: transform 0.25s ease;
}

.wcwa-sidebar__brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.wcwa-sidebar__brand-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--theme-white);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.15rem;
}

.wcwa-sidebar__brand-icon {
    color: var(--theme-base);
    font-size: 24px;
}

.wcwa-sidebar__toggle {
    background: transparent;
    border: 0;
    color: var(--theme-white);
    font-size: 1.2rem;
    line-height: 1;
}

.wcwa-sidebar__nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.wcwa-sidebar__list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.wcwa-sidebar__section-label {
    margin: 18px 20px 6px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.4);
}

.wcwa-sidebar__link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: #cbd5d9;
    text-decoration: none;
    font-size: 0.95rem;
    border-left: 3px solid transparent;
    transition: background 0.15s ease, color 0.15s ease;
}

.wcwa-sidebar__link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--theme-white);
}

.wcwa-sidebar__link.is-active {
    background: rgba(var(--theme-base-rgb), 0.18);
    color: var(--theme-white);
    border-left-color: var(--theme-base);
    font-weight: 600;
}

.wcwa-sidebar__icon {
    width: 20px;
    text-align: center;
}

.wcwa-sidebar__footer {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 14px 16px;
}

.wcwa-sidebar__user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.wcwa-sidebar__avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--theme-base);
    color: var(--theme-white);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.wcwa-sidebar__user-info {
    flex: 1;
    min-width: 0;
    line-height: 1.2;
}

.wcwa-sidebar__user-name {
    display: block;
    font-size: 0.85rem;
    color: var(--theme-white);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wcwa-sidebar__user-role {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.5);
}

.wcwa-sidebar__logout {
    color: rgba(255, 255, 255, 0.55);
    font-size: 1.05rem;
}

.wcwa-sidebar__logout:hover {
    color: var(--theme-white);
}

/* Sidebar responsive */
@media (max-width: 991.98px) {
    .wcwa-sidebar {
        transform: translateX(-100%);
    }
    .wcwa-sidebar.is-open {
        transform: translateX(0);
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.3);
    }
}

@media (min-width: 992px) {
    .wcwa-main {
        margin-left: 260px;
    }
}

/* ---------- Topbar ---------- */
.wcwa-topbar {
    background: var(--theme-white);
    border-bottom: 1px solid var(--theme-bdr-color);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 20px;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.wcwa-topbar__hamburger {
    background: transparent;
    border: 0;
    font-size: 1.3rem;
    color: var(--theme-secundary);
}

.wcwa-topbar__title {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 0;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wcwa-topbar__select {
    min-width: 200px;
    border-color: var(--theme-bdr-color);
}

.wcwa-topbar__userbtn {
    background: transparent;
    border: 1px solid var(--theme-bdr-color);
    color: var(--theme-secundary);
}

.wcwa-topbar__userbtn:hover {
    background: var(--theme-bg);
}

/* ---------- Utilidades del panel ---------- */
.wcwa-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.wcwa-page-header__title {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0;
}

.wcwa-card {
    background: var(--theme-white);
    border: 1px solid var(--theme-bdr-color);
    border-radius: 12px;
}

.wcwa-card__body {
    padding: 20px;
}

.wcwa-card__title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 14px;
}

.wcwa-stat {
    background: var(--theme-white);
    border: 1px solid var(--theme-bdr-color);
    border-radius: 12px;
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.wcwa-stat__icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.wcwa-stat__icon--base { background: rgba(var(--theme-base-rgb), 0.12); color: var(--theme-base); }
.wcwa-stat__icon--primary { background: rgba(var(--theme-primary-rgb), 0.16); color: #b07d10; }
.wcwa-stat__icon--secundary { background: rgba(var(--theme-secundary-rgb), 0.1); color: var(--theme-secundary); }
.wcwa-stat__icon--green { background: rgba(25, 135, 84, 0.12); color: #198754; }

.wcwa-stat__value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.1;
}

.wcwa-stat__label {
    font-size: 0.82rem;
    color: var(--theme-gray);
}

.wcwa-btn-base {
    background: var(--theme-base);
    border-color: var(--theme-base);
    color: var(--theme-white);
}

.wcwa-btn-base:hover,
.wcwa-btn-base:focus {
    background: #8f2bd0;
    border-color: #8f2bd0;
    color: var(--theme-white);
}

.wcwa-badge-estado { font-size: 0.72rem; }

.wcwa-table thead th {
    background: #f8f7fa;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--theme-gray);
    border-bottom-width: 1px;
}

.wcwa-table td {
    vertical-align: middle;
}

.wcwa-empty {
    text-align: center;
    padding: 50px 20px;
    color: var(--theme-gray);
}

.wcwa-empty__icon {
    font-size: 2.4rem;
    margin-bottom: 12px;
    opacity: 0.4;
}

/* ---------- Chat (bandeja) ---------- */
.wcwa-chat {
    display: grid;
    grid-template-columns: 320px 1fr;
    height: calc(100vh - 190px);
    min-height: 420px;
    background: var(--theme-white);
    border: 1px solid var(--theme-bdr-color);
    border-radius: 12px;
    overflow: hidden;
}

.wcwa-chat__contacts {
    border-right: 1px solid var(--theme-bdr-color);
    overflow-y: auto;
    background: #fbfafd;
}

.wcwa-chat__contact {
    display: flex;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid #f0eef4;
    cursor: pointer;
    align-items: center;
    text-decoration: none;
    color: inherit;
}

.wcwa-chat__contact:hover {
    background: #f3f0f8;
}

.wcwa-chat__contact.is-active {
    background: rgba(var(--theme-base-rgb), 0.1);
    border-left: 3px solid var(--theme-base);
}

.wcwa-chat__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--theme-secundary);
    color: var(--theme-white);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.wcwa-chat__body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.wcwa-chat__head {
    padding: 12px 16px;
    border-bottom: 1px solid var(--theme-bdr-color);
    background: var(--theme-white);
}

.wcwa-chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px;
    background: #efeef4;
}

.wcwa-chat__bubble {
    max-width: 72%;
    padding: 9px 13px;
    border-radius: 14px;
    margin-bottom: 8px;
    font-size: 0.92rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.wcwa-chat__bubble--in {
    background: var(--theme-white);
    border: 1px solid #e4e1ec;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}

.wcwa-chat__bubble--out {
    background: var(--theme-base);
    color: var(--theme-white);
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

.wcwa-chat__meta {
    font-size: 0.68rem;
    opacity: 0.7;
    display: block;
    margin-top: 3px;
}

.wcwa-chat__composer {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--theme-bdr-color);
    background: var(--theme-white);
}

@media (max-width: 767.98px) {
    .wcwa-chat {
        grid-template-columns: 1fr;
        height: calc(100vh - 200px);
    }
    .wcwa-chat__contacts {
        border-right: 0;
        border-bottom: 1px solid var(--theme-bdr-color);
    }
    .wcwa-chat.is-open-thread .wcwa-chat__contacts {
        display: none;
    }
    .wcwa-chat__bubble {
        max-width: 85%;
    }
}

/* ---------- QR ---------- */
.wcwa-qr__frame {
    width: 280px;
    height: 280px;
    margin: 0 auto;
    border-radius: 12px;
    overflow: hidden;
    background: var(--theme-white);
    display: flex;
    align-items: center;
    justify-content: center;
}

.wcwa-qr__frame img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.wcwa-pulse {
    animation: wcwa-pulse 1.6s ease-in-out infinite;
}

@keyframes wcwa-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

/* ---------- Bandejas de contacto/reglas ---------- */
.wcwa-rule-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid var(--theme-bdr-color);
    border-radius: 10px;
    margin-bottom: 8px;
    background: var(--theme-white);
}

/* ---------- Proposals ---------- */
.wcwa-proposal {
    border: 1px dashed rgba(var(--theme-primary-rgb), 0.6);
    background: #fffbf2;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
}

.wcwa-proposal__content {
    white-space: pre-wrap;
    font-size: 0.9rem;
    background: rgba(var(--theme-primary-rgb), 0.08);
    border-radius: 8px;
    padding: 12px;
    max-height: 260px;
    overflow-y: auto;
}
