/**
 * LeadRouter WhatsApp Pro - Master Stylesheet
 * VERSÃO 7.4.0
 * Autor: Dtech Sites
 */

:root {
    --lr-primary: #2271b1;
    --lr-success: #25D366;
    --lr-success-dark: #108738;
    --lr-danger: #d63638;
    --lr-warning: #ffb900;
    --lr-bg: #f0f2f5;
    --lr-white: #ffffff;
    --lr-shadow: 0 4px 15px rgba(0,0,0,0.08);
    --lr-radius: 10px;
    --lr-text: #2c3e50;
}
/*------Botao Confirmação Whats-----------------*/
.lr-phone-popup-overlay{
    position:fixed;
    inset:0;
    background:rgba(0,0,0,.58);
    backdrop-filter:blur(6px);
    -webkit-backdrop-filter:blur(6px);
    display:none;
    align-items:center;
    justify-content:center;
    z-index:999999;
    padding:18px;
}

.lr-phone-popup-overlay[style*="flex"] .lr-phone-popup{
    animation:lrPopupIn .24s ease-out both;
}

@keyframes lrPopupIn{
    from{
        opacity:0;
        transform:translateY(18px) scale(.96);
    }
    to{
        opacity:1;
        transform:translateY(0) scale(1);
    }
}

.lr-phone-popup{
    background:#ffffff;
    width:100%;
    max-width:420px;
    border-radius:24px;
    padding:32px 28px 28px;
    box-shadow:0 24px 70px rgba(0,0,0,.24);
    font-family:Arial,sans-serif;
    border:1px solid rgba(34,197,94,.18);
    text-align:center;
}

