/* ==================== PROGRAMAÇÃO DE OBRAS ==================== */
/* VERSÃO CORRIGIDA - NUNCA ESCONDE OS ENCARREGADOS */

/* ===== LAYOUT PRINCIPAL ===== */
.programacao-page {
    padding: 15px;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: hidden;
}

/* ===== HEADER COM CONTROLES ===== */
.programacao-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 10px;
    flex-shrink: 0;
}

.programacao-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.programacao-header-left h2 {
    font-size: 1.2rem;
    color: var(--primary);
    margin: 0;
}

.programacao-nav-btns {
    display: flex;
    align-items: center;
    gap: 6px;
}

.programacao-nav-btns .btn-nav {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.programacao-nav-btns .btn-nav:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.programacao-periodo-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    min-width: 160px;
    text-align: center;
}

.programacao-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ===== TOGGLE ===== */
.programacao-view-toggle {
    display: flex;
    background: var(--bg-input);
    border-radius: 8px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.programacao-view-toggle .toggle-btn {
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.programacao-view-toggle .toggle-btn.active {
    background: var(--primary);
    color: white;
}

/* ===== RESUMO CARDS ===== */
.programacao-summary {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    flex-shrink: 0;
}

.prog-summary-card {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 8px 6px;
    text-align: center;
    border: 1px solid var(--border);
}

.prog-summary-card .icon { font-size: 1.1rem; margin-bottom: 2px; }
.prog-summary-card .value { font-size: 1.1rem; font-weight: 700; color: var(--primary); }
.prog-summary-card .label { font-size: 0.55rem; color: var(--text-muted); }
.prog-summary-card.preparacao .value { color: #f39c12; }
.prog-summary-card.execucao .value { color: #27ae60; }
.prog-summary-card.desligamento .value { color: #8e44ad; }

/* ===== FILTROS ===== */
.programacao-filtros {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
    padding: 10px 12px;
    background: var(--bg-card);
    border-radius: 10px;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.programacao-filtros .filtro-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 120px;
}

.programacao-filtros .filtro-group label {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 600;
}

.programacao-filtros .filtro-group select {
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    color: var(--text);
    font-size: 0.75rem;
}

/* ===== GRADE CONTAINER - O IMPORTANTE ===== */
.programacao-grid-container {
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border);
    flex: 1;
    min-height: 0; /* ESSENCIAL para scroll funcionar */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.programacao-grid-scroll {
    flex: 1;
    overflow: auto;
    min-height: 0; /* ESSENCIAL */
    -webkit-overflow-scrolling: touch;
}

/* ===== TABELA ===== */
.programacao-grid {
    border-collapse: collapse;
    width: 100%;
}

/* Modo semanal */
.programacao-grid:not(.mensal) {
    min-width: 750px;
}

/* Modo mensal */
.programacao-grid.mensal {
    min-width: 600px;
}

/* CABEÇALHO */
.programacao-grid thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-card);
    padding: 10px 6px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text);
    text-align: center;
    border-bottom: 2px solid var(--border);
}

.programacao-grid thead th.col-equipe {
    text-align: left;
    padding-left: 12px;
    color: var(--primary);
    background: var(--bg-card);
    z-index: 15;
}

/* LARGURAS DAS COLUNAS */
.programacao-grid thead th.col-equipe {
    width: 170px;
    min-width: 170px;
}

.programacao-grid.mensal thead th.col-equipe {
    width: 140px;
    min-width: 140px;
}

.programacao-grid:not(.mensal) thead th.col-dia {
    width: 120px;
    min-width: 120px;
}

.programacao-grid.mensal thead th.col-dia {
    width: 55px;
    min-width: 55px;
}

/* DESTAQUES */
.programacao-grid thead th.col-dia.hoje {
    color: var(--primary);
    background: rgba(255, 104, 0, 0.08);
}

.programacao-grid thead th.col-dia.weekend {
    color: #e74c3c;
    opacity: 0.6;
}

.programacao-grid thead th .dia-numero {
    display: block;
    font-size: 0.9rem;
    font-weight: 800;
}

.programacao-grid thead th .dia-nome {
    display: block;
    font-size: 0.55rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* ===== CÉLULAS - COLUNA DE EQUIPE FIXA ===== */
.programacao-grid td {
    padding: 6px;
    vertical-align: top;
}

.programacao-grid td.col-equipe {
    padding: 10px 12px;
    vertical-align: middle;
    background: var(--bg-card);
    position: sticky;
    left: 0;
    z-index: 5;
    box-shadow: 2px 0 5px rgba(0,0,0,0.05);
}

.programacao-grid td.col-dia {
    border-left: 1px solid var(--border);
}

/* ===== INFO DA EQUIPE - NUNCA ESCONDE ===== */
.equipe-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.equipe-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.equipe-dados {
    flex: 1;
}

.equipe-dados .equipe-nome {
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--text);
    line-height: 1.2;
    word-break: break-word;
}

.equipe-dados .equipe-cargo {
    font-size: 0.6rem;
    color: var(--text-muted);
}

/* ===== CARDS DE ATIVIDADE ===== */
.celula-atividades {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ativ-card {
    padding: 5px 7px;
    border-radius: 6px;
    font-size: 0.65rem;
    cursor: pointer;
    transition: transform 0.15s;
    border-left: 3px solid transparent;
    position: relative;
}

.ativ-card:hover {
    transform: scale(1.02);
    z-index: 5;
}

.ativ-card.fase-preparacao { background: rgba(243, 156, 18, 0.15); border-left-color: #f39c12; }
.ativ-card.fase-execucao { background: rgba(39, 174, 96, 0.15); border-left-color: #27ae60; }
.ativ-card.fase-desligamento { background: rgba(142, 68, 173, 0.15); border-left-color: #8e44ad; }

.ativ-card .ativ-tipo {
    font-weight: 700;
    font-size: 0.65rem;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.ativ-card .ativ-atividade {
    font-size: 0.6rem;
    opacity: 0.8;
    line-height: 1.2;
    word-break: break-word;
}

.ativ-card .ativ-badge-fase {
    position: absolute;
    top: 3px;
    right: 3px;
    font-size: 0.45rem;
    padding: 1px 4px;
    border-radius: 6px;
    font-weight: 700;
}

.fase-preparacao .ativ-badge-fase { background: #f39c12; color: white; }
.fase-execucao .ativ-badge-fase { background: #27ae60; color: white; }
.fase-desligamento .ativ-badge-fase { background: #8e44ad; color: white; }

/* ===== BOTÃO ADD ===== */
.celula-add-btn {
    width: 100%;
    padding: 3px;
    border: 1px dashed var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.65rem;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0;
}

.programacao-grid td.col-dia:hover .celula-add-btn,
.programacao-grid td.col-dia:active .celula-add-btn {
    opacity: 1;
}

.celula-add-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ===== VISÃO MENSAL ===== */
.mensal-ativ-mini {
    width: 100%;
    padding: 2px 3px;
    border-radius: 3px;
    font-size: 0.5rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    margin-bottom: 1px;
}

.mensal-ativ-mini.fase-preparacao { background: #f39c12; color: white; }
.mensal-ativ-mini.fase-execucao { background: #27ae60; color: white; }
.mensal-ativ-mini.fase-desligamento { background: #8e44ad; color: white; }

/* ===== LEGENDA ===== */
.programacao-legenda {
    display: flex;
    gap: 15px;
    padding: 6px 12px;
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: 0.65rem;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.legenda-item { display: flex; align-items: center; gap: 5px; color: var(--text-muted); }
.legenda-dot { width: 10px; height: 10px; border-radius: 2px; }
.legenda-dot.prep { background: #f39c12; }
.legenda-dot.exec { background: #27ae60; }
.legenda-dot.desl { background: #8e44ad; }

/* ============================================ */
/* RESPONSIVO - NUNCA ESCONDE OS ENCARREGADOS */
/* ============================================ */

/* Tablet (768px - 1024px) */
@media (max-width: 1024px) {
    .programacao-grid:not(.mensal) thead th.col-dia { width: 100px; min-width: 100px; }
    .programacao-grid:not(.mensal) { min-width: 680px; }
    .equipe-avatar { width: 30px; height: 30px; font-size: 0.65rem; }
    .equipe-dados .equipe-nome { font-size: 0.75rem; }
}

/* Tablet pequeno (600px - 768px) */
@media (max-width: 768px) {
    .programacao-summary { gap: 6px; }
    .prog-summary-card .value { font-size: 1rem; }
    .prog-summary-card .label { font-size: 0.5rem; }
    
    .programacao-grid:not(.mensal) thead th.col-dia { width: 85px; min-width: 85px; }
    .programacao-grid:not(.mensal) { min-width: 620px; }
    .programacao-grid thead th.col-equipe { width: 140px; min-width: 140px; }
    .programacao-grid.mensal thead th.col-equipe { width: 120px; min-width: 120px; }
    .programacao-grid.mensal thead th.col-dia { width: 45px; min-width: 45px; }
    
    .equipe-avatar { width: 28px; height: 28px; font-size: 0.6rem; }
    .equipe-dados .equipe-nome { font-size: 0.7rem; }
}

/* Celular (480px - 600px) */
@media (max-width: 600px) {
    .programacao-page { padding: 10px; }
    
    .programacao-summary { gap: 5px; }
    .prog-summary-card { padding: 6px 4px; }
    .prog-summary-card .icon { font-size: 1rem; }
    .prog-summary-card .value { font-size: 0.9rem; }
    
    .programacao-grid:not(.mensal) { min-width: 580px; }
    .programacao-grid:not(.mensal) thead th.col-dia { width: 75px; min-width: 75px; }
    .programacao-grid thead th.col-equipe { width: 120px; min-width: 120px; }
    .programacao-grid.mensal thead th.col-equipe { width: 100px; min-width: 100px; }
    
    .equipe-avatar { width: 26px; height: 26px; font-size: 0.55rem; }
    .equipe-dados .equipe-nome { font-size: 0.65rem; }
    .equipe-dados .equipe-cargo { font-size: 0.5rem; }
    
    .ativ-card { padding: 3px 5px; }
    .ativ-card .ativ-tipo { font-size: 0.55rem; }
}

/* Celular retrato (até 480px) - NUNCA ESCONDE O NOME */
@media (max-width: 480px) {
    /* Mantém o nome visível - só reduz tamanho */
    .programacao-grid:not(.mensal) { min-width: 550px; }
    .programacao-grid:not(.mensal) thead th.col-dia { width: 65px; min-width: 65px; }
    .programacao-grid thead th.col-equipe { width: 100px; min-width: 100px; }
    .programacao-grid.mensal thead th.col-equipe { width: 85px; min-width: 85px; }
    .programacao-grid.mensal thead th.col-dia { width: 38px; min-width: 38px; }
    
    /* Avatar some para dar espaço ao nome */
    .equipe-avatar { display: none; }
    
    /* Nome fica VISÍVEL */
    .equipe-dados .equipe-nome { 
        font-size: 0.6rem; 
        font-weight: 700;
        white-space: normal;
        word-break: break-word;
    }
    
    .equipe-dados .equipe-cargo { font-size: 0.45rem; }
    
    .programacao-grid td.col-equipe { padding: 6px 8px; }
    
    /* Badge fase some */
    .ativ-card .ativ-badge-fase { display: none; }
    
    /* Cabeçalho menor */
    .programacao-grid thead th .dia-numero { font-size: 0.7rem; }
    .programacao-grid thead th .dia-nome { font-size: 0.45rem; }
    
    /* Botão novo ocupa toda largura */
    #pN { width: 100%; }
    .programacao-header-right { width: 100%; }
    .programacao-view-toggle { flex: 1; }
    .programacao-view-toggle .toggle-btn { flex: 1; text-align: center; }
}

/* Celular muito pequeno (até 380px) */
@media (max-width: 380px) {
    .programacao-grid:not(.mensal) { min-width: 520px; }
    .programacao-grid:not(.mensal) thead th.col-dia { width: 55px; min-width: 55px; }
    .programacao-grid thead th.col-equipe { width: 85px; min-width: 85px; }
    
    .equipe-dados .equipe-nome { font-size: 0.55rem; }
    
    .programacao-grid.mensal thead th.col-dia { width: 32px; min-width: 32px; }
    .programacao-grid.mensal thead th.col-equipe { width: 75px; min-width: 75px; }
    
    .programacao-grid.mensal thead th .dia-numero { font-size: 0.55rem; }
    
    .mensal-ativ-mini { font-size: 0.4rem; }
    
    .programacao-filtros .filtro-group { min-width: 100%; }
}

/* ===== SCROLLBAR ===== */
.programacao-grid-scroll::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.programacao-grid-scroll::-webkit-scrollbar-track {
    background: var(--bg-input);
    border-radius: 3px;
}

.programacao-grid-scroll::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 3px;
}

/* ===== BOTÃO NOVO ===== */
#pN {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    background: var(--primary);
    color: #fff;
    transition: all 0.2s;
    white-space: nowrap;
}

#pN:hover {
    background: #e55d00;
    transform: translateY(-1px);
}