/* ========================================
   DISPARADOR PRO - LAYOUT CSS ORGANIZADO
   ======================================== */

/* ========================================
   1. VARIÁVEIS CSS
   ======================================== */
:root {
    --bg-primary: linear-gradient(135deg, #3679b5 0%, #832ddb 100%);
    --bg-body: #f8f9fa;
    --bg-card: #ffffff;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --border-color: #dee2e6;
    --contact-bg: #ffffff;
    --contact-list: #e7e7e7;
    --contact-border: #25D366;
    --upload-border: #dee2e6;
    --upload-hover: #f8f9fa;
    --upload-dragover: #e8f5e8;
}

[data-theme="dark"] {
    --bg-body: #1a1a1a;
    --bg-card: #2d2d30;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --border-color: #444444;
    --contact-bg: #2d2d30;
    --contact-list: #3d3d3d;
    --contact-border: #25D366;
    --upload-border: #444444;
    --upload-hover: #3c3c3f;
    --upload-dragover: #2d4a2d;
}

/* ========================================
   2. ELEMENTOS BASE
   ======================================== */
body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.navbar-dark {
    background: var(--bg-primary) !important;
}

.bg-gradient-primary {
    background: var(--bg-primary);
}

.text-muted {
    color: var(--text-secondary) !important;
}

.bg-light {
    background-color: var(--upload-hover) !important;
}

/* ========================================
   3. CARDS E FORMULÁRIOS
   ======================================== */
.card {
    box-shadow: 0 0.15rem 1.75rem 0 rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-color);
    background-color: var(--bg-card);
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.form-control,
.form-select {
    background-color: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.form-control:focus,
.form-select:focus {
    background-color: var(--bg-card);
    border-color: #25D366;
    color: var(--text-primary);
    box-shadow: 0 0 0 0.2rem rgba(37, 211, 102, 0.25);
}

.form-control::placeholder {
    color: var(--text-secondary);
}

/* ========================================
   4. BOTÕES
   ======================================== */
.btn-whatsapp {
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
    border: none;
    color: white;
}

.btn-whatsapp:hover {
    background: linear-gradient(135deg, #128C7E 0%, #075E54 100%);
    color: white;
}

.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1050;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: var(--bg-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.btn-install {
    animation: pulse 2s infinite;
}

/* ========================================
   5. UPLOAD DE ARQUIVOS
   ======================================== */
.file-upload-area {
    border: 2px dashed var(--upload-border);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    background-color: var(--bg-card);
    color: var(--text-primary);
}

.file-upload-area:hover {
    border-color: #25D366;
    background-color: var(--upload-hover);
}

.file-upload-area.dragover {
    border-color: #25D366;
    background-color: var(--upload-dragover);
}

/* ========================================
   6. CONTATOS
   ======================================== */
.contact-item {
    background: var(--contact-list);
    border-radius: 8px;
    margin-bottom: 5px;
    padding: 8px 12px;
    border-left: 4px solid var(--contact-border);
    color: var(--text-primary);
    transition: all 0.3s ease;
}

#contactsList {
    background-color: var(--contact-bg) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary);
}

/* ========================================
   7. PREVIEW WHATSAPP - BASE
   ======================================== */
.whatsapp-preview {
    background-image: url('./img/black.jpg');
    background-size: cover;
    background-repeat: repeat;
    background-position: center;
    border-radius: 20px;
    padding: 20px;
    margin: 0 auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

[data-theme="light"] .whatsapp-preview {
    background-image: url('./img/green.jpg');
}

.whatsapp-preview::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(circle at 20% 80%, rgba(255, 255, 255, 0.01), transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.01), transparent 50%);
    z-index: 0;
    pointer-events: none;
}

/* Garantir que o conteúdo fique acima do overlay */
.whatsapp-header,
.whatsapp-message,
.preview-placeholder {
    position: relative;
    z-index: 1;
}

/* ========================================
   8. HEADER DO WHATSAPP
   ======================================== */
.whatsapp-header {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    color: white;
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    background: linear-gradient(135deg, rgba(7, 94, 84, 0.95), rgb(22 77 56));
    border-radius: 15px 15px 0 0;
    margin: -20px -20px 20px -20px;
    position: relative;
    z-index: 2;
    backdrop-filter: blur(10px);
}

.whatsapp-avatar {
    width: 40px;
    height: 40px;
    background: #25D366;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    font-weight: bold;
    color: white;
}

.whatsapp-contact-info h6 {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
}

.whatsapp-contact-info small {
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
}

/* ========================================
   9. MENSAGEM DO WHATSAPP
   ======================================== */
.whatsapp-message {
    background: #144d37;
    border-radius: 18px 0px 18px 18px;
    padding: 12px 16px;
    margin-left: auto;
    max-width: 85%;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    color: white;
    line-height: 1.4;
}

.whatsapp-message::after {
    content: '';
    position: absolute;
    top: 0px;
    right: -11px;
    width: 0;
    height: 0;
    border-top: 14px solid #144d37;
    border-right: 14px solid transparent;
}

.whatsapp-time {
    font-size: 11px;
    color: #667781;
    text-align: right;
    margin-top: 6px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

.whatsapp-time i {
    color: #4fc3f7;
}

/* ========================================
   10. MÍDIA NO WHATSAPP
   ======================================== */
.whatsapp-media {
    border-radius: 12px;
    max-width: 100%;
    margin-bottom: 8px;
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
}

/* Vídeo específico */
video.whatsapp-media {
    width: 100% !important;
    height: auto !important;
    max-height: 300px !important;
    border-radius: 10px !important;
    background: #000 !important;
}

/* ========================================
   11. PREVIEW MÚLTIPLAS MENSAGENS
   ======================================== */
#multiplePreviewContent .whatsapp-preview {
    background-image: url('./img/black.jpg');
    background-size: cover;
    background-repeat: repeat;
    background-position: center;
    border-radius: 20px;
    padding: 20px;
    margin: 0 auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

[data-theme="light"] #multiplePreviewContent .whatsapp-preview {
    background-image: url('./img/green.jpg');
}

#multiplePreviewContent .whatsapp-preview::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(circle at 20% 80%, rgba(255, 255, 255, 0.01), transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.01), transparent 50%);
    z-index: 0;
    pointer-events: none;
}