.lr-phone-popup::before{
    content:"💬";
    width:64px;
    height:64px;
    background:linear-gradient(135deg,#dcfce7,#bbf7d0);
    color:#16a34a;
    border-radius:50%;
    display:flex;
    align-items:center;
    justify-content:center;
    font-size:30px;
    margin:0 auto 18px;
    box-shadow:0 10px 24px rgba(34,197,94,.18);
}

.lr-phone-popup h3{
    margin:0 0 10px;
    font-size:24px;
    font-weight:800;
    color:#111827;
}

.lr-phone-popup p{
    margin:0 auto 22px;
    color:#4b5563;
    font-size:15px;
    line-height:1.5;
    max-width:340px;
}

.lr-phone-popup input{
    width:100%;
    height:56px;
    border:2px solid #dcfce7;
    background:#f9fafb;
    border-radius:16px;
    padding:0 18px;
    font-size:18px;
    box-sizing:border-box;
    margin-bottom:16px;
    outline:none;
    text-align:center;
    font-weight:700;
    color:#111827;
    transition:.2s ease;
}

.lr-phone-popup input:focus{
    border-color:#22c55e;
    background:#ffffff;
    box-shadow:0 0 0 5px rgba(34,197,94,.13);
}

.lr-phone-popup-actions{
    display:flex;
    gap:12px;
}

.lr-phone-popup-actions button{
    flex:1;
    height:52px;
    border:0;
    border-radius:16px;
    font-size:16px;
    font-weight:800;
    cursor:pointer;
    transition:.18s ease;
}

.lr-phone-cancel{
    background:#f3f4f6;
    color:#374151;
}

.lr-phone-cancel:hover{
    background:#e5e7eb;
}

.lr-phone-confirm{
    background:linear-gradient(135deg,#22c55e,#16a34a);
    color:#fff;
    box-shadow:0 12px 24px rgba(34,197,94,.26);
}

.lr-phone-confirm:hover{
    transform:translateY(-1px);
    box-shadow:0 16px 30px rgba(34,197,94,.34);
}

@media (max-width:480px){
    .lr-phone-popup-overlay{
        align-items:flex-end;
        padding:12px;
    }

    .lr-phone-popup{
        max-width:100%;
        border-radius:24px 24px 18px 18px;
        padding:28px 20px 22px;
    }

    .lr-phone-popup h3{
        font-size:22px;
    }

    .lr-phone-popup p{
        font-size:14px;
    }

    .lr-phone-popup-actions{
        flex-direction:column-reverse;
    }

    .lr-phone-popup-actions button{
        width:100%;
    }
}

/* ==========================================================================
   TABELAS DE MOTIVOS DE PERDA E FORA DO CATÁLOGO
   ========================================================================== */
.lr-motivos-table,
.lr-fora-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.lr-motivos-table th,
.lr-fora-table th {
    background: #f8f9fa;
    padding: 12px 10px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #e9ecef;
}

.lr-motivos-table td,
.lr-fora-table td {
    padding: 10px 10px;
    border-bottom: 1px solid #e9ecef;
    vertical-align: middle;
}

/* Larguras específicas */
.lr-motivos-table th:nth-child(1),
.lr-fora-table th:nth-child(1) { width: 10%; text-align: center; }
.lr-motivos-table th:nth-child(2),
.lr-fora-table th:nth-child(2) { width: 6%; text-align: center; }
.lr-motivos-table th:nth-child(3),
.lr-fora-table th:nth-child(3) { width: 20%; }
.lr-motivos-table th:nth-child(4),
.lr-fora-table th:nth-child(4) { width: 20%; }
.lr-motivos-table th:nth-child(5),
.lr-fora-table th:nth-child(5) { width: 34%; }
.lr-motivos-table th:nth-child(6),
.lr-fora-table th:nth-child(6) { width: 10%; text-align: center; }

/* Colunas de data e ID centralizadas */
.lr-motivos-table td:nth-child(1),
.lr-motivos-table td:nth-child(2),
.lr-fora-table td:nth-child(1),
.lr-fora-table td:nth-child(2) {
    text-align: center;
}

/* Badge de motivo */
.motivo-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 11px;
    font-weight: 500;
}

.motivo-preco { background: #fff3cd; color: #856404; }
.motivo-fora { background: #fef2f2; color: #dc2626; }
.motivo-outro { background: #e3f2fd; color: #1565c0; }

/* Link do lead */
.lr-lead-link {
    color: #2271b1;
    text-decoration: none;
    font-weight: 600;
}
.lr-lead-link:hover {
    text-decoration: underline;
    color: #135e96;
}

/* Responsivo */
@media (max-width: 900px) {
    .lr-motivos-table,
    .lr-fora-table {
        font-size: 11px;
    }
    .lr-motivos-table th,
    .lr-fora-table th,
    .lr-motivos-table td,
    .lr-fora-table td {
        padding: 8px 5px;
    }
}

@media (max-width: 768px) {
    .lr-motivos-table,
    .lr-fora-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

/* ==========================================================================
   BASE & RESET
   ========================================================================== */
.lr-admin-wrapper, .lr-wrap {
    margin: 20px;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--lr-text);
}

/* ==========================================================================
   FRONTEND: Botão de Orçamento
   ========================================================================== */
.lr-btn-orcamento {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--lr-success-dark) !important;
    color: #ffffff !important;
    padding: 12px 24px;
    border-radius: var(--lr-radius);
    font-weight: 600;
    text-decoration: none !important;
    transition: all 0.3s ease;
    gap: 10px;
    box-shadow: 0 2px 6px rgba(16, 135, 56, 0.2);
}

.lr-btn-orcamento:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(16, 135, 56, 0.3);
}

/* ==========================================================================
   DASHBOARD: Header & KPI Cards
   ========================================================================== */
.lr-top-header {
    background: var(--lr-white);
    padding: 15px 25px;
    border-radius: var(--lr-radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 4px solid var(--lr-success);
    margin-bottom: 20px;
    box-shadow: var(--lr-shadow);
}

/* Grid de Cards - Responsivo */
.lr-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.lr-card {
    background: var(--lr-white);
    padding: 20px;
    border-radius: var(--lr-radius);
    border-top: 4px solid var(--lr-primary);
    text-align: center;
    box-shadow: var(--lr-shadow);
}

.lr-card h3 { margin: 0 0 8px; font-size: 11px; color: #666; text-transform: uppercase; letter-spacing: 0.5px; }
.lr-card .val { font-size: 24px; font-weight: 800; color: var(--lr-text); }
.lr-card .sub-val { font-size: 11px; font-weight: bold; padding: 3px 8px; border-radius: 12px; background: #e3f2fd; color: var(--lr-primary); margin-top: 5px; }

/* ==========================================================================
   GRÁFICOS (Layout Flexbox Responsivo)
   ========================================================================== */
.lr-charts-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
}

.lr-chart-item {
    flex: 1;
    min-width: 350px;
    background: var(--lr-white);
    padding: 25px;
    border-radius: var(--lr-radius);
    box-shadow: var(--lr-shadow);
    text-align: center;
}

.lr-chart-legend-text {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
}

/* ==========================================================================
   TABELAS & PAINÉIS
   ========================================================================== */
.lr-panel {
    background: var(--lr-white);
    padding: 20px;
    border-radius: var(--lr-radius);
    box-shadow: var(--lr-shadow);
    margin-bottom: 20px;
    overflow-x: auto;
}

/* ================================
   TABELA HISTÓRICO
================================ */
.historico-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 13px;
}

.historico-table th {
    background: #f8fafc;
    color: #374151;
    font-weight: 600;
    text-align: left;
    padding: 10px 8px;
    border-bottom: 2px solid #e5e7eb;
}

.historico-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #f1f5f9;
    color: #374151;
    text-align: left;
    vertical-align: middle;
}

.historico-table tbody tr:hover {
    background: #f9fafb;
}

/* COLUNAS */
.checkbox-col { width: 40px; text-align: center; }
.data-col { width: 130px; }
.id-col { width: 70px; }
.telefone-col { width: 140px; }
.vendedor-col { width: 140px; }
.origem-col { width: 130px; }
.status-col { width: 130px; }
.tempo-col { width: 90px; }
.acoes-col { width: 140px; }
.produto-col { width: auto; }

/* ==========================================================================
   BOTÕES E TOOLTIPS
   ========================================================================== */

/* Container dos botões */
.action-buttons {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* BOTÃO PADRÃO */
.action-btn {
    position: relative;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    text-decoration: none;
    border: 1px solid #e5e5e5;
    background: #fff;
    transition: all .2s ease;
    cursor: pointer;
}

/* ÍCONE */
.action-btn .icon {
    font-size: 15px;
    line-height: 1;
}

/* HOVER */
.action-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

/* 🔥 TOOLTIP ACIMA */
.action-btn[data-tooltip]::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 10px;
    padding: 6px 12px;
    background: #1a1a2e;
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    pointer-events: none;
}

.action-btn[data-tooltip]::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 4px;
    border-width: 5px;
    border-style: solid;
    border-color: #1a1a2e transparent transparent transparent;
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.action-btn[data-tooltip]:hover::before,
.action-btn[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
}

/* CORES POR AÇÃO */
.btn-excluir,
.btn-delete {
    background: linear-gradient(135deg, #fee2e2, #fecaca);
    color: #991b1b;
    border-color: #fecaca;
}

.btn-change-vendedor,
.btn-vendedor {
    background: linear-gradient(135deg, #f9fafb, #e5e7eb);
    color: #374151;
    border-color: #e5e7eb;
}

.btn-finalizar,
.btn-status {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #ffffff;
    border: none;
}

.btn-finalizar:hover,
.btn-status:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
}

.btn-finalizar-finalizado {
    background: #e5e7eb;
    color: #6b7280;
    border: none;
}

.btn-reopen {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #92400e;
    border-color: #fde68a;
}

/* HOVER específicos */
.btn-delete:hover,
.btn-excluir:hover {
    background: #fee2e2;
}

.btn-vendedor:hover,
.btn-change-vendedor:hover {
    background: #e3f2fd;
}

.btn-status:hover {
    background: #e8f5e9;
}

.btn-reopen:hover {
    background: #fff3e0;
}

/* Ações fixas */
.acoes-col {
    min-width: 130px;
}

@media (min-width: 900px) {
    .acoes-col {
        position: sticky;
        right: 0;
        background: #fff;
        box-shadow: -4px 0 6px rgba(0,0,0,0.05);
    }
}

/* STATUS BADGE */
.badge {
    padding: 6px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.badge-aguardando {
    background: #fef3c7;
    color: #92400e;
}

.badge-em_atendimento {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-finalizado {
    background: #dcfce7;
    color: #166534;
}

/* ==========================================================================
   MODAIS & UI COMPONENTS
   ========================================================================== */
.filter-bar {
    background: #fff;
    padding: 15px;
    border-radius: var(--lr-radius);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    box-shadow: var(--lr-shadow);
}

.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(3px);
}

.modal-content {
    background: #fff;
    margin: 10% auto;
    padding: 30px;
    border-radius: var(--lr-radius);
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

/* ==========================================================================
   📱 RESPONSIVIDADE (MOBILE & TABLET)
   ========================================================================== */
@media (max-width: 992px) {
    .lr-card-grid { grid-template-columns: repeat(4, 1fr); }
    .lr-chart-item { min-width: 100%; }
}

@media (max-width: 768px) {
    .lr-card-grid { grid-template-columns: repeat(2, 1fr); }
    .lr-top-header { flex-direction: column; gap: 15px; text-align: center; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .ranking-table, .historico-table { display: block; overflow-x: auto; }
}

/* ==========================================================================
   🖨️ IMPRESSÃO A4 PROFISSIONAL
   ========================================================================== */
@media print {

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        box-sizing: border-box !important;
    }

    html, body {
        width: 210mm;
        height: 297mm;
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
        font-size: 10px !important;
    }

    #adminmenumain, #wpadminbar, #wpfooter,
    .filter-bar, .bulk-actions, .pagination,
    .modal, button, .action-buttons, .button {
        display: none !important;
    }

    #wpcontent, #wpbody-content {
        margin: 0 !important;
        padding: 0 !important;
    }

    .lr-wrap {
        width: 100% !important;
        padding: 4mm 3mm !important;
    }

    /* Header */
    .lr-top-header {
        display: grid !important;
        grid-template-columns: 1fr auto 1fr !important;
        align-items: center !important;
        border-bottom: 2px solid #28a745 !important;
        margin-bottom: 8px !important;
        padding-bottom: 5px !important;
    }

    .lr-top-header img {
        max-height: 38px !important;
        width: auto !important;
    }

    .lr-top-header img:first-child {
        justify-self: start !important;
    }

    .lr-top-header img:last-child {
        justify-self: end !important;
    }

    .lr-top-header h1 {
        font-size: 15px !important;
        text-align: center !important;
        margin: 0 !important;
        justify-self: center !important;
    }

    /* Cards */
    .lr-card-grid {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 5px !important;
        margin-bottom: 6px !important;
    }

    .lr-card {
        padding: 6px !important;
        border: 1px solid #ddd !important;
        text-align: center !important;
    }

    .lr-card h3 {
        font-size: 9px !important;
        margin: 0 !important;
    }

    .lr-card strong {
        font-size: 13px !important;
    }

    /* Gráficos centralizados */
    .lr-charts-row {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        gap: 10px !important;
        justify-content: center !important;
        align-items: center !important;
        text-align: center !important;
    }

    .lr-chart-item {
        flex: 1 !important;
        min-width: 0 !important;
        max-width: 48% !important;
        width: 48% !important;
        border: 1px solid #eee !important;
        box-shadow: none !important;
        break-inside: avoid;
        margin: 0 auto !important;
        text-align: center !important;
    }

    .lr-chart-item canvas {
        margin: 0 auto !important;
        display: block !important;
        max-width: 100% !important;
        height: auto !important;
    }

    .lr-chart-legend-text {
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        align-items: center !important;
        text-align: center !important;
        margin-top: 10px !important;
    }

    /* Tabelas */
    table {
        width: 100% !important;
        border-collapse: collapse !important;
        font-size: 8.5px !important;
        margin-top: 6px !important;
    }

    th, td {
        padding: 4px !important;
        border: 1px solid #ddd !important;
        text-align: center !important;
    }

    thead {
        background: #f2f2f2 !important;
    }

    /* Remove checkbox e ações */
    th:first-child,
    td:first-child,
    th:last-child,
    td:last-child {
        display: none !important;
    }

    tr {
        page-break-inside: avoid !important;
    }

    /* Seções */
    .lr-section {
        margin-bottom: 6px !important;
    }

    h2, h3 {
        font-size: 11px !important;
        margin: 4px 0 !important;
    }

    .lr-section:last-child {
        max-height: 90mm !important;
        overflow: hidden !important;
    }

    .lr-section:last-child table {
        font-size: 7.5px !important;
    }

    .lr-section:last-child td {
        padding: 3px !important;
        word-break: break-word !important;
    }
}