/* Valores por defecto; la app puede sobreescribir --brown, --pink-light, --cream y --brown-variant vía empresa-theme.js (colores por empresa). */
:root {
    --pink-light: #f4e0df;
    --brown: #816268;
    --brown-variant: #81626a;
    --cream: #f6f3e4;
    --white: #ffffff;
    --gray-light: #f5f5f5;
    --gray: #e0e0e0;
    --gray-dark: #6b7280;
    --black: #1f2937;
    --blue-check: #53bdeb;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--gray-light);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    max-width: 100%;
    margin: 0 auto;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

/* Left Sidebar - Chat List */
.sidebar-left {
    width: 350px;
    min-width: 350px;
    background-color: var(--white);
    border-right: 1px solid var(--gray);
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.sidebar-header {
    padding: 16px;
    background-color: var(--cream);
    border-bottom: 1px solid var(--gray);
}

.tabs-container {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.tab-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: var(--white);
    color: var(--brown);
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-align: center;
    box-sizing: border-box;
}

.tab-btn.active {
    background-color: var(--brown);
    color: var(--white);
}

.tab-btn:hover:not(.active) {
    background-color: var(--pink-light);
}

.chat-header-bar--interno {
    border-bottom: 1px solid var(--gray);
}

.interno-header-chips {
    margin-top: 4px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chat-input-area--interno .chat-input-row {
    align-items: flex-end;
}

.filter-btn, .filtros-btn {
    padding: 6px 14px;
    border: 1px solid var(--gray);
    border-radius: 20px;
    background-color: var(--white);
    color: var(--gray-dark);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filtros-btn {
    width: 40px;
    padding: 6px 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 33.5px;
    float: right;
}

.advanced-filters-panel {
    margin-top: 10px;
    background: var(--white);
    border: 1px solid rgba(129, 98, 104, 0.18);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.06), 0 2px 10px rgba(129, 98, 104, 0.06);
    padding: 12px;
}

.advanced-filters-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.advanced-filters-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    color: var(--brown);
    font-size: 13px;
}

.advanced-filters-title i {
    font-size: 16px;
}

.advanced-filters-close {
    width: 30px;
    height: 30px;
    border: none;
    border-radius: 10px;
    background: var(--gray-light);
    color: var(--brown);
    cursor: pointer;
}

.advanced-filters-close:hover {
    background: var(--pink-light);
}

.advanced-filters-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 12px;
}

.advanced-filter-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.advanced-filter-field span {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-dark);
}

.advanced-filter-input,
.advanced-filter-select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--gray);
    background: var(--white);
    font-size: 13px;
    font-family: inherit;
    outline: none;
}

.advanced-filter-input:focus,
.advanced-filter-select:focus {
    border-color: var(--brown);
    box-shadow: 0 0 0 3px rgba(129, 98, 104, 0.15);
}

.advanced-filters-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 12px;
}

.advanced-filters-btn {
    border-radius: 10px;
    padding: 10px 14px;
    border: 1px solid transparent;
    font-weight: 700;
    cursor: pointer;
    font-size: 13px;
}

.advanced-filters-btn--primary {
    background: var(--brown);
    color: var(--white);
}

.advanced-filters-btn--primary:hover {
    filter: brightness(1.05);
}

.advanced-filters-btn--ghost {
    background: var(--white);
    border-color: var(--gray);
    color: var(--brown);
}

.advanced-filters-btn--ghost:hover {
    background: var(--pink-light);
    border-color: var(--pink-light);
}

.filter-btn.active {
    background-color: var(--brown-variant);
    color: var(--white);
    border-color: var(--brown-variant);
}

.filter-btn:hover:not(.active) {
    background-color: var(--pink-light);
    border-color: var(--pink-light);
}

/* Resumen de filtros activos (debajo del header) */
.sidebar-active-filters {
    flex-shrink: 0;
    padding: 10px 16px 12px;
    background: linear-gradient(180deg, rgba(129, 98, 104, 0.06) 0%, rgba(255, 255, 255, 0.9) 100%);
    border-bottom: 1px solid var(--gray);
    max-height: 140px;
    overflow-y: auto;
}

.sidebar-active-filters-inner {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-active-filters-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-dark);
}

.sidebar-active-filters-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.sidebar-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    max-width: 100%;
    padding: 4px 4px 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    line-height: 1.35;
    background-color: var(--white);
    border: 1px solid rgba(129, 98, 104, 0.22);
    color: var(--black);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.sidebar-filter-chip-remove {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    margin-left: 2px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--gray-dark);
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar-filter-chip-remove:hover {
    background-color: rgba(129, 98, 104, 0.12);
    color: var(--brown);
}

.sidebar-filter-chip-remove:focus-visible {
    outline: 2px solid var(--brown);
    outline-offset: 1px;
}

.sidebar-filter-chip-remove .ph {
    font-size: 13px;
}

.sidebar-filter-chip .ph {
    font-size: 14px;
    color: var(--brown);
    flex-shrink: 0;
}

.sidebar-filter-chip-label {
    font-weight: 600;
    color: var(--brown-variant);
    flex-shrink: 0;
}

.sidebar-filter-chip-label::after {
    content: ':';
    font-weight: 600;
    margin-left: 1px;
}

.sidebar-filter-chip-value {
    font-weight: 500;
    color: var(--black);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    max-width: 200px;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--gray) transparent;
}

.chat-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid var(--gray-light);
}

.chat-item:hover {
    background-color: var(--cream);
}

.chat-item.active {
    background-color: var(--pink-light);
}

.chat-item-pinned {
    background-color: rgba(250, 248, 249, 0.9);
}

.chat-item-pin-icon {
    display: inline-block;
    margin-right: 4px;
    font-size: 14px;
    color: var(--brown);
    vertical-align: -2px;
    opacity: 0.9;
}

