/* ============================================================
   RESET E BASE
============================================================ */
.chatviewer-container {
    width: 100%;
    margin: 0;
    padding: 0;
}

.container-fluid.px-3.py-4 {
    min-height: calc(100vh - 40px);
    padding-top: 20px;
    padding-bottom: 0;
}

.page {
    display: flex;
    height: 85vh;
    min-height: 600px;
    width: 100%;
    background: #ffffff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}

/* ============================================================
   SIDEBAR
============================================================ */
.sidebar {
    width: 350px;
    background: #f8f9fa;
    border-right: 1px solid #dee2e6;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    background: #2c3e50;
    color: white;
}

.sidebar-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

/* UPLOAD */
.upload-section {
    padding: 20px;
    border-bottom: 1px solid #ddd;
}

.form-group input[type='file'] {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 5px;
}

/* ============================================================
   EMPTY STATE + PLACEHOLDER
============================================================ */

.placeholder-container {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;

    background: rgba(229, 221, 213, 0.92); /* fundo leve WhatsApp */

    cursor: pointer;
    z-index: 10;
}

.placeholder {
    background: white;
    padding: 40px 45px;
    border-radius: 18px;
    text-align: center;

    border: 3px dashed #25d366; /* borda WhatsApp */
    box-shadow: 0px 10px 30px rgba(0,0,0,0.15);

    color: #3b4a54;
    font-size: 1.45rem;
    font-weight: 600;

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;

    transition: all .2s ease-in-out;
}

.placeholder:hover {
    border-color: #128c7e;
    background: #f7f7f7;
    transform: scale(1.03);
}

.placeholder small {
    font-size: 1rem;
    color: #6b7280;
}

.placeholder-folder-icon {
    font-size: 4.4rem;
    color: #25d366;
    margin-bottom: 10px;
}

/* ============================================================
   BUTTONS
============================================================ */
.btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 10px;
    margin-top: 10px;
    border-radius: 6px;
    cursor: pointer;
    width: 100%;
    font-size: .95rem;
}

.btn:hover {
    background: #2980b9;
}

.btn-clear {
    background: #e74c3c;
}

.btn-clear:hover {
    background: #c0392b;
}

/* ============================================================
   ESTATÍSTICAS
============================================================ */
.stats-card,
.participants-card,
.media-card,
.file-card {
    background: white;
    padding: 15px;
    margin: 15px 0;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

.stats-card h3,
.participants-card h3,
.media-card h3,
.file-card h3 {
    font-size: 1rem;
    margin-bottom: 10px;
    color: #2c3e50;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
}

.stat-label {
    color: #6c757d;
    font-size: .85rem;
}

.stat-value {
    color: #333;
    font-weight: bold;
}

/* PARTICIPANTES */
.participant-item {
    display: flex;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f1f1f1;
}

.participant-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #3498db;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    font-weight: bold;
}

/* ============================================================
   CHAT-AREA — FUNDO WHATSAPP COM OPACIDADE
============================================================ */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;

    background:
        linear-gradient(
            rgba(229, 221, 213, 0.90),
            rgba(229, 221, 213, 0.90)
        ),
        url('/static/chatviewer/images/bg.png') center/cover no-repeat;

    border-radius: 10px;
    border: 1px solid #d4d4d4;
    overflow: hidden;
    height: 100%;
    position: relative;
    z-index: 0;
}

/* Caixa onde ficam as mensagens */
.chat-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 20px 25px;
    background: transparent;
    height: 100%;
    min-height: 0;
}

.mensagens-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ============================================================
   MENSAGENS ESTILO WHATSAPP
============================================================ */
.mensagem {
    max-width: 65%;
    margin-bottom: 12px;
}

.mensagem.recebida {
    align-self: flex-start;
}

.mensagem.enviada {
    align-self: flex-end;
}

.autor {
    font-size: .8rem;
    font-weight: bold;
    margin-left: 12px;
    margin-bottom: 3px;
}

