/* Estilos Gerais e Reset Mínimo */
body {
    font-family: Arial, sans-serif; margin: 0; padding: 0; min-height: 100vh; display: flex; flex-direction: column;
    background-image: url('calendario-lunarx.jpg'); background-size: cover; background-position: center center; background-repeat: no-repeat; background-attachment: fixed;
}
main.tool-content-wrapper { flex-grow: 1; padding: 20px 0; width: 100%; box-sizing: border-box; }
.container {
    width: 95%; max-width: 1200px; margin: 0 auto; padding: 25px; box-shadow: 0 8px 32px 0 rgba( 31, 38, 135, 0.37 );
    border-radius: 10px; border: 1px solid rgba( 255, 255, 255, 0.18 ); box-sizing: border-box;
    background: rgba(255, 255, 255, 0.6); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.hidden { display: none; }

/* Header/Footer Padrão da Ferramenta (Mantidos) */
.header-compact { background-color: #3498db; color: white; padding: 10px 15px; text-align: center; border-bottom: 3px solid #2980b9; flex-shrink: 0; position: sticky; top: 0; z-index: 100; }
.header-compact-content { display: flex; align-items: center; justify-content: center; gap: 15px; flex-wrap: wrap; max-width: 1200px; margin: 0 auto; }
.header-logo { height: 40px; width: 40px; border-radius: 50%; }
.header-compact-text h1 { font-size: 1.4em; color: white; margin: 0 0 3px 0; font-weight: bold; line-height: 1.2; text-align: left; border-bottom: none; padding-bottom: 0; }
.header-compact-text p { font-size: 0.9em; color: #f1c40f; margin: 0; line-height: 1.2; text-align: left; font-style: italic; }
.tool-footer { background-color: #2c3e50; color: #bdc3c7; text-align: center; padding: 20px 15px; font-size: 0.85em; border-top: 3px solid #3498db; margin-top: auto; flex-shrink: 0; }
.tool-footer-links { margin-bottom: 10px; }
.tool-footer a { color: #ecf0f1; margin: 0 10px; text-decoration: none; transition: color 0.3s; }
.tool-footer a:hover { color: #3498db; text-decoration: underline; }

/* Espaços de Anúncio (Mantidos) */
.adsense-tool { margin: 25px 0; }
.ad-space { width: 100%; min-height: 90px; background-color: rgba(238, 238, 238, 0.7); display: flex; justify-content: center; align-items: center; color: #555; font-style: italic; border: 1px dashed #bbb; box-sizing: border-box; border-radius: 4px; }
.container > .adsense-tool:first-child { margin-top: 0; }
.container > .adsense-tool:last-child { margin-bottom: 0; }

/* Navegação do Ano (Mantidos) */
.header { display: flex; justify-content: center; align-items: center; margin-bottom: 25px; padding: 0 10px; flex-wrap: wrap; gap: 15px; }
.navigation button { background-color: #3498db; color: white; border: none; padding: 10px 20px; margin: 0 5px; cursor: pointer; border-radius: 5px; transition: background-color 0.3s ease; font-size: 1em; font-weight: bold; }
.navigation button:hover { background-color: #2980b9; }
.year-display { font-size: 1.3em; font-weight: bold; color: #2c3e50; margin: 0 15px; }

/* Título Visível na Tela (h1) */
.year-title { /* Este é o #calendarTitleOnScreen no HTML */
    font-size: 1.8em; color: #2c3e50; text-align: center; margin-top: 0; margin-bottom: 20px;
    background-color: rgba(240, 240, 240, 0.8); padding: 12px 20px; border-radius: 5px; font-weight: bold;
}

/* Container dos Meses (Mantidos) */
.months-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin-top: 15px; }
.month-container { border: 1px solid rgba(221, 221, 221, 0.5); padding: 15px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); border-radius: 8px; box-sizing: border-box; display: flex; flex-direction: column; transition: transform 0.2s ease-in-out; }
.month-container:hover { transform: translateY(-3px); }
.month-container:nth-child(3n+1) { background-color: rgba(250, 240, 230, 0.75); }
.month-container:nth-child(3n+2) { background-color: rgba(245, 245, 220, 0.75); }
.month-container:nth-child(3n+3) { background-color: rgba(238, 232, 170, 0.75); }
.month-title { text-align: center; color: #34495e; margin-top: 0; margin-bottom: 15px; font-size: 1.3em; font-weight: bold; padding-bottom: 5px; border-bottom: 1px solid rgba(52, 73, 94, 0.2); }

/* Grid dos Dias (Mantidos) */
.day-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; flex-grow: 1; }
.day-name { font-weight: bold; font-size: 0.8em; color: #7f8c8d; padding-bottom: 6px; border-bottom: 1px solid #ecf0f1; margin-bottom: 4px; text-transform: uppercase; }
.day-name:first-child { color: #c0392b; } .day-name:last-child { color: #2980b9; }
.day { text-align: center; padding: 5px 2px; color: #34495e; min-height: 60px; display: flex; flex-direction: column; justify-content: space-between; align-items: center; font-size: 0.9em; border-radius: 4px; position: relative; background-color: rgba(255, 255, 255, 0.4); border: 1px solid transparent; transition: background-color 0.2s; }
.day:not(.empty):hover { background-color: rgba(52, 152, 219, 0.1); }
.day.empty { background-color: transparent; border: none; }
.day-number { display: block; font-weight: normal; font-size: 0.95em; margin-bottom: 0; }

/* FASES DA LUA - CORES (Mantidas) */
.moon-phase { display: block; width: 24px; height: 24px; margin: 0 auto; background-size: contain; background-repeat: no-repeat; background-position: center; border-radius: 50%; }
.luanova { background-color: #000000; background-image: none !important; }
.crescente { background-color: #90EE90; background-image: none !important; }
.cheia { background-color: #FFFFE0; background-image: none !important; border: 1px solid #ccc; }
.minguante { background-color: #FFB6C1; background-image: none !important; }

/* Legenda */
.legend-container { border: 1px solid rgba(204, 204, 204, 0.5); padding: 20px; width: fit-content; max-width: 300px; margin: 30px auto; border-radius: 8px; background-color: rgba(249, 249, 249, 0.8); }
.legend-title { text-align: center; margin-top: 0; margin-bottom: 15px; font-size: 1.2em; color: #34495e; font-weight: bold; }
.legend-item { display: flex; align-items: center; margin-bottom: 10px; font-size: 0.95em; }
.legend-icon { width: 22px; height: 22px; margin-right: 10px; border-radius: 50%; flex-shrink: 0; }
.legend-item span { text-align: left; color: #34495e; }

/* Destaques (Mantidos) */
.today { background-color: rgba(255, 240, 240, 0.8); border: 1px solid #e74c3c; }
.today .day-number { font-weight: bold; color: #c0392b; }
.day.sunday .day-number { color: #2980b9; font-weight: bold; }

/* Botão Imprimir (Mantido) */
button[onclick="window.print()"] { display: block; margin: 35px auto; background-color: #5cb85c; color: white; border: none; padding: 12px 30px; cursor: pointer; border-radius: 5px; transition: background-color 0.3s ease, transform 0.2s ease; font-size: 1.1em; font-weight: bold; box-shadow: 0 2px 5px rgba(0,0,0,0.2); }
button[onclick="window.print()"]:hover { background-color: #4cae4c; transform: translateY(-2px); }
button[onclick="window.print()"]:active { transform: translateY(0); box-shadow: inset 0 1px 3px rgba(0,0,0,0.3); }


/* --- Estilos de Impressão --- */
@media print {
    @page {
        size: A4 portrait;
        margin: 1.5cm;
        /* Tentar remover header/footer padrão do navegador (suporte varia) */
        @top-left { content: none !important; }
        @top-center { content: none !important; }
        @top-right { content: none !important; }
        @bottom-left { content: none !important; }
        @bottom-center { content: none !important; }
        @bottom-right { content: none !important; }
    }

    body { background: none !important; color: #000; font-size: 9pt; -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

    /* Esconde elementos da tela */
    .header-compact, .tool-footer, .adsense-tool, button[onclick="window.print()"],
    .navigation button, .year-display { /* .legend-container REMOVIDO daqui para tentar mostrar */
        display: none !important;
    }

    /* 1) Esconder o título h1 da tela (Calendário Lunar de XXXX) na impressão */
    .year-title {
        display: none !important;
    }

    main.tool-content-wrapper { padding: 0 !important; }
    .container { box-shadow: none !important; border: none !important; background: none !important; backdrop-filter: none !important; width: 100% !important; max-width: none !important; padding: 0 !important; margin: 0 !important; }

    /* Layout dos Meses */
    .months-container { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; page-break-inside: avoid; }
    .month-container { border: 1px solid #ccc; padding: 8px; page-break-inside: avoid; background-color: #fff !important; }
    .month-title { font-size: 10pt; margin-bottom: 5px; border-bottom: 1px solid #ccc; }

    /* Dias */
    .day-grid { gap: 1.5px; }
    .day { min-height: 35px; font-size: 8pt; padding: 2px; border: 1px solid #eee; }
    .day.empty { background-color: transparent !important; border: none; }
    .day-name { font-size: 7pt; padding-bottom: 2px; border-bottom: 1px solid #ccc; }
    .day-number { margin-bottom: 2px; font-size: 8pt; }

    /* Luas (cores sólidas) */
    .moon-phase { width: 12px; height: 12px; background-image: none !important; } /* Tamanho menor para impressão */

    /* Domingos */
    .day.sunday .day-number { color: darkblue !important; font-weight: bold !important; }

    /* 'Hoje' */
    .today { background-color: #eee !important; border: 1px solid #bbb !important; }
    .today .day-number { color: #000 !important; font-weight: bold; }
    .day.sunday.today .day-number { color: darkblue !important; }

    /* 3) Mostrar e Estilizar Legenda na Impressão */
    .legend-container {
        display: block !important; /* Força a exibição */
        margin: 20px auto; /* Centraliza com margem */
        padding: 10px;
        border: 1px solid #ccc;
        background-color: #f9f9f9 !important; /* Fundo simples para impressão */
        width: 90%; /* Ajusta largura */
        box-sizing: border-box;
        page-break-before: auto; /* Tenta colocar em nova página se não couber */
        page-break-inside: avoid; /* Tenta não quebrar a legenda */
    }
    .legend-title { font-size: 10pt; margin-bottom: 8px; }
    .legend-item { font-size: 8pt; margin-bottom: 5px; }
    .legend-icon { width: 12px; height: 12px; margin-right: 5px; /* Ícones menores */ }

} /* Fim @media print */


/* --- Responsividade (Mantida) --- */
@media (max-width: 1200px) { .months-container { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); } }
@media (max-width: 992px) { .container { width: 98%; padding: 20px; } .months-container { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); } .year-title { font-size: 1.6em; } }
@media (max-width: 768px) { body { background-attachment: scroll; } .container { padding: 15px; background: rgba(255, 255, 255, 0.7); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); } .year-title { font-size: 1.4em; padding: 10px 15px; } .header { justify-content: space-around; } .months-container { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 15px; } .month-container { padding: 12px; } .day { font-size: 0.8em; min-height: 50px; } .moon-phase { width: 20px; height: 20px; } .legend-container { width: 90%; max-width: 90%; padding: 15px; } .header-compact-content { justify-content: center; gap: 10px; } .header-compact-text h1 { font-size: 1.2em; } .header-compact-text p { font-size: 0.8em; } .tool-footer { padding: 15px 10px; font-size: 0.8em; } }
@media (max-width: 480px) { .container { padding: 10px; background: rgba(255, 255, 255, 0.8); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); } .year-title { font-size: 1.2em; } .navigation button { padding: 8px 10px; font-size: 0.85em; } .year-display { font-size: 1em; margin: 0 8px; } .months-container { grid-template-columns: 1fr; } .month-title { font-size: 1.1em; } .day { font-size: 0.75em; min-height: 45px; } .day-name { font-size: 0.7em; } .moon-phase { width: 18px; height: 18px; } button[onclick="window.print()"] { font-size: 1em; padding: 10px 20px; width: 80%; max-width: 250px; } .legend-item { font-size: 0.9em; } .legend-icon { width: 20px; height: 20px; } .header-logo { height: 30px; width: 30px; } .header-compact-text h1 { font-size: 1.1em; } .header-compact-text p { font-size: 0.75em; } }