/* main3.css - Versão FINAL, Responsiva e com Estilos de Férias/Destaque */

/* --- Estilos globais --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;700&display=swap');

/* --- Estilos globais --- */
html, body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    background-color: #dbe2f2;
    color: #2d3748;
    box-sizing: border-box;
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    width: 100%;
    padding: 0;
    max-width: 1200px;
    margin: 0 auto;
}

.main-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* --- Cabeçalho --- */
header {
    width: 100%;
    background-color: #2d3748;
    color: white;
    padding: 0;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

header h1 {
    margin: 0;
    font-size: 2rem;
}

/* --- Tabela de Calendário --- */
.calendar-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0 18px;
    border-radius: 8px;
    overflow: hidden;
    table-layout: fixed;
}

.calendar-table th,
.calendar-table td {
    padding: 2px 4px;
    text-align: center;
    border: 1px solid #e2e8f0;
    background-color: #f9fafb;
    color: #4a5568;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.calendar-table .KW {
    background-color: #e6edf7;
    font-weight: bold;
    color: #2d3748;
}

.calendar-table th:not(.Leandro):not(.Rafaela),
.calendar-table td:not(.Leandro):not(.Rafaela) {
    width: 7%;
}

.calendar-table .Leandro {
    background-color: #e0e7ff;
    color: #2d3748;
    font-weight: 500;
    width: 22%;
}

.calendar-table .Rafaela {
    background-color: #d1e2f7;
    color: #2d3748;
    font-weight: 500;
    width: 22%;
}

.calendar-table th.Leandro,
.calendar-table th.Rafaela {
    white-space: normal;
}

.calendar-table th {
    padding: 2px;
    background-color: #cbd5e0;
    color: #2d3748;
    font-weight: bold;
}

.calendar-table .sa {
    background-color: #d1e8ff;
    color: #2d3748;
}

.calendar-table .so {
    background-color: #cbd5e0;
    color: #2d3748;
}

.calendar-table td.holiday {
    background-color: #c4e7f4;
    color: #2d3748;
    font-weight: bold;
}

.calendar-table td.today {
    background-color: #2c5282;
    color: white;
    font-weight: bold;
    text-decoration: underline;
    border: 2px solid #001f3f;
    position: relative;
    z-index: 2;
}

.calendar-table tr.highlight-current {
    background-color: #e0f2f7;
    border-left: 3px solid #64b5f6;
    border-right: 3px solid #64b5f6;
}

.calendar-table tr.highlight-current .KW {
    background-color: #d7edf4;
    border-color: #64b5f6;
}

.calendar-table td.empty-day {
    color: transparent;
    cursor: default;
}

.calendar-table td:not(.empty-day):hover {
    background-color: #dae4ef;
    cursor: pointer;
}

.calendar-table tr:nth-child(odd) {
    background-color: #f9fafb;
}

.calendar-table tr:nth-child(even) {
    background-color: #e2e8f0;
}

/* --- LEGENDA --- */
.legend {
    margin-top: 4px;
    padding: 5px;
    background-color: #f1f4f8;
    border-left: 5px solid #2d3748;
    border-radius: 8px;
    line-height: 1.6;
}

.legend-item strong {
    color: #2d3748;
    margin-bottom: 2px;
    display: block;
}

/* --- ESTILOS DE FÉRIAS PESSOAIS (CORES DINÂMICAS) --- */

/* Estilo BÁSICO para a célula do dia de FÉRIAS (para todos) */
.calendar-table td.ferias-day {
    font-weight: bold;
    color: black; 
}

/* 1. FÉRIAS de AMBOS (Leandro E Rafaela) - Verde Menta Suave para descanso */
.calendar-table td.ferias-ambos {
    background-color: #BDE7C8; 
    border: 2px solid #99c4a4; 
}

/* 2. FÉRIAS Apenas Leandro */
.calendar-table td.ferias-leandro {
    background-color: #ffb6c1; /* Rosa Claro */
    border: 1px solid #e09292;
}

/* 3. FÉRIAS Apenas Rafaela */
.calendar-table td.ferias-rafaela {
    background-color: #add8e6; /* Azul Claro */
    border: 1px solid #8fc9e0;
}

