.wa-page { padding-bottom: 30px; }
.wa-heading { margin-bottom: 22px; }
.wa-layout {
    display: grid;
    grid-template-columns: minmax(220px, 290px) minmax(0, 1fr);
    gap: 18px;
    min-height: 620px;
}
.wa-sidebar, .wa-chat {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 10px;
    overflow: hidden;
}
.wa-sidebar { padding: 18px; }
.wa-sidebar h2, .wa-chat-header h2 { margin-top: 0; }
.wa-conversation {
    display: block;
    width: 100%;
    padding: 13px 10px;
    margin: 5px 0;
    text-align: left;
    border: 0;
    border-radius: 7px;
    background: #f5f5f5;
    cursor: pointer;
    color: inherit;
}
.wa-conversation:hover, .wa-conversation.active { background: #e5f2ec; }
.wa-conversation strong, .wa-conversation small { display: block; }
.wa-conversation small { margin-top: 5px; color: #666; }
.wa-chat { display: flex; flex-direction: column; min-width: 0; }
.wa-chat-header { padding: 18px 22px; border-bottom: 1px solid #ddd; }
.wa-chat-header p { margin-bottom: 0; color: #666; }
.wa-filters {
    display: grid;
    grid-template-columns: repeat(3, minmax(130px, 1fr));
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid #ddd;
    background: #fff;
}
.wa-filter { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.wa-filter label { font-size: .82rem; color: #555; }
.wa-filter input, .wa-filter select {
    box-sizing: border-box;
    width: 100%;
    min-height: 36px;
    padding: 7px 9px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fff;
    color: inherit;
}
.wa-filter-search { grid-column: span 2; }
.wa-filter-actions {
    display: flex;
    align-items: end;
    gap: 8px;
}
.wa-filter-actions button {
    min-height: 36px;
    padding: 7px 12px;
    border: 1px solid #bbb;
    border-radius: 6px;
    background: #f3f3f3;
    cursor: pointer;
}
.wa-filter-actions .wa-secondary { background: #fff; }
.wa-filter-status {
    margin: 0;
    padding: 0 18px;
    color: #555;
    font-size: .85rem;
}
.wa-filter-status:not(:empty) { padding-top: 9px; }
.wa-messages {
    flex: 1;
    padding: 18px;
    background: #f6f5f1;
    min-height: 420px;
}
.wa-message {
    max-width: 85%;
    width: fit-content;
    margin: 0 0 12px;
    padding: 11px 14px;
    background: #fff;
    border: 1px solid #e4e4e4;
    border-radius: 9px;
    overflow-wrap: anywhere;
}
.wa-message .meta { color: #666; font-size: .82rem; margin-bottom: 6px; }
.wa-message .sender { font-weight: 600; margin-right: 10px; }
.wa-message .body { white-space: pre-wrap; }
.wa-event {
    max-width: 90%;
    margin: 10px auto;
    padding: 8px 12px;
    text-align: center;
    color: #555;
    background: #e9e9e9;
    border-radius: 8px;
    font-size: .9rem;
}
.wa-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-top: 1px solid #ddd;
}
.wa-pagination button {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
}
.wa-pagination button:disabled { opacity: .45; cursor: default; }
@media (max-width: 900px) {
    .wa-filters { grid-template-columns: repeat(2, minmax(130px, 1fr)); }
}
@media (max-width: 760px) {
    .wa-layout { grid-template-columns: 1fr; }
    .wa-sidebar { max-height: 260px; overflow-y: auto; }
    .wa-message { max-width: 96%; }
    .wa-filter-search { grid-column: span 2; }
}

/* Multimedia integrada en mensajes WhatsApp */
.wa-media {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 10px;
    max-width: 100%;
}
.wa-media-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 100%;
}
.wa-media-label {
    color: #666;
    font-size: .78rem;
    overflow-wrap: anywhere;
}
.wa-media-image {
    display: block;
    max-width: min(100%, 420px);
    max-height: 420px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 7px;
}
.wa-media-audio {
    display: block;
    width: min(100%, 360px);
}
.wa-media-video {
    display: block;
    max-width: min(100%, 480px);
    max-height: 360px;
    width: 100%;
    border-radius: 7px;
    background: #111;
}
.wa-media-link {
    display: inline-block;
    overflow-wrap: anywhere;
}


/* B4.2: navegación entre Consulta y Análisis */
.wa-workspace-nav {
    display: flex;
    gap: 8px;
    padding: 10px 18px 0;
    border-bottom: 1px solid #ddd;
    background: #fff;
}
.wa-workspace-tab {
    padding: 10px 16px;
    border: 1px solid transparent;
    border-bottom: 3px solid transparent;
    border-radius: 7px 7px 0 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font: inherit;
}
.wa-workspace-tab:hover {
    background: #f5f5f5;
}
.wa-workspace-tab.active {
    border-bottom-color: #287653;
    background: #f5f8f6;
    font-weight: 600;
}
.wa-workspace-panel[hidden] {
    display: none !important;
}
.wa-analysis-placeholder {
    min-height: 300px;
    padding: 24px;
    background: #f6f5f1;
}
.wa-analysis-placeholder h3 {
    margin-top: 0;
}
.wa-analysis-placeholder p {
    color: #555;
}


/* B4.3: contraste del botón Aplicar filtros */
.wa-filter-actions #wa-apply {
    background: #287653;
    color: #fff;
    border-color: #1f6042;
    font-weight: 600;
}

.wa-filter-actions #wa-apply:hover {
    background: #1f6042;
}

.wa-filter-actions #wa-apply:focus-visible {
    outline: 3px solid #287653;
    outline-offset: 2px;
}


/* B4.3: interfaz de análisis */
.wa-analysis-header {
    padding: 20px 22px 8px;
}

.wa-analysis-header h3 {
    margin: 0 0 8px;
}

.wa-analysis-header p {
    margin: 0;
    color: #555;
}

.wa-analysis-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 14px;
    padding: 14px 22px;
    background: #f6f8f6;
    border-top: 1px solid #e2e7e3;
    border-bottom: 1px solid #e2e7e3;
}

.wa-analysis-filter {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 145px;
}

.wa-analysis-filter label {
    font-size: .88rem;
    font-weight: 600;
}

.wa-analysis-filter input,
.wa-analysis-filter select {
    min-height: 36px;
    padding: 6px 9px;
    border: 1px solid #bbb;
    border-radius: 5px;
    background: #fff;
    color: #222;
    font: inherit;
}

.wa-analysis-filter-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.wa-analysis-filter-actions button {
    min-height: 36px;
    padding: 7px 12px;
    border: 1px solid #bbb;
    border-radius: 6px;
    background: #f3f3f3;
    cursor: pointer;
}

.wa-analysis-filter-actions #wa-analysis-apply {
    background: #287653;
    color: #fff;
    border-color: #1f6042;
    font-weight: 600;
}

.wa-analysis-filter-actions #wa-analysis-apply:hover {
    background: #1f6042;
}