/* Menú contextual (clic derecho en chat) */
.chat-context-menu {
    min-width: 220px;
    padding: 6px;
    background: #fff;
    border: 1px solid rgba(129, 98, 104, 0.2);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.14), 0 4px 12px rgba(129, 98, 104, 0.08);
}

.message-reaction-menu {
    padding: 8px 10px;
    background: #fff;
    border: 1px solid rgba(129, 98, 104, 0.2);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.14), 0 4px 12px rgba(129, 98, 104, 0.08);
}

.message-context-reactions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    padding: 0;
}

.message-context-reaction-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: rgba(129, 98, 104, 0.06);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.12s ease;
    font-family: inherit;
}

.message-context-reaction-btn:hover:not(:disabled),
.message-context-reaction-btn:focus-visible:not(:disabled) {
    background: var(--pink-light);
    outline: none;
    transform: scale(1.08);
}

.message-context-reaction-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.message-context-reactions--disabled {
    opacity: 0.85;
}

.chat-context-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    background: transparent;
    font-size: 14px;
    font-weight: 500;
    color: var(--black);
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease, color 0.15s ease;
}

.chat-context-item i {
    font-size: 18px;
    color: var(--brown);
    opacity: 0.85;
    flex-shrink: 0;
}

.chat-context-item:hover,
.chat-context-item:focus-visible {
    background: var(--pink-light);
    color: var(--brown);
    outline: none;
}

.chat-context-item[data-action="archive"] {
    color: #6b5b5e;
}

.chat-context-item[data-action="archive"]:hover {
    background: rgba(129, 98, 104, 0.1);
    color: #4a3f42;
}

.chat-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--brown);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    margin-right: 12px;
    flex-shrink: 0;
}

.chat-info {
    flex: 1;
    min-width: 0;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-name {
    font-weight: 600;
    color: var(--black);
    font-size: 15px;
}

.chat-time {
    font-size: 12px;
    color: var(--gray-dark);
}

.chat-preview {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 4px 0px;
}

.chat-message {
    color: var(--gray-dark);
    font-size: 14px;
    max-width: 200px;
    min-width: 0;
    display: inline-flex;
    align-items: end;
    gap: 6px;
}

.chat-message .chat-message-plain {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.chat-preview-dir-icon {
    flex-shrink: 0;
    opacity: 0.88;
    font-size: 1.05em;
    line-height: 1;
}

.unread-badge {
    background-color: var(--brown);
    color: var(--white);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 12px 16px;
    background-color: var(--cream);
    border-top: 1px solid var(--gray);
}

.search-container {
    position: relative;
    margin-bottom: 10px;
}

.sidebar-search-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.sidebar-search-row .search-container {
    flex: 1;
    margin-bottom: 0;
}

.add-contact-btn {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: 1px solid var(--gray);
    background: linear-gradient(180deg, #fff 0%, #fff7f9 100%);
    color: var(--brown);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.12s ease, border-color 0.12s ease;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.06);
    flex-shrink: 0;
}

.add-contact-btn .ph {
    font-size: 18px;
    line-height: 1;
}

.add-contact-btn:hover {
    background: var(--pink-light);
}

.add-contact-btn:active {
    transform: translateY(0);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.05);
}

.add-contact-btn:focus-visible {
    outline: 2px solid rgba(129, 98, 104, 0.35);
    outline-offset: 2px;
}

.search-input {
    width: 100%;
    padding: 10px 40px 10px 16px;
    border: 1px solid var(--gray);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--brown);
}

.search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-dark);
}

.tags-container, .tags-user-container {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.tags-container{
    max-height: 23px;
    overflow: hidden;
    transition: max-height 0.4s ease;
}

.chat-item:hover .tags-container{
    max-height: 200px;
}

.tags-user-container{
    margin-bottom: 4px;
}

.tag-chip, .tag-chip-user {
    padding: 4px 10px;
    border-radius: 10px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--gray);
    background-color: var(--white);
    color: var(--gray-dark);
}

.tag-chip:hover, .tag-chip.active {
    background-color: var(--brown-variant);
    color: var(--white);
    border-color: var(--brown-variant);
}

/* Main Chat Area */
.chat-area {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background-color: var(--cream);
    transition: all 0.3s ease;
}

/* Columna que ocupa todo el alto: header arriba, mensajes al medio (scroll), input abajo */
.chat-content {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--gray-dark);
}

.empty-state-icon {
    font-size: 80px;
    color: var(--brown);
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 24px;
    color: var(--brown);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
}

.chat-header-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background-color: var(--white);
    border-bottom: 1px solid var(--gray);
}

.chat-pinned-bar {
    flex-shrink: 0;
    background: linear-gradient(180deg, rgba(255, 245, 248, 0.95) 0%, var(--white) 100%);
    border-bottom: 1px solid rgba(129, 98, 104, 0.15);
    padding: 8px 12px 0px;
    max-height: 90px;
    overflow-y: auto;
}

.chat-pinned-bar-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--gray) transparent;
    padding-bottom: 2px;
}

.chat-pinned-chip {
    flex: 0 0 auto;
    width: 100%;
    display: inline-flex;
    align-items: flex-start;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid rgba(129, 98, 104, 0.22);
    border-radius: 999px;
    background: #fff;
    font-size: 12px;
    font-weight: 500;
    color: var(--black);
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    margin-bottom: 8px;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.chat-pinned-chip:hover {
    background: var(--pink-light);
    border-color: rgba(129, 98, 104, 0.35);
}

.chat-pinned-chip-icons {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    margin-top: 2px;
    color: var(--brown);
}

.chat-pinned-chip-pin {
    font-size: 14px;
    line-height: 1;
}

.chat-pinned-dir-wrap {
    display: inline-flex;
    line-height: 1;
}

.chat-pinned-dir-icon {
    font-size: 14px;
    line-height: 1;
    opacity: 0.92;
}

.chat-pinned-chip-main {
    display: flex;
    gap: 2em;
    min-width: 0;
    flex: 1;
    align-items: center;
}

.chat-pinned-chip-meta {
    font-size: 10px;
    font-weight: 600;
    color: var(--gray-dark);
    white-space: nowrap;
    line-height: 1.2;
}

.chat-pinned-chip-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.contact-info {
    display: flex;
    align-items: center;
}

.contact-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background-color: var(--brown);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    margin-right: 12px;
}

