/* Variáveis de Cores (Dark Theme) */
:root {
    --bg-page: #1c1c1c;
    --bg-card: #242424;
    --bg-input: #1a1a1a;
    --border-color: #333333;
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --primary: #008844;
    --primary-hover: #00753a;
    --success: #16a34a;
    --warning: #ca8a04;
    --blue: #3b82f6;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-page);
    color: var(--text-main);
    padding-bottom: 100px; /* Espaço para a barra inferior */
}

/* Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.62);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}

.modal-backdrop.open {
    display: flex;
}

.modal {
    width: 100%;
    max-width: 520px;
    background: linear-gradient(180deg, rgba(36, 36, 36, 0.98), rgba(28, 28, 28, 0.98));
    border: 1px solid rgba(255, 255, 255, 0.10);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.55);
    padding: 18px;
    animation: modal-in 0.16s ease-out;
}

@keyframes modal-in {
    from { transform: translateY(6px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 12px;
}

.modal-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.10);
    background: rgba(255, 255, 255, 0.04);
    flex: 0 0 auto;
    font-size: 20px;
}

.modal-icon.info { color: var(--blue); }
.modal-icon.success { color: var(--success); }
.modal-icon.warning { color: var(--warning); }
.modal-icon.danger { color: #f87171; }

.modal-title {
    font-weight: 700;
    font-size: 1.05rem;
    line-height: 1.2;
}

.modal-subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 4px;
}

.modal-body {
    color: var(--text-main);
    font-size: 0.92rem;
    line-height: 1.45;
    padding: 10px 0 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 14px;
}

/* Tipografia e Utilidades */
.text-blue { color: var(--blue); }
.text-yellow { color: var(--warning); }
.text-green { color: var(--success); }
.section-title { margin: 24px 0 16px; font-size: 1.2rem; font-weight: 500; }

/* Header */
.topbar {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 18px 28px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.header-icon {
    background: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 10px 12px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
}

.header-logo img {
    display: block;
    width: 40px;
    height: 40px;
    object-fit: contain;
}
.topbar h1 { font-size: 1.4rem; }
.topbar p { color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }

/* Layout Principal */
main {
    max-width: 1000px;
    margin: 30px auto;
    padding: 0 14px;
}

@media (max-width: 900px) {
    main { padding: 0 10px; }
    .topbar { padding: 16px 18px; }
}

/* Cards e Upload */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
}
.upload-card {
    text-align: center;
    padding: 60px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.upload-card.is-processing {
    padding: 82px 20px;
    gap: 18px;
}

.upload-card.is-processing .upload-icon,
.upload-card.is-processing h2,
.upload-card.is-processing p {
    display: none;
}
.upload-icon {
    font-size: 48px;
    color: var(--text-muted);
    background: #2a2a2a;
    padding: 16px;
    border-radius: 50%;
    margin-bottom: 10px;
}

/* Botões */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 6px;
    border: none;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
}
.btn-primary { background-color: var(--primary); color: white; }
.btn-primary:hover { background-color: var(--primary-hover); }
.btn-secondary { background-color: transparent; color: var(--text-muted); border: 1px solid var(--border-color); }
.btn-secondary:hover { background-color: var(--bg-card); color: white; }
.btn-success { background-color: var(--success); color: white; }
.btn-success:hover { background-color: #15803d; }

/* Resumo (Summary Grid) */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 30px;
}

@media (max-width: 1050px) {
    .summary-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 680px) {
    .summary-grid { grid-template-columns: repeat(2, 1fr); }
}
.summary-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.summary-card i { font-size: 26px; background: rgba(255,255,255,0.05); padding: 10px; border-radius: 8px; }
.summary-card.warning { border-color: rgba(202, 138, 4, 0.3); }
.summary-card.success { border-color: rgba(22, 163, 74, 0.3); }
.summary-card span { display: block; color: var(--text-muted); font-size: 0.78rem; margin-bottom: 2px; }
.summary-card strong { display: block; font-size: 1.25rem; color: var(--text-main); }

/* Lista de Registros e Formulário */
.records-list { display: flex; flex-direction: column; gap: 16px; }
.record-item {
    background-color: var(--bg-card);
    border: 1px solid rgba(220, 38, 38, 0.4);
    border-radius: 12px;
    padding: 14px 16px;
    position: relative;
    overflow: hidden;
    transition: 0.3s;
}
.record-item.ignored {
    border-color: var(--border-color);
    opacity: 0.5;
}

/* Secao de Registros OK */
.ok-section {
    margin-top: 40px;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

.btn-collapse {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 15px 20px;
    border-radius: 8px;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    font-weight: 500;
    transition: 0.3s;
}

.btn-collapse-ok {
    color: #86efac;
}

.btn-collapse-ok i {
    color: #86efac;
}

.btn-collapse-ok:hover {
    color: #d1fae5;
}

.btn-collapse-ok:hover i {
    color: #d1fae5;
}

.btn-collapse:hover {
    background: rgba(255, 255, 255, 0.07);
    color: #fff;
}

.hidden {
    display: none;
}

/* Diferenciando visualmente o card OK do card de Erro */
.record-item.status-ok {
    border-color: rgba(22, 163, 74, 0.2); /* Bordinha verde discreta */
}

.record-item.status-ok::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background-color: var(--success); /* Barra lateral verde */
}