#multiplePreviewContent .whatsapp-header,
#multiplePreviewContent .whatsapp-message,
#multiplePreviewContent .preview-placeholder,
#multiplePreviewContent .badge {
    position: relative;
    z-index: 1;
}

#multiplePreviewContent .whatsapp-header {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    color: white;
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    background: linear-gradient(135deg, rgba(7, 94, 84, 0.95), rgb(22 77 56));
    border-radius: 15px 15px 0 0;
    margin: -20px -20px 20px -20px;
    backdrop-filter: blur(10px);
}

#multiplePreviewContent .whatsapp-avatar {
    width: 40px;
    height: 40px;
    background: #25D366;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    font-weight: bold;
    color: white;
}

#multiplePreviewContent .whatsapp-contact-info h6 {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
}

#multiplePreviewContent .whatsapp-contact-info small {
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
}

#multiplePreviewContent .whatsapp-message {
    background: #144d37;
    border-radius: 18px 0px 18px 18px;
    padding: 12px 16px;
    margin-left: auto;
    max-width: 85%;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    color: white;
    line-height: 1.4;
}

#multiplePreviewContent .whatsapp-message::after {
    content: '';
    position: absolute;
    top: 0px;
    right: -11px;
    width: 0;
    height: 0;
    border-top: 14px solid #144d37;
    border-right: 14px solid transparent;
}

#multiplePreviewContent .whatsapp-media {
    border-radius: 12px;
    max-width: 100%;
    margin-bottom: 8px;
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
}

#multiplePreviewContent video.whatsapp-media {
    width: 100% !important;
    height: auto !important;
    max-height: 300px !important;
    border-radius: 10px !important;
    background: #000 !important;
}

#multiplePreviewContent .whatsapp-time {
    font-size: 11px;
    color: #667781;
    text-align: right;
    margin-top: 6px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

#multiplePreviewContent .whatsapp-time i {
    color: #4fc3f7;
}

#multiplePreviewContent .preview-placeholder {
    text-align: center;
    padding: 40px 20px;
    color: rgba(255, 255, 255, 0.7);
    font-style: italic;
}

#multiplePreviewContent .badge {
    margin-bottom: 10px;
}

.preview-placeholder {
    text-align: center;
    padding: 40px 20px;
    color: rgba(255, 255, 255, 0.7);
    font-style: italic;
}

/* ========================================
   12. PREVIEW DE MÍDIA LATERAL
   ======================================== */
.msg-file-preview {
    background: var(--upload-hover);
    border-radius: 8px;
    padding: 0.75rem;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
}

.msg-file-preview img,
.msg-file-preview video {
    max-width: 100px;
    max-height: 100px;
    border-radius: 4px;
    margin-right: 0.5rem;
}

.media-preview-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    background: #f8f9fa;
    border-radius: 5px;
    flex-shrink: 0;
}

[data-theme="dark"] .media-preview-icon {
    background: #343a40;
}

#mediaPreview {
    transition: all 0.3s ease;
}

#mediaPreview .border {
    border: 2px dashed #dee2e6 !important;
    transition: border-color 0.3s ease;
}

#mediaPreview .border:hover {
    border-color: #00D95F !important;
}

#mediaPreviewContent img {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#clearMediaBtn {
    transition: all 0.3s ease;
}

#clearMediaBtn:hover {
    transform: scale(1.1);
}

/* ========================================
   13. NAVEGAÇÃO POR ABAS
   ======================================== */
.nav-tabs .nav-link {
    position: relative;
}

.nav-tabs .nav-link .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    font-size: 0.6rem;
}

[data-theme="dark"] .nav-tabs .nav-link {
    color: var(--text-secondary);
    background-color: var(--bg-card);
    border-color: var(--border-color);
}

[data-theme="dark"] .nav-tabs .nav-link.active {
    color: #25D366;
    background-color: var(--bg-card);
    border-color: #25D366 #25D366 var(--bg-card);
}