.contact-details h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--black);
    margin-bottom: 0px;
}

.contact-details span {
    font-size: 13px;
    color: var(--gray-dark);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Operador: desplegable custom (ul/li), no select nativo */
.chat-operator-dropdown {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: stretch;
    border-radius: 999px;
    border: 1px solid rgba(129, 98, 104, 0.35);
    background: linear-gradient(180deg, #fff 0%, #faf8f9 100%);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    overflow: visible;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    min-width: 200px;
    max-width: 400px;
}

.chat-operator-dropdown:hover {
    border-color: rgba(129, 98, 104, 0.55);
}

.chat-operator-dropdown.is-open {
    z-index: 100;
    border-color: var(--brown);
    box-shadow: 0 0 0 3px rgba(129, 98, 104, 0.18);
}

.chat-operator-label {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px 0 14px;
    color: var(--brown);
    font-size: 18px;
    opacity: 0.85;
    user-select: none;
    flex-shrink: 0;
}

.chat-operator-inner {
    position: relative;
    flex: 1;
    min-width: 0;
}

.chat-operator-trigger {
    display: flex;
    align-items: center;
    width: 100%;
    margin: 0;
    padding: 8px 34px 8px 0px!important;
    border: none;
    background: transparent;
    font-size: 13px;
    font-weight: 600;
    color: var(--black);
    cursor: pointer;
    line-height: 1.3;
    text-align: left;
    border-radius: 0 999px 999px 0;
    outline: none;
    font-family: inherit;
}

.chat-operator-trigger:focus-visible {
    box-shadow: inset 0 0 0 2px rgba(129, 98, 104, 0.35);
}

.chat-operator-trigger-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.chat-operator-inner::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    width: 0;
    height: 0;
    margin-top: -3px;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--brown);
    opacity: 0.55;
    pointer-events: none;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.chat-operator-dropdown.is-open .chat-operator-inner::after {
    transform: rotate(180deg);
    margin-top: -4px;
    opacity: 0.75;
}

.chat-operator-list {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 200px;
    max-width: min(280px, 92vw);
    max-height: 240px;
    overflow-y: auto;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: #fff;
    border: 1px solid rgba(129, 98, 104, 0.2);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12), 0 2px 10px rgba(129, 98, 104, 0.08);
    scrollbar-width: thin;
    scrollbar-color: var(--gray) transparent;
}

*::-webkit-scrollbar {
    width: 5px;
}

*::-webkit-scrollbar-thumb {
    background: var(--brown);
    border-radius: 3px;
}

.chat-operator-list li {
    margin: 0;
    padding: 0;
}

.chat-operator-option {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    background: transparent;
    font-size: 13px;
    font-weight: 500;
    color: var(--black);
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease, color 0.15s ease;
}

.chat-operator-option:hover,
.chat-operator-option:focus-visible {
    background: var(--pink-light);
    color: var(--brown);
}

.chat-operator-option.is-selected {
    color: var(--brown);
    font-weight: 600;
}

.chat-operator-option.is-selected::after {
    content: '✓';
    float: right;
    opacity: 0.7;
    font-size: 12px;
}

.header-actions button {
    background: none;
    border: none;
    font-size: 14px;
    color: var(--brown);
    cursor: pointer;
    padding: 8px;
    transition: background-color 0.2s ease;
}


.messages-container {
    flex: 1;
    min-height: 0;
    padding: 20px;
    overflow-y: auto;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23816268' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    scrollbar-width: thin;
    scrollbar-color: var(--gray) transparent;
}



.message {
    display: flex;
    margin-bottom: 12px;
}

.message--with-reaccion {
    margin-bottom: 22px;
}

.message.sent {
    justify-content: flex-end;
}

.message.received {
    justify-content: flex-start;
}

.message-shell {
    display: flex;
    align-items: center;
    gap: 6px;
    max-width: calc(65% + 36px);
}

.message.sent .message-shell {
    flex-direction: row-reverse;
}

.message.received .message-shell {
    flex-direction: row;
}

.message-shell:hover .message-actions-trigger {
    display: flex!important;
}

.message-actions-trigger {
    display:none!important;
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    margin-bottom: 2px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--gray-dark);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.55;
    transition: opacity 0.15s ease, background-color 0.15s ease, color 0.15s ease;
    font-size: 20px;
    line-height: 1;
}

.message-actions-trigger:hover,
.message-actions-trigger:focus-visible {
    opacity: 1;
    outline: none;
}

.message.received .message-actions-trigger:hover,
.message.received .message-actions-trigger:focus-visible {
    background: rgba(0, 0, 0, 0.06);
    color: var(--brown);
}

.message.sent .message-actions-trigger:hover,
.message.sent .message-actions-trigger:focus-visible {
    background: rgba(129, 98, 104, 0.14);
    color: var(--brown);
}

.message-pin-badge {
    position: absolute;
    top: 6px;
    right: 8px;
    z-index: 1;
    font-size: 13px;
    color: var(--brown);
    opacity: 0.9;
    line-height: 1;
    pointer-events: none;
}

.message.sent .message-pin-badge {
    right: auto;
    left: 8px;
}

.message-note-badge {
    position: absolute;
    top: 6px;
    right: 8px;
    z-index: 1;
    font-size: 15px;
    color: #a67c00;
    opacity: 0.92;
    line-height: 1;
    pointer-events: none;
}

.message.sent .message-note-badge {
    right: 8px;
    left: auto;
}

.message.received .message-note-badge {
    left: 8px;
    right: auto;
}

.message.sent.message--internal-note .message-bubble-stack {
    padding-right: 22px;
}