/* Estilos para os quadradinhos na LEGENDA */
.legend-color-box {
    display: inline-block;
    width: 15px;
    height: 15px;
    margin-right: 5px;
    vertical-align: middle;
    border: 1px solid #333; 
}
/* Cores dos quadradinhos da legenda */
.legend-color-box.ambos { background-color: #BDE7C8; }
.legend-color-box.leandro { background-color: #ffb6c1; }
.legend-color-box.rafaela { background-color: #add8e6; }

/* Opcional: Para manter o turno em FÉRIAS destacado na coluna do calendário */
.calendar-table .Leandro.ferias,
.calendar-table .Rafaela.ferias {
    font-style: italic;
    background-color: #f0f4f7; /* Fundo levemente diferente para a coluna do turno */
}


/* --- TABELA DE HORÁRIOS PADRÃO (Turnos Rafaela) --- */
.turnosRafaela {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    margin: 15px 0 18px;
    border-radius: 8px;
    overflow: hidden;
}

.turnosRafaela th,
.turnosRafaela td {
    padding: 2px;
    text-align: center;
    border: 1px solid #e2e8f0;
    background-color: #f9fafb;
    color: #4a5568;
    box-sizing: border-box;
    word-wrap: break-word;
    white-space: nowrap; /* Original: mantém tudo na linha */
    overflow: hidden;
    text-overflow: ellipsis;
}

.turnosRafaela th {
    background-color: #cbd5e0;
    font-weight: bold;
}

.turnosRafaela th:nth-child(1),
.turnosRafaela td:nth-child(1) {
    width: 15.04%;
    font-weight: bold;
}

.turnosRafaela th:nth-child(n + 2),
.turnosRafaela td:nth-child(n + 2) {
    width: 14.16%;
}

.turnosRafaela .turno {
    background-color: #e6edf7;
    color: #2d3748;
    font-weight: bold;
}

.turnosRafaela td.frei {
    background-color: #edf2f7;
    font-style: italic;
    font-weight: bold;
}

/* --- TABELA DE MESES (ÍNDICE) --- */
.month-table {
    width: 99.99%; 
    max-width: 600px;
    margin: 20px auto;
    border-collapse: collapse;
    background-color: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    table-layout: fixed; 
}

.month-table td {
    width: 33.33%; 
    padding: 7px 7px; 
    text-align: center;
    border: 1px solid #e2e8f0;
    color: #4a5568;
    vertical-align: top; 
}

.month-table th {
    padding: 2px 2px;
    text-align: center;
    border: 1px solid #e2e8f0;
    background-color: #cbd5e0;
    font-weight: bold;
    text-transform: uppercase;
    color: #2d3748;
}

.month-table td a {
    text-decoration: none;
    background-color: #e6edf7;
    color: #2c5282;
    font-weight: bold;
    display: block; 
    padding: 8px 5px; 
    border-radius: 4px;
    transition: background-color 0.3s ease;
    white-space: nowrap; 
    overflow: hidden;  
    text-overflow: ellipsis; 
    box-sizing: border-box; 
}

.month-table td a:hover {
    background-color: #cbd5e0;
    color: #2d3748;
    cursor: pointer;
}

/* --- RODAPÉ --- */
footer {
    width: 100%;
    margin-top: auto;
    background-color: #2d3748;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    padding: 15px 0;
    font-size: 0.9em;
}

/* --- NAVEGAÇÃO ENTRE MESES (Atualizada para manter os botões dentro da tela) --- */
.navigation-footer-container {
    width: 100%;
    max-width: 1200px;
    margin: 25px auto;
    padding: 0 15px;
    
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* 🔑 Permite quebrar linha se faltar espaço */
    gap: 10px; /* Pequeno espaçamento quando quebrar */
    box-sizing: border-box;
}

.nav-button {
    display: inline-block;
    padding: 10px 16px;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    
    background-color: #2d3748;
    color: white;
    border-radius: 6px;
    
    transition: background-color 0.2s, transform 0.1s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    
    flex: 1 1 150px; /* 🔑 Faz os botões redimensionarem automaticamente */
    min-width: 120px; /* Evita encolher demais */
    text-align: center; /* Centraliza texto */
    box-sizing: border-box;
}

.nav-button:hover {
    background-color: #4a5568;
    transform: translateY(-2px);
}


/* --- DESTAQUE DE CLIQUE (CORES UNIFICADAS) --- */
.calendar-table tr:hover {
    cursor: pointer;
    background-color: #f0f8ff; 
}
/* Destaque da linha inteira do calendário após o clique */
.calendar-table tr.highlight-clicked {
    border: 3px solid #007bff; 
    background-color: #C0DFFD; /* Azul Claro Vívido */
    transition: all 0.2s ease-in-out;
}

/* --- DESTAQUE NA TABELA DE HORÁRIOS DE RAFAELA (UNIFICADO) --- */
.turnosRafaela tr.highlight-turno {
    background-color: #C0DFFD; /* Azul unificado */
    border: 3px solid #007bff; 
    font-weight: bold;
    transition: background-color 0.2s;
}

.turnosRafaela tr.highlight-turno td {
    background-color: #C0DFFD !important; 
    border-color: #007bff !important;
    border-width: 2px !important; 
}


/* --- RESPONSIVIDADE (MEDIA QUERIES) --- */
@media (max-width: 600px) {
    .calendar-table th,
    .calendar-table td,
    .turnosRafaela th,
    .turnosRafaela td {
        font-size: 10px;
        padding: 1px;
        /* white-space: normal aqui não é aplicado para evitar quebra de dias no calendário */
    }

    .calendar-table .Leandro,
    .calendar-table .Rafaela {
        width: 18%;
    }

    .calendar-table th:not(.Leandro):not(.Rafaela),
    .calendar-table td:not(.Leandro):not(.Rafaela) {
        width: calc((100% - 36%) / 8);
    }

    .turnosRafaela .turno {
        width: 20%;
    }

    .legend-item {
        font-size: 10px;
    }

    .month-table {
        width: 90%;
    }
}

@media (max-width: 480px) {
    /* CORREÇÃO CRÍTICA PARA NAVEGAÇÃO E TABELA DE HORÁRIOS EM CELULARES */
    
    /* Botões de Navegação (Para não invadir) */
    .navigation-footer-container {
        padding: 0 5px; /* Reduz o padding para dar mais espaço */
    }
    
    .nav-button {
        flex: 0 1 45%; 
        min-width: 120px; 
        padding: 8px 10px;
        font-size: 0.9rem; 
    }

    /* Tabela de Horários da Rafaela (Permite quebra de horário) */
    .turnosRafaela th,
    .turnosRafaela td {
        white-space: normal; /* Permite a quebra de linha para os horários */
        font-size: 9px; 
        word-wrap: break-word;
    }
    
    /* Mantém o texto do turno ("Spät 1") em uma linha se possível */
    .turnosRafaela td:nth-child(1) {
        white-space: nowrap;
    }
}


@media (max-width: 400px) {
    .calendar-table th,
    .calendar-table td,
    .turnosRafaela th,
    .turnosRafaela td {
        font-size: 8.5px;
        padding: 1px 2px;
    }

    .legend-item {
        font-size: 9px;
    }

    .month-table {
        width: 95%;
    }
}