/* General Styles */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #e0e0e0; /* Fallback */
    /* Ensure correct path to your image */
    background-image: url('calendario-dinamicox.jpg');
    background-size: cover;
    background-repeat: no-repeat;
    background-attachment: fixed; /* Keeps background fixed during scroll */
    background-position: center center; /* Center the image */
}

.container {
    width: 95%;
    max-width: 1200px;
    margin: 20px auto;
    /* Glass Effect */
    background-color: rgba(255, 255, 255, 0.75); /* White background with transparency */
    backdrop-filter: blur(10px); /* Increased blur for glass effect */
    -webkit-backdrop-filter: blur(10px); /* Safari support */
    border-radius: 15px; /* Slightly more rounded */
    padding: 25px; /* More padding */
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2); /* Enhanced shadow */
    border: 1px solid rgba(255, 255, 255, 0.2); /* Subtle border */
    overflow: hidden; /* Clip content for rounded corners */
}


.hidden {
    display: none;
}

/* Controls Section */
#controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 10px 15px; /* Adjust padding */
    background-color: rgba(240, 240, 240, 0.6); /* Lighter background */
    border-radius: 8px; /* Rounded corners */
}

#countrySelection {
    margin-right: 20px;
    margin-bottom: 10px;
}

#countrySelection label {
    margin-right: 8px; /* More space */
    font-weight: bold;
    color: #333;
}

#countrySelect {
    padding: 6px 10px; /* Adjust padding */
    border-radius: 5px;
    border: 1px solid #ccc;
    min-width: 130px;
    background-color: #fff; /* White background */
}

#yearNavigation {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
}


/* Calendar Table Styles */
table {
    border-collapse: collapse;
    margin: 10px auto;
    width: 100%;
    background-color: rgba(255, 255, 255, 0.65); /* Slightly adjusted transparency */
    border-radius: 5px;
    overflow: hidden;
}

th,
td {
    border: 1px solid #ddd;
    padding: 6px;
    text-align: center;
    font-size: 0.9em;
    vertical-align: top;
    height: 48px; /* Slightly increased height */
    box-sizing: border-box;
}

th {
    background-color: rgba(230, 230, 230, 0.8); /* Darker header */
    font-weight: bold; /* Make headers bold */
    color: #444;
}

/* === SCREEN Holiday/Sunday Styling === */
@media screen {
    td.holiday { /* Target only table data cells */
        background-color: #000080; /* Dark Blue background */
        color: white !important; /* White text, !important to override other color rules */
        font-weight: bold;
    }
    td.sunday { /* Target non-holiday Sundays */
        color: #000080; /* Dark Blue text */
        font-weight: bold;
        background-color: transparent; /* Ensure no background override from holiday */
    }
    /* Handle cells that are BOTH Sunday AND Holiday */
    td.sunday.holiday {
        background-color: #000080; /* Dark Blue background */
        color: white !important; /* White text */
        font-weight: bold;
    }
}


/* Week Number Column Specific Width */
.week-number-header,
.week-number-cell {
    width: 35px;
    min-width: 35px;
    box-sizing: border-box;
    background-color: rgba(225, 225, 225, 0.7);
    font-weight: normal;
    color: #555;
}

/* Year Navigation */
#currentYear {
    margin: 0 15px;
    font-size: 1.2em;
    font-weight: bold;
    min-width: 50px;
    display: inline-block;
    text-align: center;
    color: #1a1a1a; /* Darker year color */
}

button {
    margin: 0 5px;
    padding: 10px 20px;
    cursor: pointer;
    border-radius: 5px;
    transition: background-color 0.3s ease, transform 0.1s ease;
    font-size: 1em;
    background-color: #3498db;
    color: white;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

button:hover {
    background-color: #2980b9;
}
button:active {
    transform: translateY(1px);
}

/* Calendar Grid Layout */
.calendar-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    gap: 15px;
}