.ph-caret-down {
    transition: transform 0.3s;
}

.rotate-180 {
    transform: rotate(180deg);
}

/* Agrupamento por colaborador (matriz) */
.collab-group {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px;
    position: relative;
    overflow: hidden;
}

.collab-group.status-ok {
    border-color: rgba(22, 163, 74, 0.2);
}

.collab-group.status-ok::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background-color: var(--success);
}

.collab-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 8px;
}

.collab-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.collab-left {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.collab-id {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.95rem;
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    padding: 6px 10px;
    border-radius: 8px;
}

.pill {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
}

.pill-ok {
    border-color: rgba(22, 163, 74, 0.25);
    background: rgba(22, 163, 74, 0.12);
    color: #86efac;
}

.pill-warn {
    border-color: rgba(202, 138, 4, 0.35);
    background: rgba(202, 138, 4, 0.18);
    color: #fde68a;
    gap: 6px;
}

.collab-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.collab-id-edit {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.collab-id-edit input {
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 10px;
    border-radius: 8px;
    outline: none;
    min-width: 220px;
}

.collab-id-edit input:focus {
    border-color: var(--text-muted);
}

.ai-ref {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 0;
}

.ai-note {
    color: var(--text-muted);
    font-weight: 500;
}

.empty-state {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px;
    border: 1px dashed rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
}

.empty-state i {
    font-size: 28px;
}

.empty-state strong {
    display: block;
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.empty-state span {
    display: block;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Botao de upload: estado "processando" */
.btn-processing {
    padding: 16px 30px;
    min-height: 62px;
    min-width: 460px;
    border-radius: 14px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.18);
}

/* Sobrescreve o verde do .btn-primary durante processamento */
.btn.btn-processing {
    background-color: rgba(255, 255, 255, 0.03);
    color: #fff;
}

.btn-processing .ai-btn {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

/* Verde so no trilho do robo e na barra de progresso */
.btn-processing .ai-row {
    padding: 2px 2px 0;
}

.btn-processing .ai-progress {
    display: block;
    width: 100%;
    padding: 0 2px 2px;
}

.btn-processing .ai-row {
    display: flex;
    align-items: center;
    gap: 14px;
}

.btn-processing .ai-text-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    min-width: 0;
}

.btn-processing .ai-text {
    font-weight: 700;
    letter-spacing: 0.01em;
    font-size: 1.02rem;
    line-height: 1.1;
}

.btn-processing .ai-hi {
    font-weight: 900;
    color: #d1fae5;
    text-shadow: 0 0 18px rgba(167, 243, 208, 0.25);
}

.btn-processing .ai-sub {
    color: rgba(255, 255, 255, 0.82);
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.2;
}

.btn-processing .ai-track {
    position: relative;
    width: 128px;
    height: 40px;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(0, 136, 68, 0.95), rgba(0, 116, 58, 0.95));
    border: 1px solid rgba(255, 255, 255, 0.16);
    overflow: hidden;
}

.btn-processing .ai-progress-track {
    display: block;
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: rgba(0, 136, 68, 0.22);
    border: 1px solid rgba(0, 136, 68, 0.35);
    overflow: hidden;
}

.btn-processing .ai-progress-fill {
    display: block;
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(167, 243, 208, 0.95), rgba(34, 197, 94, 0.95));
    transition: width 0.35s ease;
}



.btn-processing .ai-progress-meta {
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.82rem;
    font-variant-numeric: tabular-nums;
}

.btn-processing .ai-progress-meta #progress-percent {
    min-width: 44px;
    text-align: right;
    color: rgba(209, 250, 229, 0.95);
    font-weight: 800;
}

.btn-processing .ai-track::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.14), transparent);
    animation: ai-sheen 1.6s linear infinite;
}

.btn-processing .ai-bot {
    position: absolute;
    top: 50%;
    left: 10px;
    transform: translateY(-50%);
    width: 34px;
    height: 28px;
    animation: ai-bot-run 1.55s ease-in-out infinite;
}

.btn-processing .ai-bot-emoji {
    display: inline-flex;
    width: 34px;
    height: 28px;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    line-height: 1;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.35));
    animation: bot-bob 0.9s ease-in-out infinite;
}

@keyframes ai-bot-run {
    0% { left: 10px; transform: translateY(-50%) translateX(0); }
    50% { left: calc(100% - 44px); transform: translateY(-50%) translateX(0); }
    100% { left: 10px; transform: translateY(-50%) translateX(0); }
}

@keyframes bot-bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
}

@keyframes ai-sheen {
    0% { transform: translateX(-60%); }
    100% { transform: translateX(60%); }
}

@media (max-width: 520px) {
    .btn-processing {
        min-width: 100%;
    }
}


.ai-ref .ai-name {
    color: var(--text-main);
    font-weight: 600;
}

.ai-label {
    color: #93c5fd;
    font-weight: 700;
}