.message.sent.message--internal-note:has(.message-pin-badge) .message-bubble-stack {
    padding-left: 20px;
}

.message.received.message--internal-note .message-bubble-stack {
    padding-left: 22px;
}

.message--destacado .message-bubble {
    border: 2px solid rgba(129, 98, 104, 0.55);
    box-shadow: 0 0 0 1px rgba(184, 134, 11, 0.25), 0 2px 10px rgba(129, 98, 104, 0.12);
}

.message.sent.message--destacado .message-bubble {
    border-color: rgba(129, 98, 104, 0.65);
}

.message-bubble {
    max-width: 100%;
    min-width: 0;
    flex: 0 1 auto;
    padding: 10px 14px;
    border-radius: 12px;
    position: relative;
    overflow: visible;
}

.message-bubble-stack {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 4px;
}

/* Cita / respuesta a otro mensaje (context.id de WhatsApp) */
.message-context {
    display: flex;
    gap: 8px;
    align-items: stretch;
    margin-bottom: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    text-align: left;
}

.message.received .message-context {
    background: rgba(0, 0, 0, 0.055);
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.message.sent .message-context {
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(129, 98, 104, 0.2);
}

.message-context--missing {
    opacity: 0.88;
}

.message-context-bar {
    width: 3px;
    flex-shrink: 0;
    border-radius: 2px;
    background: var(--brown);
}

.message-context-text {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    line-height: 1.35;
    color: var(--black);
    word-break: break-word;
    overflow-wrap: anywhere;
}

.message-context-missing-label {
    font-style: italic;
    color: var(--gray-dark);
}

/* Reacción en el borde inferior de la burbuja, medio “afuera” (estilo WhatsApp) */
.message-reaccion-wrap {
    position: absolute;
    z-index: 2;
    bottom: -10px;
    pointer-events: none;
    line-height: 0;
}

.message.sent .message-reaccion-wrap {
    right: 6px;
    left: auto;
}

.message.received .message-reaccion-wrap {
    left: 6px;
    right: auto;
}

.message-reaccion {
    min-width: 1.5em;
    padding: 2px;
    font-size: 15px;
    line-height: 1.2;
    border-radius: 14px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    pointer-events: auto;
}

.message.received .message-reaccion {
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.message.sent .message-reaccion {
    background: #fff;
    border: 1px solid rgba(129, 98, 104, 0.2);
}

.message.sent .message-bubble {
    background-color: var(--pink-light);
    border-bottom-right-radius: 4px;
}

.message.failed .message-bubble {
    background-color: #ff00006e;
    border-bottom-right-radius: 4px;
    border: 2px solid #cb3b3b;
}

.message-status.failed {
    color: #cb3b3b;
}

.message.received .message-bubble {
    background-color: var(--white);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.message-text {
    font-size: 14px;
    color: var(--black);
    line-height: 1.4;
    margin-bottom: 4px;
    white-space: pre-wrap; /* respeta \\n */
    word-break: break-word;
    overflow-wrap: anywhere;
}

.message.sent .message-text{
    text-align: right;
}

.message-text--templated .message-text-header {
    font-weight: 700;
    margin-bottom: 6px;
}

.message-text--templated .message-text-header--media {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    font-weight: 600;
    opacity: 0.95;
}

.message.received .message-text--templated .message-text-header--media {
    justify-content: flex-start;
}

.message-text--templated .message-text-body {
    font-weight: 400;
}

.message-text--templated .message-text-footer {
    margin-top: 7px;
    padding-top: 6px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    font-size: 12px;
    color: var(--gray-dark);
    opacity: 0.9;
}

.message-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

.message-time {
    font-size: 11px;
    color: var(--gray-dark);
}

.message-usuario-sep {
    font-size: 11px;
    color: var(--gray-dark);
    opacity: 0.7;
    user-select: none;
}

.message-usuario {
    font-size: 11px;
    color: var(--gray-dark);
    opacity: 0.85;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-status {
    font-size: 14px;
    display: flex;
    align-items: center;
}

.message-status.sent {
    color: var(--gray-dark);
}

.message-status.delivered {
    color: var(--gray-dark);
}

.message-status.read {
    color: var(--blue-check);
}


.chat-input-area {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 12px 20px;
    background-color: var(--white);
    border-top: 1px solid var(--gray);
    gap: 0;
    position: relative;
}

.chat-input-area.attachment-uploading {
    opacity: 0.92;
    pointer-events: none;
}

.chat-input-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    flex-shrink: 0;
}

.message-reply-bar {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 10px;
    border-radius: 10px;
    background: var(--pink-light);
    border: 1px solid rgba(129, 98, 104, 0.2);
}

.message-reply-bar-inner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
}

.message-reply-bar-icon {
    flex-shrink: 0;
    font-size: 20px;
    color: var(--brown);
    margin-top: 2px;
}

.message-reply-bar-text {
    flex: 1;
    min-width: 0;
}

.message-reply-bar-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--brown);
    opacity: 0.85;
    margin-bottom: 2px;
}

.message-reply-bar-preview {
    display: block;
    font-size: 13px;
    color: var(--black);
    line-height: 1.35;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.message-reply-bar-close {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.7);
    color: var(--brown);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: background-color 0.15s ease;
}

.message-reply-bar-close:hover {
    background: #fff;
}

.attachment-preview-bar {
    width: 100%;
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--gray);
}

.attachment-preview-inner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    position: relative;
}

.attachment-preview-remove {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: var(--pink-light);
    color: var(--brown);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: background-color 0.2s ease;
}

.attachment-preview-remove:hover:not(:disabled) {
    background-color: var(--gray);
}

.attachment-preview-thumb {
    flex-shrink: 0;
    max-width: 200px;
    max-height: 140px;
    border-radius: 10px;
    overflow: hidden;
    background: var(--cream);
    display: flex;
    align-items: center;
    justify-content: center;
}