.month-container {
    flex: 1 1 300px;
    max-width: 350px;
    margin: 10px;
    border: 1px solid #ccc; /* Slightly darker border */
    padding: 15px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15); /* Slightly stronger shadow */
    border-radius: 8px;
    background-color: rgba(250, 240, 230, 0.9); /* Default - more opaque */
}

.month-container:nth-child(3n+2) { background-color: rgba(245, 245, 220, 0.9); }
.month-container:nth-child(3n+3) { background-color: rgba(238, 232, 170, 0.9); }

.month-container h2 {
    text-align: center;
    color: #2c3e50; /* Darker title */
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.3em;
    font-weight: 600; /* Bolder month title */
}

/* Holiday List Styles */
.holiday-list-container {
    width: 90%;
    max-width: 700px;
    margin: 30px auto 20px auto;
    padding: 20px;
    border: 1px solid #aed6f1; /* Light blue border */
    border-radius: 8px;
    text-align: left;
    /* Light Blue background with transparency */
    background-color: rgba(173, 216, 230, 0.85); /* Light Blue (e.g., #add8e6) with alpha */
}

.holiday-list-container h2 {
    text-align: center;
    margin-top: 0;
    margin-bottom: 15px;
    color: #154360; /* Darker blue title */
    font-size: 1.4em;
}

.holiday-list {
    list-style: none;
    padding: 0;
    margin: 0;
    columns: 2;
    column-gap: 20px;
}

.holiday-list li {
    margin-bottom: 8px;
    font-size: 0.95em;
    padding-left: 0;
    break-inside: avoid-column;
    color: #333; /* Standard text color */
}

/* Year Title Styles */
.year-title {
    font-size: 2em;
    color: #2c3e50; /* Darker blue */
    text-align: center;
    margin-bottom: 15px;
    background-color: rgba(240, 240, 240, 0.85);
    padding: 15px;
    border-radius: 8px;
    font-weight: bold; /* Make year title bold */
}

/* Advertisement Spaces */
.ad-space {
    width: 100%;
    min-height: 90px;
    background-color: rgba(238, 238, 238, 0.7);
    margin-bottom: 15px;
    text-align: center;
    line-height: 90px;
    color: #777;
    font-style: italic;
    border-radius: 5px;
}

/* === HEADER STYLES === */
.header-compact {
    background-color: #3498db;
    padding: 15px 10px;
    color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}
.header-compact-content { display: flex; align-items: center; justify-content: center; max-width: 1200px; margin: 0 auto; flex-wrap: wrap; }
.header-logo { height: 50px; width: auto; margin-right: 20px; border-radius: 5px; vertical-align: middle; }
.header-compact-text { text-align: left; }
.header-compact-text h1 { font-size: 1.8em; margin: 0 0 5px 0; font-weight: 600; }
.header-compact-text p { font-size: 1em; margin: 0; font-weight: 300; }

