/* escala.css — CSS especifico da escala mensal */
.content { max-width: 1100px; margin: 20px auto; padding: 0 12px; }

/* Month navigation */
.month-nav { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 16px; background: white; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
.month-nav button { background: none; border: 2px solid var(--azul); color: var(--azul); border-radius: 7px; padding: 6px 14px; font-family: var(--font); font-weight: 700; font-size: 13px; cursor: pointer; }
.month-nav button:hover { background: var(--azul); color: white; }
.month-nav .month-label { font-size: 18px; font-weight: 800; min-width: 200px; text-align: center; }

/* Legend */
.legend { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 16px; }
.legend-item { display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; color: var(--cinza-700); }
.legend-dot { width: 14px; height: 14px; border-radius: 4px; }

/* Table */
.tbl-wrap { background: white; border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { background: var(--cinza-50); padding: 10px 12px; font-weight: 700; text-align: left; border-bottom: 2px solid var(--cinza-300); font-size: 12px; text-transform: uppercase; letter-spacing: .3px; color: var(--cinza-700); white-space: nowrap; }
thead th:first-child { width: 100px; }
tbody tr { border-bottom: 1px solid var(--cinza-100); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--cinza-50); }
tbody tr.feriado { background: var(--vermelho-claro); }
tbody tr.feriado:hover { background: #FFCDD2; }
tbody tr.hoje { background: var(--azul-claro); }
tbody tr.hoje:hover { background: #BBDEFB; }
td { padding: 8px 12px; vertical-align: middle; }
td:first-child { font-weight: 700; white-space: nowrap; }
.dia-num { font-size: 15px; font-weight: 800; }
.dia-sem { font-size: 10px; color: var(--cinza-500); text-transform: uppercase; font-weight: 600; }
.feriado-label { font-size: 10px; color: var(--vermelho); font-weight: 600; display: block; margin-top: 2px; }

/* City chips */
.chip { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.chip-mossoro  { background: var(--azul-claro);    color: var(--azul); }
.chip-alto     { background: var(--verde-claro);   color: var(--verde); }
.chip-apodi    { background: var(--roxo-claro);    color: var(--roxo); }
.chip-assu     { background: var(--teal-claro);    color: var(--teal); }
.chip-caraubas { background: var(--laranja-claro); color: var(--laranja); }
.chip-upanema  { background: var(--amarelo-claro); color: var(--amarelo); }
.chip-viagem   { background: var(--cinza-100);     color: var(--cinza-700); }
.chip-feriado  { background: var(--vermelho-claro); color: var(--vermelho); }

@media(max-width:700px) {
  table { font-size: 12px; }
  .chip { font-size: 10px; padding: 2px 7px; }
  td, thead th { padding: 6px 8px; }
}

/* Botao editar e ajuda */
#btn-editar-escala { margin-left: 8px; background: none; border: 2px solid var(--cinza-300); color: var(--cinza-700); border-radius: 7px; padding: 6px 14px; font-family: var(--font); font-weight: 700; font-size: 13px; cursor: pointer; transition: .15s; }
#btn-editar-escala:hover { border-color: var(--azul); color: var(--azul); }
#btn-editar-escala.ativo { border-color: var(--vermelho); color: var(--vermelho); }
#btn-ajuda-escala { margin-left: 4px; background: none; border: 2px solid var(--cinza-300); color: var(--cinza-500); border-radius: 50%; width: 30px; height: 30px; font-family: var(--font); font-weight: 800; font-size: 14px; cursor: pointer; transition: .15s; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
#btn-ajuda-escala:hover { border-color: var(--azul); color: var(--azul); }
#btn-ajuda-escala.ativo { border-color: var(--azul); background: var(--azul-claro); color: var(--azul); }

/* Painel de ajuda */
#escala-ajuda-panel { display: flex; gap: 16px; flex-wrap: wrap; background: var(--azul-claro); border: 1.5px solid var(--azul); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 16px; }
.ajuda-bloco { flex: 1; min-width: 220px; }
.ajuda-bloco strong { display: block; font-size: 13px; color: var(--azul); margin-bottom: 8px; }
.ajuda-bloco ol { margin: 0; padding-left: 18px; }
.ajuda-bloco li { font-size: 12px; color: var(--cinza-700); line-height: 1.6; }
.ajuda-bloco kbd { display: inline-block; background: white; border: 1px solid var(--cinza-300); border-radius: 4px; padding: 1px 5px; font-family: var(--font); font-size: 11px; font-weight: 700; color: var(--cinza-900); }

/* Edit mode — cabecalhos e celulas clicaveis */
.tbl-wrap.edit-mode th.th-adv { cursor: pointer; transition: background .15s; }
.tbl-wrap.edit-mode th.th-adv:hover { background: #E3F2FD !important; }
.tbl-wrap.edit-mode td.td-adv:not(.td-feriado):not(.td-batch-col):not(.td-batch-other) { cursor: pointer; }
.tbl-wrap.edit-mode td.td-adv:not(.td-feriado):not(.td-batch-col):not(.td-batch-other):hover { background: #FFF9C4 !important; box-shadow: inset 0 0 0 2px #F9A825; }

/* Batch mode — estados de coluna */
th.th-batch-active { background: var(--azul-claro) !important; color: var(--azul) !important; box-shadow: inset 0 -3px 0 var(--azul); }
th.th-batch-inactive { opacity: .4; }
td.td-batch-other { opacity: .3; pointer-events: none; }
td.td-batch-col { cursor: pointer; }
td.td-batch-col:hover { background: #E8F5E9 !important; }

/* Checkboxes */
.batch-cb { margin-right: 5px; cursor: pointer; width: 14px; height: 14px; vertical-align: middle; accent-color: var(--azul); }

/* Preview de batch */
.td-batch-preview { background: #FFFDE7 !important; }
.chip-batch-pending { border: 2px dashed currentColor !important; opacity: .8; font-style: italic; }
.chip-batch-sem-escala { font-style: italic; color: var(--cinza-500); font-size: 12px; }

/* Toolbar de selecao rapida (acima da tabela) */
#escala-batch-toolbar { display: flex; align-items: center; gap: 10px; padding: 9px 14px; background: #E8F5E9; border: 1.5px solid var(--verde); border-bottom: none; border-radius: var(--radius) var(--radius) 0 0; flex-wrap: wrap; }
#escala-batch-toolbar + .tbl-wrap { border-radius: 0 0 var(--radius) var(--radius); }
#escala-batch-label { font-size: 13px; font-weight: 700; color: var(--verde); flex: 1; white-space: nowrap; }
.batch-toolbar-btns { display: flex; gap: 6px; }
.batch-toolbar-btns button { background: white; border: 1.5px solid var(--verde); color: var(--verde); border-radius: 6px; padding: 4px 10px; font-family: var(--font); font-size: 12px; font-weight: 600; cursor: pointer; }
.batch-toolbar-btns button:hover { background: var(--verde-claro); }

/* Barra de acoes fixa no rodape */
#escala-batch-bar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 200; background: white; border-top: 2px solid var(--azul); box-shadow: 0 -4px 20px rgba(0,0,0,.13); padding: 10px 24px; }
#batch-bar-select, #batch-bar-preview { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#batch-count-label, #batch-preview-label { font-size: 13px; font-weight: 700; color: var(--cinza-900); flex: 1; min-width: 160px; }
#batch-progress-label { font-size: 12px; color: var(--cinza-700); }
#batch-cidade-select { padding: 6px 8px; border: 1.5px solid var(--azul); border-radius: 7px; font-family: var(--font); font-size: 13px; background: white; }
#escala-batch-bar button { padding: 7px 16px; border-radius: 7px; font-family: var(--font); font-weight: 700; font-size: 13px; cursor: pointer; border: 2px solid transparent; transition: .15s; white-space: nowrap; }
#batch-btn-preview { background: var(--azul); color: white; border-color: var(--azul); }
#batch-btn-preview:hover:not(:disabled) { opacity: .88; }
#batch-btn-preview:disabled { opacity: .45; cursor: not-allowed; }
#batch-btn-apply { background: var(--verde); color: white; border-color: var(--verde); }
#batch-btn-apply:hover:not(:disabled) { opacity: .88; }
#batch-btn-apply:disabled { opacity: .45; cursor: not-allowed; }
#batch-btn-back { background: none; border-color: var(--cinza-300); color: var(--cinza-700); }
#batch-btn-back:hover:not(:disabled) { border-color: var(--cinza-500); }
#batch-btn-back:disabled { opacity: .45; cursor: not-allowed; }
.btn-batch-cancel { background: none !important; border-color: var(--cinza-300) !important; color: var(--cinza-700) !important; }
.btn-batch-cancel:hover { border-color: var(--vermelho) !important; color: var(--vermelho) !important; }

/* Inline cell editor */
.td-inline-editor { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.td-inline-editor select { padding: 3px 6px; border: 1.5px solid var(--azul); border-radius: 6px; font-family: var(--font); font-size: 12px; background: white; max-width: 140px; }
.td-inline-editor select:focus { outline: 2px solid var(--azul); outline-offset: 1px; }
.btn-inline-ok, .btn-inline-cancel { border: none; border-radius: 5px; padding: 3px 8px; font-size: 13px; font-weight: 700; cursor: pointer; line-height: 1.2; }
.btn-inline-ok { background: var(--verde); color: white; }
.btn-inline-ok:hover:not(:disabled) { opacity: .85; }
.btn-inline-ok:disabled, .btn-inline-cancel:disabled { opacity: .45; cursor: not-allowed; }
.btn-inline-ok:focus, .btn-inline-cancel:focus { outline: 2px solid var(--azul); outline-offset: 1px; }
.btn-inline-cancel { background: var(--cinza-100); color: var(--cinza-700); }
.btn-inline-cancel:hover:not(:disabled) { background: var(--cinza-300); }
.td-save-ok  { background: var(--verde-claro) !important; transition: background .9s; }
.td-saving   { opacity: .6; pointer-events: none; }
.td-save-err { background: var(--vermelho-claro) !important; transition: background .3s; }
.td-inline-err { width: 100%; font-size: 10px; color: var(--vermelho); margin-top: 2px; }

/* Modal legado (remover apos Feature 1 aprovada) */
#escala-modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1000; display: none; align-items: center; justify-content: center; }
#escala-modal-bg.open { display: flex; }
.escala-modal { background: white; border-radius: 14px; padding: 28px 24px 20px; width: 440px; max-width: 95vw; box-shadow: 0 8px 32px rgba(0,0,0,.22); }
.escala-modal h3 { margin: 0 0 18px; font-size: 16px; font-weight: 800; color: var(--cinza-900); }
.escala-edit-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.escala-edit-row label { flex: 1; font-size: 13px; font-weight: 600; color: var(--cinza-700); white-space: nowrap; }
.escala-edit-row select { flex: 1.5; padding: 6px 8px; border: 1.5px solid var(--cinza-300); border-radius: 7px; font-family: var(--font); font-size: 13px; background: white; }
.escala-modal-actions { display: flex; gap: 10px; margin-top: 18px; justify-content: flex-end; }
.escala-modal-actions button { padding: 8px 20px; border-radius: 7px; font-family: var(--font); font-weight: 700; font-size: 13px; cursor: pointer; transition: .15s; }
.escala-modal-actions .btn-cancelar { background: none; border: 2px solid var(--cinza-300); color: var(--cinza-700); }
.escala-modal-actions .btn-cancelar:hover { border-color: var(--cinza-500); }
.escala-modal-actions .btn-salvar { background: var(--azul); border: 2px solid var(--azul); color: white; }
.escala-modal-actions .btn-salvar:hover { opacity: .88; }
.escala-modal-actions .btn-salvar:disabled { opacity: .55; cursor: not-allowed; }
.msg.err { font-size: 13px; padding: 8px 12px; border-radius: 7px; margin-top: 10px; background: var(--vermelho-claro); color: var(--vermelho); }

/* Botao historico */
#btn-historico-escala { margin-left: 8px; background: none; border: 2px solid var(--cinza-300); color: var(--cinza-700); border-radius: 7px; padding: 6px 12px; font-family: var(--font); font-weight: 700; font-size: 12px; cursor: pointer; transition: .15s; }
#btn-historico-escala:hover { border-color: var(--azul); color: var(--azul); }
#btn-historico-escala.ativo { border-color: var(--azul); background: var(--azul-claro); color: var(--azul); }

/* Painel historico */
#escala-historico-panel { background: white; border: 1.5px solid var(--cinza-300); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; }
#escala-historico-panel h4 { margin: 0 0 10px; font-size: 13px; font-weight: 700; color: var(--cinza-900); }
.historico-loading, .historico-vazio { font-size: 12px; color: var(--cinza-500); }
.historico-entry { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--cinza-100); font-size: 12px; flex-wrap: wrap; }
.historico-entry:last-child { border-bottom: none; }
.historico-ts   { color: var(--cinza-500); white-space: nowrap; min-width: 100px; }
.historico-user { font-weight: 700; color: var(--azul); white-space: nowrap; }
.historico-adv  { color: var(--cinza-700); white-space: nowrap; }
.historico-dia  { color: var(--cinza-500); white-space: nowrap; }
.historico-cidade { font-weight: 600; color: var(--cinza-900); }
.historico-badge-lote { background: var(--verde-claro); color: var(--verde); border-radius: 4px; padding: 1px 6px; font-size: 10px; font-weight: 700; }