.attachment-preview-img {
    max-width: 200px;
    max-height: 140px;
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
}

.attachment-preview-doc {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    font-size: 36px;
    color: var(--brown);
}

.attachment-preview-label {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    color: var(--gray-dark);
    word-break: break-word;
    padding-top: 4px;
}

.attachment-preview-label.d-none {
    display: none !important;
}

.audio-record-panel {
    width: 100%;
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--gray);
}

.audio-record-inner {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.audio-record-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.audio-record-preview-row {
    flex-direction: column;
    align-items: stretch;
}

.audio-record-preview-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.audio-record-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 24px;
    border: 1px solid var(--gray);
    background: var(--white);
    color: var(--black);
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.audio-record-btn:hover:not(:disabled) {
    background-color: var(--pink-light);
}

.audio-record-btn-primary {
    background-color: var(--brown);
    color: var(--white);
    border-color: var(--brown);
}

.audio-record-btn-primary:hover:not(:disabled) {
    background-color: var(--brown-variant);
}

.audio-record-btn-stop {
    border-color: #c62828;
    color: #c62828;
}

.audio-record-btn-stop:hover:not(:disabled) {
    background-color: #ffebee;
}

.audio-record-timer {
    font-variant-numeric: tabular-nums;
    font-size: 15px;
    font-weight: 600;
    color: var(--brown);
    min-width: 3ch;
}

.audio-record-pulse {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #c62828;
    animation: audio-record-pulse 1.2s ease-in-out infinite;
}

@keyframes audio-record-pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.15);
    }
}

.attach-wrap {
    position: relative;
    flex-shrink: 0;
}

.attach-menu-tooltip {
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 6px 0;
    z-index: 1001;
    min-width: 220px;
}

.attach-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: none;
    text-align: left;
    font-size: 14px;
    color: var(--black);
    cursor: pointer;
}

.attach-menu-item:hover:not(:disabled) {
    background-color: var(--pink-light);
}

.attach-menu-item-disabled,
.attach-menu-item:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.attach-menu-item .ph {
    font-size: 20px;
    color: var(--brown);
}

/* Modal elegir plantilla (adjuntos → Plantilla) */
.plantilla-picker-modal {
    border: 0;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.2);
}

.plantilla-picker-modal .modal-header {
    border-bottom: 1px solid #f1e7ea;
    background: linear-gradient(180deg, #fff 0%, #fff9fb 100%);
    padding: 14px 18px;
}

.plantilla-picker-modal .modal-title {
    font-weight: 700;
    color: #2a1f1f;
}

.plantilla-picker-modal .modal-body {
    padding: 14px 18px 18px;
    background: #fff7f9;
}

/* Modal agregar contacto */
.contact-add-modal {
    border: 0;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.2);
}

.contact-add-modal .modal-header {
    border-bottom: 1px solid #f1e7ea;
    background: linear-gradient(180deg, #fff 0%, #fff9fb 100%);
    padding: 14px 18px;
}

.contact-add-modal .modal-title {
    font-weight: 700;
    color: #2a1f1f;
}

.contact-add-modal .modal-body {
    padding: 14px 18px 18px;
    background: #fff7f9;
}

.plantilla-picker-toolbar {
    margin-bottom: 14px;
}

.plantilla-picker-search-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid #efd9df;
    border-radius: 12px;
    background: #fff;
    padding: 8px 12px;
}

.plantilla-picker-search-wrap .ph {
    font-size: 18px;
    color: var(--gray-dark);
}

.plantilla-picker-search-wrap .form-control {
    border: 0;
    box-shadow: none;
    font-size: 14px;
    padding: 0;
    color: var(--black);
}

.plantilla-picker-search-wrap .form-control::placeholder {
    color: #8f7f85;
}

.plantilla-picker-loading {
    padding: 1.2rem 0;
    text-align: center;
    color: var(--gray-dark);
    font-size: 14px;
}

.plantilla-picker-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.plantilla-picker-empty {
    padding: 1.2rem;
    border: 1px dashed #eacfd7;
    border-radius: 12px;
    background: #fff;
    text-align: center;
}

.plantilla-picker-card {
    border: 1px solid #efd9df;
    border-radius: 14px;
    padding: 12px 14px;
    background: var(--white);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.plantilla-picker-card:hover {
    border-color: #e1b7c4;
    box-shadow: 0 8px 20px rgba(176, 110, 132, 0.12);
    transform: translateY(-1px);
}

.plantilla-picker-card-head {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.plantilla-picker-card-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    color: var(--black);
}

.plantilla-picker-card-body {
    margin-bottom: 12px;
}

.plantilla-picker-card-foot {
    display: flex;
    justify-content: flex-end;
}

.plantilla-picker-send {
    border-radius: 10px;
    padding: 7px 12px;
}

.plantilla-picker-meta {
    font-size: 12px;
    margin-bottom: 10px;
    line-height: 1.5;
    color: var(--gray-dark);
}

.plantilla-picker-code {
    font-size: 11px;
}

.plantilla-picker-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 8px;
    border-radius: 6px;
    margin-right: 6px;
}

.plantilla-picker-badge--in {
    background: var(--pink-light);
    color: var(--brown);
}

.plantilla-picker-badge--wa {
    background: #dcf8c6;
    color: #1b5e20;
}

.plantilla-picker-bubble {
    max-width: 100%;
    background: #fff;
    border-radius: 12px 12px 12px 4px;
    padding: 10px 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.plantilla-picker-header {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    color: var(--black);
}

.plantilla-picker-header--media {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--brown);
}

.plantilla-picker-header--media .ph {
    font-size: 18px;
    opacity: 0.95;
}

.plantilla-picker-header--with-thumb {
    display: block;
    padding-bottom: 0;
    border-bottom: none;
    margin-bottom: 8px;
}