/* === FOOTER STYLES === */
.tool-footer {
    background-color: #333;
    color: #ccc;
    text-align: center;
    padding: 20px 10px;
    margin-top: 30px;
    font-size: 0.9em;
}
.tool-footer-links a { color: #adcaf1; text-decoration: none; margin: 0 10px; transition: color 0.3s ease; }
.tool-footer-links a:hover { color: #fff; text-decoration: underline; }
.tool-footer div:last-child { margin-top: 10px; color: #aaa; }


/* === PRINT SPECIFIC STYLES === */

/* Helper classes to show/hide */
@media screen {
    .print-only { display: none; }
}

@media print {
    .screen-only, button[onclick="window.print()"], .ad-space, .header-compact, .tool-footer {
        display: none !important;
    }

    body {
        background-image: none; background-color: #fff; color: #000; font-size: 9pt; /* Slightly smaller base */
    }
    .container { width: 100%; max-width: none; margin: 0; padding: 0; box-shadow: none; border: none; background-color: transparent; backdrop-filter: none; }

     /* Page Setup */
    @page {
        size: A4;
        margin: 2cm 1cm 2cm 1cm; /* Top, Right, Bottom, Left margins */

        /* PDF Header Content - Adjusted */
        @top-center {
            content: "CalculateAll.com.br\A Ferramentas de Cálculo para facilitar seu dia a dia";
            font-family: Arial, sans-serif; /* Ensure font consistency */
            font-size: 12pt; /* Adjusted size */
            color: #007bff; /* Blue */
            font-weight: bold;
            white-space: pre;
            line-height: 1.3; /* Increased line height */
            border-bottom: 1px solid #ccc;
            padding-bottom: 4mm; /* Space between text and line */
            /* Removed margin-bottom, rely on page margin */
        }

        /* PDF Footer Content */
        @bottom-right {
            content: "CalculateAll.com.br - Página " counter(page);
            font-family: Arial, sans-serif;
            font-size: 8pt;
            color: #007bff; /* Blue */
            /* margin-top: 5mm; */ /* Let page margin handle spacing */
        }
    }

    .year-title { font-size: 14pt; padding: 5px 0; margin-bottom: 8mm; background-color: transparent; border: none; text-align: center; color: #000; font-weight: bold; }
    #controls { display: none; }

    .calendar-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4mm; page-break-inside: avoid; }
    .month-container { box-shadow: none; border: 1px solid #ccc; padding: 4px; background-color: #fff !important; page-break-inside: avoid; flex: none; width: auto; max-width: none; }
    .month-container h2 { font-size: 10pt; margin-bottom: 4px; font-weight: bold; }

    table { font-size: 7pt; width: 100%; margin: 4px 0; background-color: transparent; }
    th, td { padding: 1.5px; height: auto; border: 1px solid #eee; }
    th { background-color: #f8f8f8 !important; font-weight: bold; }

    /* === PRINT Holiday/Sunday Styling === */
    td.holiday, td.sunday { /* Target only cells */
         color: #000080 !important; /* Dark Blue Text */
         font-weight: bold;
         background-color: transparent !important; /* NO background for print */
    }

    .week-number-header, .week-number-cell { font-size: 6.5pt; width: 22px; min-width: 22px; padding: 1.5px; background-color: #f8f8f8 !important; font-weight: normal; color: #444; }

    /* Holiday List Print Styling */
    .holiday-list-container { page-break-before: always; width: 100%; margin: 0; padding: 10px 0; border: none; background-color: #fff !important; box-shadow: none; }
    .holiday-list-container h2 { font-size: 11pt; margin-bottom: 8px; color: #000080 !important; text-align: center; font-weight: bold; }
    .holiday-list { columns: 1; }
    .holiday-list li { font-size: 8.5pt; margin-bottom: 3px; }

    #pdf-header, #pdf-footer { display: none; }
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .header-compact-content { flex-direction: column; text-align: center; }
    .header-logo { margin-bottom: 10px; margin-right: 0; }
    .header-compact-text { text-align: center; }
    #controls { flex-direction: column; align-items: center; }
    #countrySelection { margin-right: 0; margin-bottom: 15px; }
    #yearNavigation { margin-bottom: 0; }
    .calendar-grid { flex-direction: column; align-items: center; }
    .month-container { width: 90%; max-width: none; flex-basis: auto; }
    .container { width: 98%; padding: 10px; backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); /* Reduce blur slightly on mobile */ }
    .holiday-list { columns: 1; }
}

@media (max-width: 480px) {
    .year-title { font-size: 1.5em; }
    #controls { padding: 5px; }
    button { padding: 8px 15px; font-size: 0.9em;}
    #currentYear { font-size: 1.1em; margin: 0 10px;}
    .month-container h2 { font-size: 1.1em; }
    th, td { font-size: 0.8em; padding: 4px; } /* Adjust padding */
    .week-number-header, .week-number-cell { width: 30px; min-width: 30px;}
    .holiday-list-container h2 { font-size: 1.2em; }
    .holiday-list li { font-size: 0.9em; }
}