/* ===== POWER CHAT CSS ===== */

/* Variáveis de cor - facilita personalização */
:root {
    --primary-color: #337ab7;
    --primary-dark: #286090;
    --primary-light: #5bc0de;
    --secondary-color: #f8f9fa;
    --dark-bg: #2c3e50;
    --darker-bg: #1a252f;
    --text-light: #ecf0f1;
    --text-muted: #95a5a6;
    --border-color: #dee2e6;
    --success-color: #5cb85c;
    --danger-color: #d9534f;
    --warning-color: #f0ad4e;
    --white: #ffffff;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;
    --gray-900: #212529;
}

/* Container principal do chat */
.power-chat-container {
    display: flex;
    height: calc(100vh - 63px);
    background: var(--white);
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* ===== SIDEBAR ===== */
.chat-sidebar {
    width: 320px;
    background: var(--dark-bg);
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
}

/* Header da sidebar */
.chat-header {
    padding: 20px;
    background: var(--darker-bg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-profile {
    display: flex;
    align-items: center;
    flex: 1;
}

.user-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    margin-right: 12px;
    border: 2px solid var(--primary-color);
}

.user-info {
    flex: 1;
}

.user-name {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-light);
}

.user-status {
    font-size: 12px;
    color: var(--text-muted);
}

.chat-actions {
    display: flex;
    gap: 5px;
}

.chat-action-btn {
    color: var(--text-muted);
    padding: 8px;
    border: none;
    background: transparent;
    border-radius: 4px;
    transition: all 0.2s;
}

.chat-action-btn:hover {
    color: var(--text-light);
    background: rgba(255, 255, 255, 0.1);
}

/* Search area */
.chat-search {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-search .input-group-addon {
    background: var(--darker-bg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-muted);
}

.chat-search .form-control {
    background: var(--darker-bg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-light);
}

.chat-search .form-control::placeholder {
    color: var(--text-muted);
}

.chat-search .form-control:focus {
    background: var(--darker-bg);
    border-color: var(--primary-color);
    color: var(--text-light);
    box-shadow: 0 0 0 2px rgba(51, 122, 183, 0.2);
}

/* Tabs */
.chat-tabs {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-tabs .nav-tabs {
    border-bottom: none;
    background: var(--dark-bg);
}

.chat-tabs .nav-tabs>li {
    flex: 1;
}

.chat-tabs .nav-tabs>li>a {
    background: transparent;
    border: none;
    color: var(--text-muted);
    border-radius: 0;
    text-align: center;
    padding: 15px 10px;
    transition: all 0.2s;
    font-size: 13px;
}

.chat-tabs .nav-tabs>li>a:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-light);
    border: none;
}

.chat-tabs .nav-tabs>li.active>a,
.chat-tabs .nav-tabs>li.active>a:hover,
.chat-tabs .nav-tabs>li.active>a:focus {
    background: var(--primary-color);
    color: var(--white);
    border: none;
}

.chat-tabs .nav-tabs>li>a i {
    margin-right: 5px;
}

/* Lista de usuários */
.chat-users-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}

.user-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.user-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.user-item.active {
    background: var(--primary-color);
}

.user-item-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 12px;
    flex-shrink: 0;
}

.user-item-info {
    flex: 1;
    min-width: 0;
}

.user-item-name {
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-item-message {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-item-time {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
    margin-left: 10px;
}

.user-item.active .user-item-name,
.user-item.active .user-item-message,
.user-item.active .user-item-time {
    color: var(--white);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state i {
    margin-bottom: 15px;
    color: var(--text-muted);
}

/* Footer da sidebar */
.chat-footer {
    padding: 15px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: var(--darker-bg);
    display: flex;
    justify-content: space-around;
}

.footer-btn {
    color: var(--text-muted);
    font-size: 12px;
    padding: 8px 12px;
    border-radius: 4px;
    transition: all 0.2s;
}

.footer-btn:hover {
    color: var(--text-light);
    background: rgba(255, 255, 255, 0.1);
}

.footer-btn i {
    margin-right: 5px;
}

/* ===== ÁREA PRINCIPAL DO CHAT ===== */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--white);
}

/* Header da área principal */
.chat-main-header {
    padding: 20px;
    background: var(--white);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-contact-info {
    display: flex;
    align-items: center;
}

.contact-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin-right: 15px;
    border: 2px solid var(--primary-color);
}

.contact-details {
    flex: 1;
}

.contact-name {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-800);
}