[data-theme="dark"] .tab-content {
    background-color: var(--bg-card);
    border-color: var(--border-color);
}

/* ========================================
   14. INSTÂNCIAS
   ======================================== */
.instance-card {
    border-radius: 10px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    pointer-events: auto;
}

.instance-card.connected {
    border-color: #28a745;
    box-shadow: 0 0 10px rgba(40, 167, 69, 0.3);
}

.instance-card.disconnected {
    border-color: #dc3545;
    box-shadow: 0 0 10px rgba(220, 53, 69, 0.3);
}

.instance-card.connecting {
    border-color: #ffc107;
    box-shadow: 0 0 10px rgba(255, 193, 7, 0.3);
}

.status-badge {
    position: absolute;
    top: 10px;
    right: 10px;
}

.instance-actions {
    display: flex;
    gap: 5px;
    justify-content: flex-end;
    pointer-events: auto;
}

.instance-card button,
.instance-actions button {
    pointer-events: auto;
    z-index: 10;
    position: relative;
}

.connecting .status-badge {
    animation: pulse-connecting 2s infinite;
}

/* ========================================
   15. EDITOR DE TEXTO RICO
   ======================================== */
.rich-text-editor {
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    background-color: white;
    position: relative;
}

.rich-text-toolbar {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    padding: 8px 12px;
    border-radius: 0.375rem 0.375rem 0 0;
    display: flex;
    gap: 8px;
    align-items: center;
}

.toolbar-btn {
    background: none;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 6px 10px;
    cursor: pointer;
    color: #495057;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
}

.toolbar-btn:hover {
    background-color: #e9ecef;
    color: #212529;
}

.toolbar-btn.active {
    background-color: #007bff;
    color: white;
    border-color: #007bff;
}

.toolbar-btn.clicked {
    animation: buttonPulse 0.3s ease;
}

.rich-text-area {
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    padding: 12px;
    border: none;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    width: 100%;
}

.rich-text-area:focus {
    outline: none;
}

.char-counter {
    position: absolute;
    bottom: 8px;
    right: 12px;
    font-size: 11px;
    color: #6c757d;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 2px 6px;
    border-radius: 10px;
}

.format-info {
    background-color: #e3f2fd;
    border: 1px solid #bbdefb;
    border-radius: 0.375rem;
    padding: 8px;
    margin-top: 8px;
    font-size: 12px;
    color: #1976d2;
}

/* Editor - Tema escuro */
[data-theme="dark"] .rich-text-editor {
    border-color: #495057;
    background-color: #343a40;
}

[data-theme="dark"] .rich-text-toolbar {
    background-color: #495057;
    border-bottom-color: #6c757d;
}

[data-theme="dark"] .toolbar-btn {
    border-color: #6c757d;
    color: #f8f9fa;
}

[data-theme="dark"] .toolbar-btn:hover {
    background-color: #6c757d;
    color: white;
}

[data-theme="dark"] .rich-text-area {
    background-color: #343a40;
    color: #f8f9fa;
}

[data-theme="dark"] .char-counter {
    color: #adb5bd;
    background-color: rgba(52, 58, 64, 0.9);
}

/* ========================================
   16. MODAIS
   ======================================== */
.qr-code-container {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-body .alert {
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.modal-body .alert ol li {
    margin-bottom: 0.5rem;
}

#connectionModal .modal-dialog {
    max-width: 600px;
}

#changelogModal .modal-dialog {
    max-width: 800px;
}

#changelogModal .badge {
    min-width: 45px;
}

#changelogModal ul li {
    margin-bottom: 0.25rem;
    color: var(--text-secondary);
}

#changelogModal h6 {
    color: var(--text-primary);
    font-weight: 600;
}

.qr-code-container .badge {
    font-size: 0.75rem;
    padding: 0.5rem;
}

.navbar .badge {
    font-size: 0.8rem;
}

[data-theme="dark"] .modal-content {
    background-color: var(--bg-card);
    color: var(--text-primary);
}

/* ========================================
   17. ELEMENTOS DIVERSOS
   ======================================== */
.badge {
    transition: all 0.3s ease;
}

.stats-card {
    background: var(--bg-primary);
    color: white;
}

[data-theme="dark"] .progress {
    background-color: #444444;
}

[data-theme="dark"] .border {
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .bg-light {
    background-color: var(--upload-hover) !important;
}

/* ========================================
   18. ANIMAÇÕES
   ======================================== */
@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes pulse-connecting {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

@keyframes buttonPulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

#updateBanner {
    animation: slideDown 0.5s ease-out;
}

#updateBanner .btn {
    transition: all 0.2s ease;
}

#updateBanner .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* ========================================
   19. PWA E RESPONSIVIDADE
   ======================================== */
@media (display-mode: standalone) {
    body {
        user-select: none;
        -webkit-user-select: none;
    }

    .container-fluid {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
}

@media (max-width: 768px) {
    .theme-toggle {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
    }

    .container-fluid {
        padding-left: 10px;
        padding-right: 10px;
    }

    .card-body {
        padding: 1rem;
    }

    .table-responsive {
        font-size: 0.85rem;
    }
}