.collab-table-wrap {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    background: rgba(0, 0, 0, 0.12);
}

.records-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 0;
    table-layout: fixed;
}

.records-table th,
.records-table td {
    min-width: 0;
}

.records-table thead th {
    text-align: left;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    padding: 10px 10px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
    position: sticky;
    top: 0;
}

/* Em telas menores, compacta um pouco mais */
@media (max-width: 820px) {
    .records-table thead th { padding: 10px 10px; }
    .records-table tbody td { padding: 8px 10px; }
    .cell-input { padding: 7px 7px; font-size: 0.9rem; }
}

.records-table tbody td {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    vertical-align: middle;
}

.cell-input {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 7px 6px;
    border-radius: 8px;
    outline: none;
}

.cell-input.error {
    border-color: rgba(220, 38, 38, 0.65);
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.10);
}

.cell-input {
    min-width: 0;
}

/* Inputs de hora (somente digitacao) */
.cell-time {
    font-variant-numeric: tabular-nums;
    text-align: center;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.95rem;
}

.cell-input:focus {
    border-color: var(--text-muted);
}

.issues-cell {
    min-width: auto;
    overflow: hidden;
    width: auto;
}

.issues-cell .issues-list {
    overflow: hidden;
}

.issues-list-compact {
    gap: 6px;
}

/* Em OK nao existe coluna de inconsistencias: nao deixar header vazio "puxar" */
.records-table thead th:empty {
    padding: 0;
    border: 0;
}

.actions-cell {
    width: auto;
    text-align: right;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    cursor: pointer;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.icon-btn.ok {
    border-color: rgba(22, 163, 74, 0.35);
    background: rgba(22, 163, 74, 0.10);
    color: #86efac;
}

.icon-btn.ok:hover {
    background: rgba(22, 163, 74, 0.18);
    color: #d1fae5;
}

.actions-cell {
    white-space: normal;
    text-align: right;
}

.row-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.row-actions-btns {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    white-space: nowrap;
    margin-left: auto;
}

tr.row-ignored {
    opacity: 0.5;
    background: rgba(255, 255, 255, 0.02);
}

tr.row-ignored .cell-input {
    pointer-events: none;
}

tr.row-ignored .icon-btn {
    pointer-events: auto;
}

.row-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    border: 1px solid rgba(255, 255, 255, 0.10);
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.03);
    margin-left: 0;
    margin-top: 0;
    max-width: 100%;
    white-space: normal;
}

.row-tag.inline {
    white-space: nowrap;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cell-date {
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.row-tag.deleted {
    border-color: rgba(220, 38, 38, 0.28);
    background: rgba(220, 38, 38, 0.14);
    color: #fca5a5;
}

.group-toggle {
    width: 36px;
    height: 36px;
}

.group-toggle i {
    transition: transform 0.2s;
    transform: rotate(180deg);
}

.group-collapsed .collab-table-wrap {
    display: none;
}

.group-collapsed .group-toggle i {
    transform: rotate(0deg);
}

/* Header do Card */
.record-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}
.record-info { display: flex; align-items: center; gap: 12px; }
.badge-id { background: var(--bg-page); color: var(--text-muted); padding: 4px 8px; border-radius: 4px; font-family: monospace; font-size: 0.85rem; }
.issues-list { display: flex; gap: 8px; flex-wrap: wrap; }
.badge-issue {
    background: rgba(220, 38, 38, 0.1);
    border: 1px solid rgba(220, 38, 38, 0.2);
    color: #f87171;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
}

/* Inconsistencias na tabela: quebra em ate 2 linhas (sem scroll) */
.records-table .badge-issue {
    white-space: normal;
    overflow-wrap: anywhere;
    max-width: 100%;
    line-height: 1.15;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Toggle Ignorar */
.ignore-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    pointer-events: auto; /* Garante que o checkbox funcione mesmo se o card estiver ignorado */
}
.ignore-toggle input { accent-color: var(--primary); width: 16px; height: 16px; cursor: pointer; }

/* Grid do Formulário Inline */
.form-grid {
    display: grid;
    grid-template-columns: 2fr 4fr 2fr 2fr;
    gap: 12px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 0.75rem; color: var(--text-muted); }
.form-group input {
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 10px;
    border-radius: 6px;
    outline: none;
}
.form-group input:focus { border-color: var(--text-muted); }
.form-group input.error { border-color: rgba(220, 38, 38, 0.6); }

.time-grid {
    grid-column: span 4;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    background: var(--bg-input);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-top: 8px;
}
.time-grid input { background-color: var(--bg-card); }

/* Barra de Ações (Footer) */
#action-bar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background-color: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 16px 40px;
    box-shadow: 0 -10px 30px rgba(0,0,0,0.5);
    z-index: 100;
}
.action-bar-content {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.status-badge {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 12px; border-radius: 20px; font-size: 0.85rem; font-weight: 500;
}
.warning-badge { background: rgba(202, 138, 4, 0.2); color: var(--warning); }
.success-badge { background: rgba(22, 163, 74, 0.2); color: var(--success); }
.action-buttons { display: flex; gap: 12px; }