.plantilla-picker-thumb-wrap {
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(0, 0, 0, 0.04);
    max-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.plantilla-picker-thumb-img {
    max-width: 100%;
    max-height: 120px;
    width: auto;
    height: auto;
    display: block;
}

.plantilla-picker-thumb-video {
    max-width: 100%;
    max-height: 120px;
    display: block;
    background: #000;
}

.plantilla-picker-thumb-wrap--pdf {
    height: 100px;
    max-height: 100px;
}

.plantilla-picker-thumb-pdf {
    width: 100%;
    height: 100%;
    border: none;
}

.plantilla-picker-header-media-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--brown);
}

.plantilla-picker-header-media-label .ph {
    font-size: 16px;
    opacity: 0.95;
}

.plantilla-picker-body {
    font-size: 14px;
    line-height: 1.5;
    color: #111;
    white-space: pre-wrap;
    word-break: break-word;
}

.plantilla-picker-footer {
    font-size: 11px;
    color: #667781;
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.plantilla-picker-quickreplies {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(11, 20, 26, 0.08);
    width: 100%;
}

.plantilla-picker-qr {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
    min-height: 28px;
    padding: 6px 12px;
    font-size: 12px;
    letter-spacing: -0.01em;
    background: #fff;
    border: 1px solid #e9edef;
    border-radius: 7px;
    box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.05);
}

/* Quick replies dentro de la burbuja del hilo (mensaje ya enviado) */
.message-bubble-quickreplies {
    margin-top: 8px;
}

.message-bubble-qr {
    color: #008069;
    font-weight: 500;
    pointer-events: none;
    user-select: none;
}

.message-bubble-list {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(11, 20, 26, 0.08);
    pointer-events: none;
    user-select: none;
}

.message-bubble-list-open {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    color: #008069;
    background: #fff;
    border: 1px solid #e9edef;
    border-radius: 8px;
    margin-bottom: 8px;
}

.message-bubble-list-section {
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-dark);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 6px;
}

.message-bubble-list-row {
    padding: 8px 10px;
    font-size: 13px;
    color: var(--black);
    background: #fff;
    border: 1px solid #e9edef;
    border-radius: 6px;
    margin-bottom: 4px;
}

.message-bubble-list-row-title {
    display: block;
}

.message-bubble-list-row-desc {
    display: block;
    font-size: 11px;
    color: var(--gray-dark);
    margin-top: 2px;
}

.plantilla-picker-list {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(11, 20, 26, 0.08);
    width: 100%;
}

.plantilla-picker-list-open {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 500;
    color: #008069;
    background: #fff;
    border: 1px solid #e9edef;
    border-radius: 8px;
    margin-bottom: 8px;
    box-sizing: border-box;
}

.plantilla-picker-list-section {
    font-size: 11px;
    font-weight: 600;
    color: #667781;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 6px;
}

.plantilla-picker-list-row {
    padding: 8px 10px;
    font-size: 13px;
    color: #111;
    background: #fff;
    border: 1px solid #e9edef;
    border-radius: 6px;
    margin-bottom: 4px;
}

.plantilla-picker-list-row-title {
    display: block;
}

.plantilla-picker-list-row-desc {
    display: block;
    font-size: 11px;
    color: #667781;
    margin-top: 2px;
}

@media (max-width: 576px) {
    .plantilla-picker-modal .modal-header,
    .plantilla-picker-modal .modal-body {
        padding-left: 12px;
        padding-right: 12px;
    }

    .plantilla-picker-card-foot {
        justify-content: stretch;
    }

    .plantilla-picker-send {
        width: 100%;
    }
}

.message-media-img {
    max-width: 260px;
    max-height: 240px;
    width: auto;
    height: auto;
    display: block;
    border-radius: 8px;
    object-fit: contain;
}

.message-media-video-wrap {
    max-width: 100%;
}

.message-media-video {
    max-width: 260px;
    max-height: 240px;
    width: 100%;
    display: block;
    border-radius: 8px;
    background: #000;
}

.attachment-preview-video {
    max-width: 200px;
    max-height: 140px;
    width: 100%;
    display: block;
    border-radius: 10px;
    background: #000;
}

.message-media-audio-wrap {
    max-width: 100%;
}

.message-media-audio {
    width: 100%;
    max-width: 280px;
    min-width: 200px;
    height: 36px;
    display: block;
}

.attachment-preview-audio {
    width: 100%;
    max-width: 260px;
    min-width: 180px;
    height: 40px;
}

.message-media-caption {
    margin-top: 6px;
    font-size: 14px;
    color: var(--black);
    white-space: pre-wrap;
    word-break: break-word;
}

.message-doc--pdf {
    max-width: 260px;
    text-align: left;
}

.message.sent .message-doc--pdf {
    text-align: left;
}

.message-doc-card {
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message.sent .message-doc-card {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(129, 98, 104, 0.22);
}

.message.received .message-doc-card {
    background: rgba(129, 98, 104, 0.07);
    border: 1px solid rgba(0, 0, 0, 0.09);
}

.message-doc-card-main {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.message-doc-pdf-icon {
    font-size: 28px;
    color: #c62828;
    flex-shrink: 0;
    line-height: 1;
    margin-top: 1px;
}

.message-doc-filename {
    font-size: 14px;
    color: var(--black);
    line-height: 1.35;
    word-break: break-word;
}

.message-doc-open-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    color: var(--white);
    background: var(--brown);
    transition: background-color 0.2s ease, opacity 0.2s ease;
    box-sizing: border-box;
}

.message-doc-open-btn:hover {
    background: var(--brown-variant);
    color: var(--white);
}

.message-doc-link {
    color: var(--brown);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.message-doc-link:hover {
    text-decoration: underline;
}

.attach-btn, .emojis-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--brown);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.attach-btn:hover, .emojis-btn:hover {
    background-color: var(--pink-light);
}

.message-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--gray);
    border-radius: 24px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    transition: border-color 0.2s ease;
}

.message-input:focus {
    outline: none;
    border-color: var(--brown);
}

