/* Calendar Widget Styles */
.calendar-widget {
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 20px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    /* Flexbox layout for internal distribution */
    display: flex;
    flex-direction: column;
    height: 100%;
}

.calendar-header {
    background-color: #abc1dd;
    color: #fff;
    padding: 10px 15px;
    border-bottom: 1px solid #ddd;
    text-align: center;
    font-weight: bold;
    position: relative;
}

.calendar-title {
    margin: 0;
    font-size: 16px;
    line-height: 1.5;
}

.calendar-title-link {
    color: #fff;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.calendar-title-link:hover,
.calendar-title-link:focus {
    color: #fff;
    text-decoration: underline;
    opacity: 0.9;
}

.calendar-nav {
    position: absolute;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    padding: 0 15px;
}

.calendar-prev {
    left: 0;
}

.calendar-next {
    right: 0;
}

.calendar-nav-btn {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: #555;
    padding: 5px 10px;
    border-radius: 3px;
}

.calendar-nav-btn:disabled {
    color: #ccc;
    cursor: not-allowed;
}

.calendar-nav-btn:hover:not(:disabled) {
    background-color: #e9e9e9;
    color: #333;
}

.calendar-weekdays {
    display: flex;
    background-color: #f8f8f8;
    border-bottom: 1px solid #eee;
}

.calendar-weekday {
    flex: 1;
    text-align: center;
    padding: 8px 0;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    color: #666;
}

.calendar-days {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
}

.calendar-week {
    display: flex;
    width: 100%;
    border-bottom: 1px solid #eee;
}

.calendar-day {
    width: 14.2857%; /* 100% / 7 days */
    padding: 8px 4px;
    text-align: center;
    border-right: 1px solid #eee;
    position: relative;
    height: 50px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    box-sizing: border-box;
}

.calendar-day:nth-child(7n) {
    border-right: none;
}

.calendar-week:last-child {
    border-bottom: none;
}

.calendar-day-number {
    width: 24px;
    height: 24px;
    line-height: 24px;
    border-radius: 50%;
    margin-bottom: 2px;
}

.calendar-day.today .calendar-day-number {
    font-weight: bold;
}

/* Removed: .calendar-day-events and .calendar-event no longer used */
/* Events are now only displayed via tooltip and legend */

.calendar-legend {
    padding: 10px 15px;
    border-top: 1px solid #eee;
    font-size: 12px;
    flex: 1 0 auto;
}

.calendar-legend-title {
    font-weight: bold;
    margin-bottom: 5px;
    margin-top: 5px;
}

.calendar-legend-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.calendar-legend-item {
    display: flex;
    align-items: center;
    padding: 3px 0;
    border-bottom: 1px solid #f5f5f5;
}

.calendar-legend-item:last-child {
    border-bottom: none;
}

.event-day {
    margin-right: 10px;
    flex-shrink: 0;
}

.event-label {
    flex: 1;
    text-align: left;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .calendar-day {
        padding: 4px 2px;
        height: 40px;
        font-size: 12px;
    }

    .calendar-day-number {
        width: 20px;
        height: 20px;
        line-height: 20px;
        font-size: 11px;
    }

    .calendar-weekday {
        font-size: 10px;
        padding: 6px 2px;
    }

    .calendar-week {
        border-bottom: 1px solid #eee;
    }
}

@media (max-width: 480px) {
    .calendar-day {
        padding: 2px 1px;
        height: 35px;
        font-size: 11px;
    }

    .calendar-day-number {
        width: 18px;
        height: 18px;
        line-height: 18px;
        font-size: 10px;
    }

    .calendar-weekday {
        font-size: 9px;
        padding: 4px 1px;
    }
}

/* CSS Custom Properties for Calendar Colors */
:root {
    --cal-today-bg: #e74c3c;
    --cal-today-color: #fff;

    /* Feriado Nacional */
    --cal-holiday-bg: #cfe1c6;
    --cal-holiday-color: #2d5016;

    /* Ponto Facultativo */
    --cal-optional-bg: #e9dcbc;
    --cal-optional-color: #6b5a3d;

    /* Feriado Estadual */
    --cal-state-bg: #c9e5f5;
    --cal-state-color: #1e5a7d;

    /* Feriado Municipal */
    --cal-city-bg: #efd9d0;
    --cal-city-color: #7d4a3a;

    /* Data Comemorativa */
    --cal-commemorative-bg: #e6a8d7;
    --cal-commemorative-color: #6d2b5c;
}

/* Color classes for event types - Updated to match widget expectations */
.event-today,
.cal-badge-today {
    background-color: var(--cal-today-bg);
    color: var(--cal-today-color);
    font-weight: bold;
}

.event-holiday,
.cal-badge-holiday {
    background-color: var(--cal-holiday-bg);
    color: var(--cal-holiday-color);
}

.event-optional,
.cal-badge-optional {
    background-color: var(--cal-optional-bg);
    color: var(--cal-optional-color);
}

.event-commemorative,
.cal-badge-commem {
    background-color: var(--cal-commemorative-bg);
    color: var(--cal-commemorative-color);
}

/* New classes for state and city holidays */
.event-state {
    background-color: var(--cal-state-bg);
    color: var(--cal-state-color);
}

.event-city {
    background-color: var(--cal-city-bg);
    color: var(--cal-city-color);
}

.cal-day-out,
.event-out-month {
    color: #999 !important;
    background-color: #f9f9f9;
}

/* Enhanced styles for calendar days with events */
.calendar-day.event-today .calendar-day-number,
.calendar-day.event-holiday .calendar-day-number,
.calendar-day.event-optional .calendar-day-number,
.calendar-day.event-commemorative .calendar-day-number,
.calendar-day.event-state .calendar-day-number,
.calendar-day.event-city .calendar-day-number {
    font-weight: 600;
    border-radius: 50%;
    min-width: 24px;
    min-height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.calendar-day.event-today .calendar-day-number {
    /* box-shadow: 0 0 0 2px var(--cal-today-color); */ /* Removed circle ring */
}

/* Hover effects for better UX */
.calendar-day:hover {
    background-color: rgba(0, 0, 0, 0.05);
    cursor: pointer;
}

.calendar-day.event-today:hover {
    background-color: #d43f2f;
}

.calendar-day.event-holiday:hover {
    background-color: var(--cal-holiday-bg);
}

.calendar-day.event-commemorative:hover {
    background-color: var(--cal-commemorative-bg);
}

.calendar-day.event-state:hover {
    background-color: var(--cal-state-bg);
}

.calendar-day.event-city:hover {
    background-color: var(--cal-city-bg);
}

/* Accessibility improvements */
.calendar-widget:focus-within {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.calendar-day:focus {
    outline: 2px solid #007cba;
    outline-offset: -2px;
    position: relative;
    z-index: 10;
}

.calendar-nav-btn:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .calendar-day {
        border-color: #000;
    }

    .event-today {
        background-color: #000;
        color: #fff;
    }

    .event-holiday {
        background-color: #f00;
        color: #fff;
    }

    .event-commemorative {
        background-color: #00f;
        color: #fff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .calendar-tooltip .tooltiptext {
        transition: none;
    }

    .calendar-day:hover {
        transition: none;
    }
}

/* Focus-visible support for better keyboard navigation */
.calendar-nav-btn:focus-visible {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

.calendar-day:focus-visible {
    outline: 2px solid #007cba;
    outline-offset: -2px;
    position: relative;
    z-index: 10;
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Enhanced tooltip styles */
.calendar-tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
}

.calendar-tooltip .tooltiptext {
    visibility: hidden;
    width: 200px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 4px;
    padding: 5px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s ease;
    font-size: 12px;
    line-height: 1.4;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.calendar-tooltip:hover .tooltiptext,
.calendar-tooltip:focus .tooltiptext {
    visibility: visible;
    opacity: 1;
}

/* Loading state for accessibility */
.calendar-widget.loading {
    position: relative;
}

.calendar-widget.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.calendar-widget.loading::before {
    content: attr(aria-label);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 101;
    font-weight: bold;
    color: #333;
}

/* Event kind badges in legend */
.event-kind {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-left: auto;
    flex-shrink: 0;
}

.event-kind-holiday {
    background-color: var(--cal-holiday-bg);
    color: var(--cal-holiday-color);
}

.event-kind-optional {
    background-color: var(--cal-optional-bg);
    color: var(--cal-optional-color);
}

.event-kind-state {
    background-color: var(--cal-state-bg);
    color: var(--cal-state-color);
}

.event-kind-city {
    background-color: var(--cal-city-bg);
    color: var(--cal-city-color);
}

.event-kind-commemorative {
    background-color: var(--cal-commemorative-bg);
    color: var(--cal-commemorative-color);
}

.event-kind-today {
    background-color: var(--cal-today-bg);
    color: var(--cal-today-color);
    border: 1px solid #ddd;
}

/* Equal-height calendar grid rows (Bootstrap 3 enhancement) */
@media (min-width: 992px) {
    /* Make rows use flexbox on desktop */
    .row {
        display: flex;
        flex-wrap: wrap;
    }

    /* Make columns flex containers */
    .col-md-4 {
        display: flex;
        flex-direction: column;
    }
}

/* Prevent flexbox on mobile (stack naturally) */
@media (max-width: 991px) {
    .row {
        display: block;  /* Override flexbox on mobile */
    }
}

/* =============================================
   LUNAR YEAR PAGE - EQUAL HEIGHT CALENDARS
   ============================================= */

/* Force equal height for all calendars in the same row on lua-ano page */
.calendar-year-row {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch; /* Forces columns to have same height */
}

.calendar-year-row > [class*="col-"] {
    display: flex;
    flex-direction: column;
}

.calendar-year-row .month-calendar-container {
    display: flex;
    flex-direction: column;
    flex: 1; /* Fill all available height */
    margin-bottom: 20px;
}

.calendar-year-row .calendar-widget {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.calendar-year-row .calendar-body {
    flex: 1; /* Calendar body expands to fill space */
}

/* Responsiveness: disable flexbox on mobile for natural stacking */
@media (max-width: 767px) {
    .calendar-year-row {
        display: block;
    }

    .calendar-year-row > [class*="col-"] {
        display: block;
    }

    .calendar-year-row .month-calendar-container,
    .calendar-year-row .calendar-widget,
    .calendar-year-row .calendar-body {
        display: block;
        flex: none;
    }

    .calendar-year-row .calendar-widget,
    .calendar-year-row .calendar-body {
        min-height: auto;
    }
}

/* =============================================
   MOON PHASE STYLES
   ============================================= */

/* Moon phase container */
.calendar-moon-phase {
    position: absolute;
    pointer-events: none;
    user-select: none;
    line-height: 1;
}

/* Moon emoji */
.calendar-moon-phase .moon-emoji {
    display: inline-block;
    filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.3));
    transition: transform 0.3s ease, filter 0.3s ease;
}

.calendar-day:hover .calendar-moon-phase .moon-emoji {
    transform: scale(1.2);
    filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.5));
}

/* Position variants */
.moon-position-top {
    top: 2px;
    right: 2px;
}

.moon-position-bottom {
    bottom: 2px;
    right: 2px;
}

.moon-position-corner {
    top: 2px;
    left: 2px;
}

/* Size variants */
.moon-phase-small .moon-emoji {
    font-size: 16px;
}

.moon-phase-medium .moon-emoji {
    font-size: 24px;
}

.moon-phase-large .moon-emoji {
    font-size: 32px;
}

/* Responsive moon phase sizes */
@media (max-width: 767px) {
    .moon-phase-medium .moon-emoji {
        font-size: 20px;
    }

    .moon-phase-large .moon-emoji {
        font-size: 24px;
    }

    .moon-phase-small .moon-emoji {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .moon-phase-medium .moon-emoji,
    .moon-phase-large .moon-emoji {
        font-size: 18px;
    }

    .moon-phase-small .moon-emoji {
        font-size: 14px;
    }
}

/* Adjust calendar day for moon phases */
.calendar-day {
    position: relative;
}

/* Print styles for moon phases */
@media print {
    .calendar-moon-phase {
        display: none !important;
    }
}
