/* WhatsApp Style Chat UI shared styles */

.chat-messages {
    background-color: #efeae2 !important;
    /* WhatsApp Beige background */
    scroll-behavior: smooth;
}

#chatMessageFlow {
    background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
    background-size: contain;
    background-repeat: repeat;
    background-attachment: local;
    opacity: 0.9;
    /* Sutil como no WhatsApp Web */
}

/* Estilos para cards de proposta no detalhe do lead */
.af-proposal-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 16px;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.af-proposal-card:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--af-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.af-proposal-card .card-header-simple {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 10px;
    margin-bottom: 4px;
}

.af-proposal-card .card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    margin: 0;
}

.af-proposal-card .card-date {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
}

.af-proposal-card .card-body-simple {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.af-proposal-card .proposal-info {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 0.85rem;
}

.af-proposal-card .info-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: rgba(255, 255, 255, 0.7);
}

.af-proposal-card .info-item i {
    width: 14px;
    height: 14px;
    color: var(--af-primary);
}

.af-proposal-card .card-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}


.msg-bubble {
    max-width: 75%;
    padding: 6px 10px;
    border-radius: 8px;
    position: relative;
    font-size: 0.85rem;
    margin-bottom: 4px;
    box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    display: flex;
    flex-direction: column;
}

.msg-received {
    align-self: flex-start;
    background: #ffffff;
    color: #111b21;
    border-top-left-radius: 0;
    margin-left: 10px;
}

.msg-sent {
    align-self: flex-end;
    background: #d9fdd3;
    /* Light WhatsApp Green */
    color: #111b21;
    border-top-right-radius: 0;
    margin-right: 10px;
    transition: opacity 0.3s;
}

/* Estilo discreto para mensagens de status de chamada */
.msg-call-info {
    opacity: 0.7;
    font-style: italic;
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px dashed rgba(0, 0, 0, 0.1) !important;
}

.msg-sent.msg-call-info {
    background: rgba(217, 253, 211, 0.5) !important;
}

.msg-received.msg-call-info {
    background: rgba(255, 255, 255, 0.5) !important;
}

.msg-pending {
    opacity: 0.7;
}

.msg-pending .msg-status {
    display: none !important;
}

.chip-close-btn {
    opacity: 0.8;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #adb5bd !important;
}

.chip-close-btn:hover {
    opacity: 1;
    color: #dc3545 !important;
    transform: scale(1.1);
}

/* Force Icon Visibility */
#chatAttachmentBtn i,
#chatAttachmentBtn svg,
#fileSelectedContainer i,
#fileSelectedContainer svg {
    opacity: 1 !important;
    visibility: visible !important;
    stroke: currentColor !important;
}

.chat-sidebar #fileSidebarTabs .nav-link.active {
    color: var(--af-primary) !important;
    border-bottom: 2px solid var(--af-primary) !important;
    background: transparent !important;
}

.chat-sidebar #fileSidebarTabs .nav-link:hover {
    color: #fff !important;
}

.transition-all {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}


/* Style for file items in dark sidebar */
.file-item-dark {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: #fff;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 8px;
    transition: all 0.2s;
}

.file-item-dark:hover {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: var(--af-primary);
    transform: translateY(-2px);
}

.msg-content-wrapper {
    display: flex;
    flex-direction: column;
}

.msg-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 1px;
    line-height: 1;
}

/* Quoted Message Styles */
.msg-quoted {
    background: rgba(0, 0, 0, 0.05);
    border-left: 4px solid var(--af-primary);
    padding: 6px 10px;
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 0.75rem;
    color: #3b4a54;
    /* Contraste melhorado */
}

/* Título de quem está sendo citado */
.msg-quoted-user {
    font-weight: 600;
    color: var(--af-primary);
    margin-bottom: 2px;
}

.wa-transcription {
    font-style: italic;
    color: #54656f;
    margin-top: 4px;
    /* Reduzido de 8px */
    padding: 4px;
    /* Reduzido de 8px 4px 4px 4px */
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    font-size: 0.8rem;
    /* Levemente menor */
    line-height: 1.3;
    /* Mais compacto */
    word-wrap: break-word;
    white-space: pre-wrap;
    max-width: 280px;
    /* Alinhado com a largura da barra de áudio */
}

.wa-read-more,
.wa-read-less {
    display: block;
    color: var(--af-primary);
    font-weight: bold;
    text-decoration: none;
    font-size: 0.75rem;
    margin-top: 4px;
    cursor: pointer;
}

.wa-read-more:hover,
.wa-read-less:hover {
    text-decoration: underline;
}

.reply-preview-bar {
    display: none;
    background: #f0f2f5 !important;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    padding: 8px 16px;
    position: relative;
}

.reply-preview-content {
    background: #e9edef !important;
    border-left: 4px solid var(--af-primary) !important;
    padding: 8px 12px !important;
    border-radius: 6px !important;
    font-size: 0.8rem;
    color: #111b21 !important;
}