.message-input.message-input--internal-note {
    background: linear-gradient(160deg, #fffde7 0%, #fff59d 55%, #ffe082 100%);
    border-color: rgba(180, 150, 0, 0.45);
    color: #3d3410;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.message-input.message-input--internal-note:focus {
    border-color: rgba(150, 120, 0, 0.55);
}

.message.sent.message--internal-note .message-bubble {
    background: linear-gradient(160deg, #fffde7 0%, #fff59d 55%, #ffe082 100%);
    border: 1px solid rgba(180, 150, 0, 0.35);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.07), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.message.sent.message--internal-note .message-text--note {
    text-align: left;
    color: #3d3410;
}

.send-btn {
    background-color: var(--brown);
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
    color: var(--white);
    font-size: 20px;
}

.send-btn:hover {
    background-color: var(--brown-variant);
}

/* Right Sidebar - Contact Details */
.sidebar-right {
    width: 0;
    background-color: var(--white);
    border-left: 1px solid var(--gray);
    overflow: hidden;
    transition: width 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar-right.open {
    width: 320px;
    min-width: 320px;
}

.sidebar-right-header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    background-color: var(--cream);
    border-bottom: 1px solid var(--gray);
}

.sidebar-right-header button {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--brown);
    cursor: pointer;
    margin-right: 16px;
}

.sidebar-right-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--black);
}

.contact-profile {
    padding: 14px 16px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
    border-bottom: 1px solid var(--gray);
}

.profile-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background-color: var(--brown);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 24px;
    margin: 0;
    flex-shrink: 0;
}

.profile-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--black);
    margin-bottom: 2px;
}

.profile-phone {
    font-size: 13px;
    color: var(--gray-dark);
    margin: 0;
}

.contact-details-section {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

.contact-details-section input:active,
.contact-details-section input:focus,
.contact-details-section input:focus-visible {
    outline: none!important;
    border: none!important;
    box-shadow: none!important;
}

.detail-value {
    font-size: 14px;
    color: var(--black);
}

/* Formulario contacto: mismo patrón que admin (fieldset + leyenda) */
.sidebar-right .admin-fieldset {
    border: 1px solid var(--gray);
    border-radius: 10px;
    padding: 5px;
    margin: 0;
    margin-top: 12px;
    min-width: 0;
}

.sidebar-right .contact-details-section > .admin-fieldset:first-of-type {
    margin-top: 0;
}

.sidebar-right .admin-fieldset-legend {
    font-size: 12px;
    font-weight: 400;
    padding: 0 6px;
    float: none;
    width: auto;
    margin: 0;
    color: var(--brown);
}

.sidebar-right .admin-input {
    width: 100%;
    box-sizing: border-box;
    padding: 0px 12px 5px 12px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--black);
    background: var(--white);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.sidebar-right .admin-input:focus {
    outline: none;
    border-color: var(--brown);
    box-shadow: 0 0 0 3px rgba(129, 98, 104, 0.15);
}

.sidebar-right select.admin-input.detail-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: var(--white);
    background-image: linear-gradient(45deg, transparent 50%, var(--brown) 50%),
        linear-gradient(135deg, var(--brown) 50%, transparent 50%);
    background-position: calc(100% - 16px) calc(50% - 3px), calc(100% - 10px) calc(50% - 3px);
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
    padding-right: 34px;
    cursor: pointer;
}

.sidebar-right .admin-fieldset .notes-textarea.admin-input {
    min-height: 120px;
    resize: vertical;
    line-height: 1.45;
}

.sidebar-right .admin-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.2s ease, border-color 0.2s ease, filter 0.15s ease;
}

.sidebar-right .admin-btn-primary {
    background: var(--brown);
    color: var(--white);
    border-color: var(--brown);
}

.sidebar-right .admin-btn-primary:hover {
    filter: brightness(1.05);
}

.sidebar-right .admin-fieldset .save-notes-btn {
    width: 100%;
    margin-top: 10px;
}

.destacados-section {
    margin-bottom: 0;
}

.sidebar-destacados-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 240px;
    overflow-y: auto;
    margin-top: 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--gray) transparent;
}

.sidebar-destacados-empty {
    margin-top: 6px;
}

.sidebar-destacado-item {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid rgba(129, 98, 104, 0.2);
    border-radius: 10px;
    background: var(--white);
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.sidebar-destacado-item:hover {
    background: var(--pink-light);
    border-color: rgba(129, 98, 104, 0.35);
}

.sidebar-destacado-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.sidebar-destacado-dir {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--brown);
    opacity: 0.9;
    line-height: 1;
}

.sidebar-destacado-dir-icon {
    font-size: 18px;
    line-height: 1;
    opacity: 0.92;
}

.sidebar-destacado-meta {
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-dark);
    white-space: nowrap;
    margin-left: auto;
}

.sidebar-destacado-text {
    font-size: 13px;
    line-height: 1.35;
    color: var(--black);
    word-break: break-word;
    overflow-wrap: anywhere;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Date Separator */
.date-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
}

.date-separator span {
    background-color: rgba(129, 98, 104, 0.1);
    color: var(--brown);
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
}

/* Hidden elements */
.d-none {
    display: none !important;
}

.message-error{
    font-size: 12px;
}

.emoji-picker-tooltip {
    position: absolute;
    bottom: 77px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 10px;
    z-index: 1000;
    width: 550px;
}

.emoji-picker-tooltip .emoji-item {
    font-size: 24px;
    margin-left:5px;
    cursor: pointer;
}

.emoji-picker-tooltip .emoji-group {
    padding: 10px 0px;
}
.emoji-picker-tooltip .emoji-group:not(:last-child) {
    border-bottom: 1px solid var(--gray);
}


#tagsSelector {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

#tagsSelector .tag-chip {
    border: 1px solid var(--color);
    color: var(--color);
    background-color: transparent;
    transition: all 0.2s ease;
}