.wa-analysis-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px 18px 0;
    border-bottom: 1px solid #ddd;
    background: #fff;
}

.wa-analysis-tab {
    padding: 9px 13px;
    border: 1px solid transparent;
    border-bottom: 3px solid transparent;
    border-radius: 6px 6px 0 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font: inherit;
}

.wa-analysis-tab:hover {
    background: #f5f5f5;
}

.wa-analysis-tab.active {
    border-bottom-color: #287653;
    background: #f5f8f6;
    font-weight: 600;
}

.wa-analysis-status {
    margin: 16px 22px 0;
    padding: 10px 12px;
    border-radius: 5px;
    background: #f6f5f1;
    color: #444;
}

.wa-analysis-results {
    padding: 18px 22px 24px;
}

.wa-analysis-view h4 {
    margin-top: 0;
}

.wa-analysis-view[hidden] {
    display: none !important;
}

@media (max-width: 700px) {
    .wa-analysis-filters {
        align-items: stretch;
        flex-direction: column;
    }

    .wa-analysis-filter {
        width: 100%;
    }

    .wa-analysis-filter input,
    .wa-analysis-filter select {
        width: 100%;
        box-sizing: border-box;
    }

    .wa-analysis-nav {
        gap: 3px;
        padding-right: 8px;
        padding-left: 8px;
    }

    .wa-analysis-tab {
        padding: 8px 9px;
        font-size: .9rem;
    }

    .wa-analysis-results {
        padding-right: 14px;
        padding-left: 14px;
    }
}

/* B4.3: presentación mejorada de análisis */
.wa-analysis-section {
    margin: 0 0 20px;
    padding: 14px;
    border: 1px solid #e1e5e2;
    border-radius: 7px;
    background: #fff;
    min-width: 0;
}

.wa-analysis-section h5 {
    margin: 0 0 12px;
    color: #294b3b;
    font-size: 1rem;
}

.wa-analysis-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.wa-analysis-metric {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
    border: 1px solid #e5e9e6;
    border-radius: 6px;
    background: #f8faf8;
    min-width: 0;
}

.wa-analysis-metric-label {
    color: #59645d;
    font-size: .88rem;
}

.wa-analysis-metric-value {
    color: #244b37;
    font-size: 1.2rem;
    overflow-wrap: anywhere;
}

.wa-analysis-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .92rem;
}

.wa-analysis-table th,
.wa-analysis-table td {
    padding: 9px 10px;
    border-bottom: 1px solid #e5e9e6;
    text-align: left;
    overflow-wrap: anywhere;
}

.wa-analysis-table th {
    background: #f2f6f3;
    color: #344b3d;
    font-weight: 600;
}

.wa-analysis-table tbody tr:hover {
    background: #f8faf8;
}

.wa-analysis-chart {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.wa-analysis-chart-row {
    display: grid;
    grid-template-columns: minmax(90px, 150px) minmax(50px, 1fr) 42px;
    align-items: center;
    gap: 10px;
}

.wa-analysis-chart-label {
    font-size: .85rem;
    overflow-wrap: anywhere;
}

.wa-analysis-chart-track {
    height: 13px;
    overflow: hidden;
    border-radius: 8px;
    background: #edf1ee;
}

.wa-analysis-chart-bar {
    display: block;
    height: 100%;
    border-radius: 8px;
    background: #287653;
}

.wa-analysis-chart-value {
    text-align: right;
    font-size: .85rem;
}

@media (max-width: 700px) {
    .wa-analysis-table {
        font-size: .82rem;
    }

    .wa-analysis-table th,
    .wa-analysis-table td {
        padding: 7px 6px;
    }

    .wa-analysis-chart-row {
        grid-template-columns: minmax(75px, 105px) minmax(35px, 1fr) 32px;
        gap: 6px;
    }

    .wa-analysis-section {
        padding: 10px;
    }
}