.reply-preview-title {
    font-weight: 600;
    color: var(--af-primary);
    margin-bottom: 2px;
    font-size: 0.75rem;
}

.chat-input-pill {
    background-color: #fff !important;
    border: 1px solid #fff !important;
    transition: all 0.2s ease;
}

.chat-input-pill:focus-within {
    border-color: #fff !important;
    box-shadow: none !important;
}

.btn-close-reply {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    opacity: 1;
    color: #dc3545;
    /* Vermelho visível */
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(220, 53, 69, 0.1);
    /* Fundo avermelhado sutil */
}

.btn-close-reply:hover {
    transform: translateY(-50%) scale(1.1);
    background: rgba(220, 53, 69, 0.2);
}

/* Reply Action Icon */
.msg-reply-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: #8696a0;
    background: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.12);
    z-index: 10;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.msg-reply-btn:hover {
    background: #f0f2f5;
    color: var(--af-primary);
    transform: translateY(-50%) scale(1.15);
}

.msg-bubble:hover .msg-reply-btn {
    opacity: 1;
}

.msg-received .msg-reply-btn {
    right: -40px;
}

.msg-sent .msg-reply-btn {
    left: -40px;
}

.msg-time {
    font-size: 0.65rem;
    color: #667781;
}

.msg-status.status-read {
    color: #53bdeb;
    /* WhatsApp blue check color */
}

#chatTypingIndicator {
    font-size: 0.7rem;
    color: #22c55e;
    height: 14px;
    font-weight: 500;
}

.status-online {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    margin-right: 5px;
}

/* Timeline Styles */
.timeline-flow {
    position: relative;
    padding-left: 20px;
    border-left: 2px solid rgba(255, 255, 255, 0.05);
    margin-left: 10px;
}

.timeline-event {
    position: relative;
    margin-bottom: 25px;
    padding-left: 15px;
}

.timeline-event .timeline-event-icon {
    position: absolute;
    left: -32px;
    top: 2px;
    width: 18px;
    height: 18px;
    background: #1a1a1a;
    border: 2px solid var(--af-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.event-time {
    font-size: 0.75rem;
    color: #6c757d;
    display: block;
    margin-bottom: 2px;
}

.event-msg {
    color: #e9edef;
    font-size: 0.9rem;
}

.chat-sidebar {
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: visible !important;
}

.chat-sidebar.sidebar-collapsed {
    width: 0 !important;
    min-width: 0 !important;
    border-right: none !important;
}

/* Quando colapsado, projeta o botão para a esquerda do avatar */
.chat-sidebar.sidebar-collapsed .sidebar-collapse-toggle {
    right: -38px;
    /* Posicionado para ficar centralizado no novo padding */
    background-color: var(--af-bg-sidebar);
    border: 1px solid var(--af-border);
    z-index: 2100;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    height: 32px;
    width: 24px;
    color: #fff;
}

/* Empurra o conteúdo do header para a direita quando colapsado para liberar espaço */
.chat-sidebar.sidebar-collapsed+#chatMainArea .p-3.border-bottom {
    padding-left: 48px !important;
    transition: padding 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-sidebar.sidebar-collapsed .af-table-card {
    display: none !important;
}

.sidebar-collapse-toggle {
    position: absolute;
    right: -10px;
    top: 36px;
    /* Header tem 72px total (40px avatar + 2*16px padding), então 36px é o meio */
    transform: translateY(-50%);
    width: 20px;
    height: 24px;
    background-color: var(--af-bg-card);
    border: 1px solid var(--af-border);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--af-text-muted);
    cursor: pointer;
    z-index: 2050;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0;
}

.sidebar-collapse-toggle:hover {
    background-color: var(--af-bg-hover);
    color: #fff;
    border-color: var(--af-primary);
}

.sidebar-collapse-toggle i {
    width: 12px;
    height: 12px;
}

/* WhatsApp Style Document Bubble */
.msg-document-bubble {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    min-width: 240px;
    max-width: 280px;
    margin: 4px 0;
}

.doc-icon-container {
    position: relative;
    width: 38px;
    height: 48px;
    background: #5d6771;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 8px;
    flex-shrink: 0;
}

.doc-icon-ext {
    font-size: 0.6rem;
    font-weight: 800;
    color: #fff;
    text-transform: uppercase;
    z-index: 1;
}

.doc-icon-container::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 12px;
    height: 12px;
    background: rgba(255, 255, 255, 0.25);
    border-bottom-left-radius: 4px;
    border-top-right-radius: 4px;
}

.doc-details {
    flex-grow: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.doc-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: #e9edef;
    margin-bottom: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.doc-meta {
    font-size: 0.7rem;
    color: #8696a0;
    text-transform: uppercase;
}

.doc-download-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8696a0;
    transition: all 0.2s;
    flex-shrink: 0;
    text-decoration: none !important;
}

.doc-download-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.3);
}