/* estado activo */
#tagsSelector .tag-chip.active {
    border: 1px solid var(--color);
    background-color: var(--color);
    color: #fff;
}

.chat-info .tags-container .tag-chip {
    border: 1px solid var(--color)!important;
    background-color: var(--color)!important;
    color: #fff!important;
    padding: 2px 4px
}

.config-container{
    text-align: center;
}
.config-btn {
    padding: 6px 6px;
    border: 1px solid var(--brown);
    border-radius: 20px;
    background-color: var(--brown);
    color: var(--white);
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

a.config-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.detail-separator{
    margin: 30px 0;
}

/* —— Toasts / Alerts (alerts.js) —— */
.alert-stack {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 110000;
    display: flex;
    flex-direction: column-reverse;
    gap: 8px;
    align-items: flex-end;
    pointer-events: none;
    max-width: min(360px, calc(100vw - 40px));
}

#toggleSidebarBtn{
    font-size: 20px;
}

.alert-toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    padding-right: 5px;
    background: var(--white);
    border: 1px solid rgba(129, 98, 104, 0.12);
    border-radius: 10px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
    font-size: 13px;
    line-height: 1.45;
    color: var(--black);
    opacity: 0;
    transform: translateY(10px) scale(0.98);
    transition:
        opacity 0.28s ease,
        transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.alert-toast.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.alert-toast__icon {
    flex-shrink: 0;
    margin-top: 1px;
    font-size: 18px;
    line-height: 1;
    opacity: 0.85;
}

.alert-toast__body {
    flex: 1;
    min-width: 0;
}

.alert-toast__title {
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--gray-dark);
    margin-bottom: 2px;
}

.alert-toast__message {
    color: var(--black);
    word-break: break-word;
}

.alert-toast__close {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin: -4px -4px -4px 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--gray-dark);
    cursor: pointer;
    opacity: 0.55;
    transition: opacity 0.15s ease, background 0.15s ease;
}

.alert-toast__close:hover {
    opacity: 1;
    background: var(--gray-light);
}

.alert-toast__close i {
    font-size: 16px;
}

/* Acento lateral sutil por tipo */
.alert-toast--success {
    border-left: 3px solid #34a853;
}

.alert-toast--success .alert-toast__icon {
    color: #2d8f47;
}

.alert-toast--error {
    border-left: 3px solid #dc5f5f;
}

.alert-toast--error .alert-toast__icon {
    color: #c44c4c;
}

.alert-toast--info {
    border-left: 3px solid #6b8caf;
}

.alert-toast--info .alert-toast__icon {
    color: #5a7a9a;
}

.alert-toast--neutral {
    border-left: 3px solid var(--brown);
}

.alert-toast--neutral .alert-toast__icon {
    color: var(--brown);
}

@media (max-width: 480px) {
    .alert-stack {
        right: 12px;
        top: 12px;
        left: 12px;
        max-width: none;
        align-items: stretch;
    }
}

/* —— Login —— */
.login-body {
    margin: 0;
    min-height: 100vh;
    background: linear-gradient(160deg, var(--cream) 0%, var(--gray-light) 45%, var(--pink-light) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.login-wrap {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: var(--white);
    border-radius: 16px;
    padding: 36px 32px 28px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.08), 0 2px 12px rgba(129, 98, 104, 0.1);
    border: 1px solid rgba(129, 98, 104, 0.12);
}

.login-brand {
    text-align: center;
    margin-bottom: 28px;
}

.login-brand-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--brown) 0%, var(--brown-variant) 100%);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    box-shadow: 0 4px 14px rgba(129, 98, 104, 0.35);
}

.login-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--black);
    margin: 0 0 6px;
}

.login-subtitle {
    margin: 0;
    font-size: 14px;
    color: var(--gray-dark);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.login-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gray-dark);
}

.login-label i {
    font-size: 16px;
    color: var(--brown);
}

.login-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--gray);
    border-radius: 10px;
    font-size: 15px;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.login-input:focus {
    outline: none;
    border-color: var(--brown);
    box-shadow: 0 0 0 3px rgba(129, 98, 104, 0.18);
}

.login-error {
    padding: 10px 12px;
    border-radius: 8px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    font-size: 13px;
}

.login-submit {
    margin-top: 4px;
    width: 100%;
    padding: 14px 18px;
    border: none;
    border-radius: 10px;
    background: var(--brown);
    color: var(--white);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: filter 0.2s ease, transform 0.1s ease;
}

.login-submit:hover:not(:disabled) {
    filter: brightness(1.06);
}

.login-submit:active:not(:disabled) {
    transform: scale(0.99);
}

.login-submit:disabled {
    opacity: 0.75;
    cursor: not-allowed;
}

.login-footnote {
    margin: 24px 0 0;
    padding-top: 20px;
    border-top: 1px solid var(--gray-light);
    font-size: 11px;
    line-height: 1.5;
    color: var(--gray-dark);
    text-align: center;
}

.login-footnote code {
    font-size: 10px;
    background: var(--gray-light);
    padding: 2px 5px;
    border-radius: 4px;
}

.config-btn--ghost {
    background-color: transparent !important;
    color: var(--brown) !important;
    border-color: var(--brown) !important;
}

.config-btn--ghost:hover {
    background-color: var(--pink-light) !important;
}

.advanced-filters-grid select, .advanced-filters-grid input {
    cursor: pointer;
}

.plantilla-picker-send{
    background-color: var(--brown)!important;
    border-color: var(--brown)!important;
}

.plantilla-picker-send:hover .plantilla-picker-send:active{
    background-color: var(--brown);
    border-color: var(--brown);
}

#sidebarDestacadosEmpty, #sidebarDestacadosList, #tagsSelector{
    padding: 0px 10px 10px;
}

#saveContactBtn{
    margin-top: 1em;
}

#addContactSubmitBtn{
    background-color: var(--brown)!important;
    border-color: var(--brown)!important;
}