.contact-status {
    font-size: 13px;
    color: var(--text-muted);
}

.chat-main-actions {
    display: flex;
    gap: 10px;
}

.main-action-btn {
    color: var(--gray-600);
    padding: 10px;
    border: none;
    background: transparent;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.main-action-btn:hover {
    background: var(--gray-100);
    color: var(--primary-color);
}

/* Área de mensagens */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--gray-100);
}

.message-bubbles {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message-bubble {
    display: flex;
    align-items: flex-end;
    max-width: 70%;
    margin-bottom: 10px;
}

.message-bubble.sent {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-bubble.received {
    align-self: flex-start;
}

.message-content {
    background: var(--white);
    padding: 12px 16px;
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    color: var(--gray-800);
    word-wrap: break-word;
    position: relative;
}

.message-bubble.sent .message-content {
    background: var(--primary-color);
    color: var(--white);
    margin-right: 10px;
}

.message-bubble.received .message-content {
    background: var(--white);
    color: var(--gray-800);
    margin-left: 10px;
}

.message-avatar {
    flex-shrink: 0;
}

.message-avatar img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
}

/* Área de input */
.chat-input-area {
    padding: 20px;
    background: var(--white);
    border-top: 1px solid var(--border-color);
}

.chat-input-area .form-control {
    border-radius: 25px;
    padding: 12px 20px;
    border: 1px solid var(--border-color);
    font-size: 14px;
}

.chat-input-area .form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(51, 122, 183, 0.2);
}

.chat-input-area .input-group-btn .btn {
    border-radius: 50%;
    width: 45px;
    height: 45px;
    margin-left: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-input-area .input-group-btn .btn:first-child {
    background: var(--gray-400);
    border-color: var(--gray-400);
}

.chat-input-area .input-group-btn .btn:first-child:hover {
    background: var(--gray-500);
    border-color: var(--gray-500);
}

.chat-input-area .input-group-btn .btn:last-child {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.chat-input-area .input-group-btn .btn:last-child:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

/* ===== RESPONSIVIDADE ===== */
@media (max-width: 768px) {
    .power-chat-container {
        margin: 10px;
        height: calc(100vh - 80px);
    }

    .chat-sidebar {
        width: 280px;
    }

    .user-item {
        padding: 10px 15px;
    }

    .chat-header,
    .chat-main-header {
        padding: 15px;
    }

    .message-bubble {
        max-width: 85%;
    }
}

@media (max-width: 576px) {
    .power-chat-container {
        flex-direction: column;
        margin: 5px;
    }

    .chat-sidebar {
        width: 100%;
        height: 300px;
    }

    .chat-main {
        flex: 1;
    }

    .chat-main-actions {
        gap: 5px;
    }

    .main-action-btn {
        width: 35px;
        height: 35px;
        padding: 8px;
    }
}

/* ===== SCROLLBAR CUSTOMIZADO ===== */
.chat-users-list::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-users-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

.chat-users-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.chat-users-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--gray-200);
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}

/* ===== ANIMAÇÕES ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-bubble {
    animation: fadeInUp 0.3s ease-out;
}

.user-item {
    transition: all 0.2s ease;
}

.chat-action-btn,
.main-action-btn,
.footer-btn {
    transition: all 0.2s ease;
}

/* ===== ESTADOS DE CONEXÃO ===== */
.user-status.online::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--success-color);
    border-radius: 50%;
    margin-right: 5px;
}

.user-status.away::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--warning-color);
    border-radius: 50%;
    margin-right: 5px;
}

.user-status.offline::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--gray-400);
    border-radius: 50%;
    margin-right: 5px;
}

/* ===== UTILITÁRIOS ===== */
.text-primary {
    color: var(--primary-color) !important;
}