/* WhatsApp Style Audio Player - Premium Refinement */
.wa-audio-player {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 4px;
    /* Reduzido de 6px 4px */
    min-width: 260px;
    max-width: 280px;
    /* Reduzido para alinhar com a transcrição */
    user-select: none;
}

.wa-audio-avatar-container {
    position: relative;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    margin-left: 4px;
}

.wa-audio-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    background: #ccc;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.wa-audio-avatar.wa-audio-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #95a5a6;
    color: white;
    font-weight: bold;
    font-size: 1.1rem;
}

.wa-audio-mic-icon {
    position: absolute;
    bottom: -2px;
    right: -2px;
    background: #fff;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    color: #22c55e;
    /* Green Mic */
    z-index: 2;
}

.wa-audio-mic-icon svg {
    width: 11px;
    height: 11px;
    stroke-width: 3px;
}

.wa-audio-play-btn {
    background: transparent;
    border: none;
    padding: 0;
    color: #8696a0;
    /* Gray play button */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    transition: color 0.2s;
}

.wa-audio-play-btn:hover {
    color: #667781;
}

.wa-audio-play-btn svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

.wa-audio-controls {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.wa-audio-main-row {
    position: relative;
    height: 28px;
    display: flex;
    align-items: center;
    overflow: hidden;
}

.wa-audio-slider-container {
    position: relative;
    flex-grow: 1;
    height: 100%;
    display: flex;
    align-items: center;
}

/* Waveform simulation background */
.wa-waveform-bg {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 16px;
    display: flex;
    align-items: center;
    gap: 2px;
    opacity: 0.2;
    pointer-events: none;
}

.wa-waveform-bar {
    width: 2px;
    background: #8696a0;
    border-radius: 1px;
}

.wa-audio-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    background: transparent;
    position: relative;
    z-index: 5;
    cursor: pointer;
}

.wa-audio-slider::-webkit-slider-runnable-track {
    width: 100%;
    height: 2px;
    background: transparent;
}

.wa-audio-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    background: #25d366;
    /* Green Dot */
    border-radius: 50%;
    margin-top: -5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.wa-audio-meta {
    font-size: 0.75rem;
    color: #8696a0;
    margin-top: -2px;
    font-family: 'Inter', sans-serif;
}

/* === LEFT SIDE: SIDEBAR (DARK THEME) === */

/* Sidebar Container */
.chat-sidebar {
    background: var(--af-bg-sidebar) !important;
    /* Dark Background */
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

/* Tabs */
#chatSidebarTabs.nav-tabs {
    border-bottom: none;
    padding: 4px;
    background: rgba(0, 0, 0, 0.2) !important;
    border-radius: 8px;
}

#chatSidebarTabs .nav-link {
    color: var(--af-text-muted);
    /* Light Text */
    border: none;
    border-radius: 6px;
    transition: all 0.2s;
    background: transparent;
}

#chatSidebarTabs .nav-link.active {
    background-color: var(--af-bg-hover) !important;
    color: var(--af-primary) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

#chatSidebarTabs .nav-link:hover:not(.active) {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

/* Search Input */
.chat-sidebar .af-search-container {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-sidebar .af-search-input {
    background: transparent;
    border: none;
    color: #fff;
    /* White Text */
    font-size: 0.9rem;
    width: 100%;
    outline: none;
}

.chat-sidebar .af-search-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* Macro List Items */
.macro-item {
    background: transparent;
    padding: 12px 16px;
    border: none !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03) !important;
    color: #e9edef;
    /* Light Text */
    transition: all 0.2s;
    cursor: pointer;
}

.macro-item:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--af-primary);
}

.macro-item .small {
    color: #8696a0;
    /* Muted Text */
    margin-top: 4px;
}

/* Custom Scrollbar for Dark Sidebar */
.chat-sidebar .custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}

.chat-sidebar .custom-scrollbar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.chat-sidebar .custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.chat-sidebar .custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Custom Scrollbar for Dark Chat Area */
.chat-messages.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}

.chat-messages.custom-scrollbar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.chat-messages.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}

.chat-messages.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* WhatsApp Style Buttons */
.msg-buttons-container {
    margin: 8px -12px -8px -12px;
    /* Pull to edges of bubble */
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    background: rgba(255, 255, 255, 0.3);
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    display: flex;
    flex-direction: column;
}

.msg-button {
    width: 100%;
    padding: 10px;
    border: none;
    background: transparent;
    color: #06cf9c;
    /* Teal primary color */
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
    text-align: center;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.msg-button:first-child {
    border-top: none;
}

.msg-button:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Options/List styles */
.msg-options-container {
    margin-top: 8px;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e9edef;
    overflow: hidden;
}

.msg-option-item {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f2f5;
    cursor: pointer;
    transition: background 0.2s;
}

.msg-option-item:last-child {
    border-bottom: none;
}

.msg-option-item:hover {
    background: #f0f2f5;
}

.option-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: #111b21;
}

.option-desc {
    font-size: 0.8rem;
    color: #667781;
}