.balao {
    padding: 10px 14px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    font-size: 0.95rem;
    line-height: 1.3;
}

.mensagem.recebida .balao {
    background: white;
    border-top-left-radius: 0;
}

.mensagem.enviada .balao {
    background: #dcf8c6;
    border-top-right-radius: 0;
}

.data-hora {
    font-size: .7rem;
    color: #667781;
    margin-top: 5px;
    text-align: right;
}

/* ============================================================
   MÍDIAS
============================================================ */
.media-container {
    margin-bottom: 10px;
}

.media-image {
    max-width: 280px;
    border-radius: 8px;
    cursor: zoom-in;
}

.media-video {
    max-width: 280px;
    border-radius: 6px;
}

.media-audio {
    width: 250px;
}

.media-caption {
    margin-top: 5px;
    font-size: .85rem;
    color: #333;
}

/* ============================================================
   MODAL DE IMAGENS
============================================================ */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    display: none;
    z-index: 10000;

    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
}

.modal-content {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 28px;
    cursor: pointer;
}

.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    font-size: 24px;
    padding: 10px;
    cursor: pointer;
    border-radius: 50%;
}

.modal-prev { left: 20px; }
.modal-next { right: 20px; }

.modal-counter {
    position: absolute;
    bottom: 20px;
    background: rgba(0,0,0,0.5);
    padding: 8px 14px;
    color: white;
    border-radius: 20px;
}

/* ============================================================
   RESPONSIVO
============================================================ */
@media (max-width: 800px) {
    .page {
        display: block;
        height: auto;
    }

    .sidebar {
        width: 100%;
        height: auto;
    }

    .chat-area {
        height: 70vh;
    }

    .mensagem {
        max-width: 85%;
    }

    .btn-icon .btn-text {
        display: none;
    }

    .btn-icon {
        width: 40px;
        height: 40px;
        padding: 0;
        justify-content: center;
    }
}

/* ===================== LOADING OVERLAY ===================== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.60);
  backdrop-filter: blur(3px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-box {
  background: #ffffff;
  padding: 25px 30px;
  border-radius: 12px;
  box-shadow: 0 6px 25px rgba(0,0,0,0.25);
  width: 350px;
  text-align: center;
}

.loading-title {
  font-size: 1.2rem;
  font-weight: bold;
  margin-bottom: 10px;
  color: #333;
}

.loading-status {
  font-size: 0.95rem;
  margin-bottom: 15px;
  color: #444;
}

.progress-bar {
  width: 100%;
  height: 10px;
  background: #e5e5e5;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 20px;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: #25d366;
  transition: width 0.4s ease;
}

.loading-spinner {
  width: 35px;
  height: 35px;
  border: 4px solid #cfcfcf;
  border-top-color: #25d366;
  border-radius: 50%;
  margin: 0 auto;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ================= TOP ACTION BAR ================= */

.upload-success {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffffcc;
    backdrop-filter: blur(4px);
    padding: 6px 12px;
    border-radius: 10px;
    border: 1px solid #e6e6e6;
    margin-bottom: 10px;
}

.upload-counter {
    font-size: 0.85rem;
    font-weight: 600;
    color: #2d3436;
}

.upload-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.top-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;

    background: #f3f3f3;
    color: #555;
    font-size: 0.85rem;

    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.top-btn:hover {
    background: #eaeaea;
    transform: translateY(-2px);
}

.top-btn i {
    font-size: 0.85rem;
}

/* CORES INDIVIDUAIS */
.top-btn.pdf {
    color: #c0392b;
}

.top-btn.pdf:hover {
    background: #f7d7d7;
}

.top-btn.txt {
    color: #2980b9;
}

.top-btn.txt:hover {
    background: #d8e9f7;
}

.top-btn.danger {
    color: #d63031;
}

.top-btn.danger:hover {
    background: #f5d0d0;
}
