/* ============================================================================
   ANALISADOR DE ERROS ADVANCECARE — WEB (style.css)
   Extraído de analisar_erros_v3.py
   ============================================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f2f5;
    color: #333;
    padding: 20px;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
}

/* ---- Header ---- */
.report-header {
    background: linear-gradient(135deg, #1e3a5f 0%, #2d5a8e 100%);
    color: white;
    padding: 20px 30px;
    border-radius: 12px;
    margin-bottom: 24px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 15px;
}

.report-header h1 {
    font-size: 24px;
    margin-bottom: 4px;
}

.report-header .subtitle {
    opacity: 0.85;
    font-size: 13px;
}

.report-header .version {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    margin-left: 8px;
    vertical-align: middle;
}

.header-user {
    text-align: right;
    font-size: 13px;
    opacity: 0.9;
}

.header-user a {
    color: #ffd54f;
    text-decoration: none;
    font-weight: 500;
}

.header-user a:hover {
    text-decoration: underline;
}

.header-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.header-actions button {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: transform 0.15s, opacity 0.15s;
    background: rgba(255,255,255,0.15);
    color: #fff;
}

.header-actions button:hover {
    transform: translateY(-1px);
    opacity: 0.9;
}

.header-actions .btn-primary { background: #1565c0; }
.header-actions .btn-warning { background: #e65100; }
.header-actions .btn-success { background: #2e7d32; }

.header-search {
    display: flex;
    align-items: center;
}

.header-search input {
    padding: 8px 12px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px 0 0 4px;
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 13px;
    outline: none;
}

.header-search input::placeholder { color: rgba(255,255,255,0.6); }
.header-search input:focus { background: rgba(255,255,255,0.2); }

.header-search button {
    padding: 8px 12px;
    border: 1px solid rgba(255,255,255,0.3);
    border-left: none;
    border-radius: 0 4px 4px 0;
    background: rgba(255,255,255,0.2);
    cursor: pointer;
    color: white;
}
.header-search button:hover { background: rgba(255,255,255,0.3); }

.header-search .clear-btn {
    text-decoration: none;
    color: #ff8a80;
    margin-left: 8px;
    font-weight: bold;
    font-size: 16px;
    line-height: 1;
}

/* ---- Summary cards ---- */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    text-align: center;
}

.card .number {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 4px;
}

.card .label {
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card.success .number {
    color: #27ae60;
}

.card.error .number {
    color: #e74c3c;
}

.card.info .number {
    color: #3498db;
}

.card.warning .number {
    color: #f39c12;
}

/* ---- Sections ---- */
.section {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 24px;
    overflow: hidden;
}

.section-header {
    background: #f8f9fa;
    padding: 16px 20px;
    border-bottom: 1px solid #e9ecef;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.section-header:hover {
    background: #e9ecef;
}

.section-body {
    padding: 0;
}

.section-body.collapsed {
    display: none;
}

/* ---- Tables ---- */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

th {
    background: #f1f3f5;
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
    position: sticky;
    top: 0;
}

td {
    padding: 6px 10px;
    border-bottom: 1px solid #f1f3f5;
    vertical-align: top;
}

tr:hover {
    background: #f8f9fa;
}

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-error {
    background: #f8d7da;
    color: #721c24;
}

.badge-warning {
    background: #fff3cd;
    color: #856404;
}

.badge-info {
    background: #d1ecf1;
    color: #0c5460;
}

/* ---- Error categories ---- */
.error-category {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    border-bottom: 1px solid #f1f3f5;
}

.error-category:last-child {
    border-bottom: none;
}

.error-category .cat-name {
    font-size: 14px;
}

.error-category .cat-count {
    background: #e74c3c;
    color: white;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

/* ---- Success ---- */
.file-success {
    padding: 12px 20px;
    border-bottom: 1px solid #f1f3f5;
    color: #27ae60;
    display: flex;
    align-items: center;
    gap: 8px;
}

.file-success:last-child {
    border-bottom: none;
}

/* ---- Data comparison boxes ---- */
.data-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 4px 0;
}

.data-box {
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 11px;
}

.data-box .box-title {
    font-weight: 700;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 4px;
}

.data-box .box-title:hover {
    opacity: 0.8;
}

.box-toggle {
    font-size: 9px;
    transition: transform 0.15s;
}

.box-body.collapsed {
    display: none;
}

.data-box .row {
    margin-bottom: 2px;
}

.data-box .label {
    color: inherit;
    font-weight: 600;
    display: inline-block;
    min-width: 100px;
    opacity: 0.7;
}

.data-box .value {
    color: inherit;
}

/* Enrollment box - verde */
.enrollment-box {
    background: #e8f5e9;
    border-left: 4px solid #43a047;
}

.enrollment-box .box-title {
    color: #2e7d32;
}

/* BD box - azul */
.bd-box {
    background: #e3f2fd;
    border-left: 4px solid #1976d2;
}

.bd-box .box-title {
    color: #1565c0;
}

.no-data {
    color: #999;
    font-style: italic;
    font-size: 11px;
}

/* ---- Divergências ---- */
.divergencia {
    background: #fff3cd !important;
    border-left: 3px solid #f39c12;
}

.divergencia-label {
    color: #e67e22;
    font-weight: 700;
    font-size: 10px;
}

.divergencias-list {
    margin-top: 4px;
    padding: 4px 8px;
    background: #fff8e1;
    border-radius: 4px;
    font-size: 10px;
}

.divergencias-list li {
    color: #e65100;
    margin-bottom: 2px;
    list-style-type: none;
}

.divergencias-list li::before {
    content: '⚠ ';
}

/* ---- Toggle ---- */
.toggle-btn {
    font-size: 18px;
    transition: transform 0.2s;
}

.toggle-btn.collapsed {
    transform: rotate(-90deg);
}

/* ---- Row-level collapse ---- */
/* First TR of each member group has cursor pointer and a small arrow */
tr.row-collapsible {
    cursor: pointer;
}

tr.row-collapsible:hover td {
    background: #eef3fb;
}

.row-toggle {
    font-size: 9px;
    display: inline-block;
    margin-right: 4px;
    color: #888;
    transition: transform 0.15s;
    vertical-align: middle;
}

/* Hides the content of the detail+reenvio TDs but keeps the cells */
.detail-collapsed .data-compare,
.detail-collapsed .data-box,
.detail-collapsed>* {
    display: none !important;
}

/* ---- Reenvio box - laranja ---- */
.reenvio-box {
    background: #fff3e0;
    border-left: 4px solid #ef6c00;
    margin-top: 8px;
}

.reenvio-box .box-title {
    color: #e65100;
}

.reenvio-entry {
    padding: 6px 0;
    border-bottom: 1px dashed rgba(0, 0, 0, 0.1);
}

.reenvio-entry:last-child {
    border-bottom: none;
}

.reenvio-status-ok {
    color: #2e7d32;
    font-weight: 700;
}

.reenvio-status-err {
    color: #c62828;
    font-weight: 700;
}

.reenvio-status-pending {
    color: #f57f17;
    font-weight: 700;
}

/* ---- Botão de correção ---- */
.btn-corrigir {
    background: linear-gradient(135deg, #43a047, #2e7d32);
    color: white;
    border: none;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    transition: all 0.2s;
}

.btn-corrigir:hover {
    background: linear-gradient(135deg, #2e7d32, #1b5e20);
    transform: scale(1.05);
}

.btn-corrigir:disabled {
    background: #bbb;
    cursor: default;
    transform: none;
}

.btn-corrigir.done {
    background: #66bb6a;
}

.btn-corrigir.ignored {
    background: #78909c;
}

/* ---- Botão de ignorar ---- */
.btn-ignorar {
    background: linear-gradient(135deg, #78909c, #546e7a);
    color: white;
    border: none;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
    transition: all 0.2s;
    margin-top: 4px;
    width: 100%;
}

.btn-ignorar:hover {
    background: linear-gradient(135deg, #546e7a, #455a64);
    transform: scale(1.02);
}

.btn-ignorar:disabled {
    background: #bbb;
    cursor: default;
    transform: none;
}

/* ---- Color dot ---- */
.color-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 6px;
}

/* ---- Toast notification ---- */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #2e7d32;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    z-index: 9999;
    font-size: 13px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ---- Loading spinner ---- */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.loading-spinner {
    text-align: center;
    font-size: 18px;
    color: #1e3a5f;
}

.loading-spinner .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #ddd;
    border-top: 4px solid #1e3a5f;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ---- Print ---- */
@media print {
    body {
        background: white;
    }

    .section-body.collapsed {
        display: block !important;
    }

    .btn-corrigir {
        display: none;
    }
}