.bg-primary {
    background-color: var(--primary-color) !important;
}

.border-primary {
    border-color: var(--primary-color) !important;
}


.chat-users-list .user-item-status {
    display: flex;
    align-items: center;
    font-size: 14px;
    color: var(--text-muted);
}

.chat-users-list .status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}

.chat-users-list .user-item-status.online .status-dot {
    background-color: #28a745;
    /* verde */
}

.chat-users-list .user-item-status.offline .status-dot {
    background-color: #dc3545;
    /* vermelho */
}


/** Indicador de digitação **/
.typing-indicator {
    animation: fadeInUp 0.3s ease-out;
}

.typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
}

.typing-dots span {
    height: 8px;
    width: 8px;
    background-color: #999;
    border-radius: 50%;
    display: inline-block;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing {

    0%,
    80%,
    100% {
        transform: scale(0);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.file-message .message-content {
    padding: 15px;
    min-width: 200px;
}

.file-size {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 5px;
}

.upload-progress {
    margin-top: 10px;
}

.upload-progress .progress {
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    overflow: hidden;
}

.upload-progress .progress-bar {
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    transition: width 0.3s ease;
}
.group-chat-input{
    display: flex;
    align-items: center;
}
.group-chat-input span{    
    display: flex;
}

.no-chat-selected{
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 18px;
    background: var(--gray-100);
    border-left: 1px solid var(--border-color);
}


/* ===== VERSÃO TOGGLED ===== */
.chat-toggled-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 300px;
    height: 65px;
    background: var(--dark-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: height 0.3s ease-in-out;
    z-index: 10000;
}

.chat-toggled-container ul {
    max-height: 400px;
    overflow-y: auto;
}

.chat-toggled-header {
    padding: 10px 15px;
    background: var(--darker-bg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.chat-toggled-header-left {
    display: flex;
    align-items: center;
    flex: 1;
}

.chat-toggled-header-right {
    display: flex;
    align-items: center;
    gap: 5px;
}

.chat-toggled-visible {
    height: 400px !important;
    transition: height 0.3s ease-in-out;
}

.chat-toggled-mini-visible {
    height: 65px !important;
    overflow: hidden;
    transition: height 0.3s ease-in-out;
}



.chat-header-toggled .chat-contact-info .contact-name{
    font-size: 15px;  
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

.chat-toggled-mensagens .chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    background: var(--gray-100);
    height: 295px;
}

.chat-toggled-mensagens {
  position: fixed;
  bottom: 0;
  right: 300px; /* recuo do canto direito */
  width: 300px;
  height: 400px;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 8px 8px 0 0;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  z-index: 9999;
   transition: height 0.3s ease-in-out;
}

.chat-header-toggled {
  cursor: move; /* deixa claro que dá pra arrastar */
  background: #007bff;
  color: #fff;
  padding: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: 8px 8px 0 0;
}

.user-item-toggle{
    display: flex;
    align-items: center;
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.user-item-toggle:hover {
    background: rgba(255, 255, 255, 0.05);
}

.user-item-toggle.active {
    background: var(--primary-color);
}

.user-item-toggle-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 12px;
    flex-shrink: 0;
}
.chat-visible-highlight{
    background-color: #3b42df; /* amarelo claro */
    transition: background-color 1.5s ease;
    position: relative;
}

.chat-visible-highlight-pulse::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 10px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #28a745; /* verde */
    transform: translateY(-50%);
    box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        transform: translateY(-50%) scale(1);
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7);
    }
    70% {
        transform: translateY(-50%) scale(1.2);
        box-shadow: 0 0 0 10px rgba(40, 167, 69, 0);
    }
    100% {
        transform: translateY(-50%) scale(1);
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0);
    }
}

.chat-aviso-recebida {
    box-shadow: 0 0 0 0 rgba(29, 170, 62, 0.945);
    animation: pulse-recebida 1.5s infinite;
}

@keyframes pulse-recebida {
    0% {       
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7);
    }
    70% {
      
        box-shadow: 0 0 0 10px rgba(40, 167, 69, 0);
    }
    100% {        
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0);
    }
}