/* Calendar Controls */
:root {
    --calendar-col-width: 200px;
}

.calendar-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
}

.filter-btn {
    padding: 8px 16px;
    background-color: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.filter-btn:hover {
    background-color: #e0e0e0;
}

.filter-btn.active {
    background-color: #8FAD88;
    color: white;
    border-color: #8FAD88;
}

/* Calendar Grid */
.calendar-grid {
    background: white;
    position: relative;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    overflow-x: auto; /* Allow horizontal scroll on small screens */
    padding-bottom: 10px;
    width: 100%;
    box-sizing: border-box;
}

.calendar-header {
    display: grid;
    grid-template-columns: var(--calendar-col-width) repeat(12, 1fr);
    border-bottom: 2px solid #eee;
    min-width: 800px; /* Minimum width to keep layout intact */
}

.header-cell {
    padding: 10px 5px;
    text-align: center;
    font-weight: bold;
    color: #555;
    font-size: 0.9rem;
    border-left: 1px solid #f9f9f9;
}

.header-cell:first-child {
    text-align: left;
    padding-left: 15px;
    border-left: none;
}

.calendar-row {
    display: grid;
    grid-template-columns: var(--calendar-col-width) repeat(12, 1fr);
    border-bottom: 1px solid #eee;
    min-width: 800px;
    position: relative;
    height: auto;
    min-height: 40px;
    align-items: center;
}

.calendar-row:hover {
    background-color: #fcfcfc;
}

.animal-name {
    padding: 5px 15px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #333;
    z-index: 2;
    background: rgba(255,255,255,0.9); /* Ensure readability over bars if overlap */
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.2;
}

.date-range {
    font-size: 0.75rem;
    color: #666;
    font-weight: normal;
    margin-top: 2px;
}

.month-cell {
    height: 100%;
    border-left: 1px solid #f9f9f9;
    position: relative;
}

/* Season Bars */
.season-bar {
    position: absolute;
    height: 20px;
    top: 10px;
    background-color: #8FAD88;
    border-radius: 4px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.season-bar:hover {
    opacity: 1;
    cursor: pointer;
}

/* Current Month Indicator */
.current-month-indicator {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: rgba(255, 0, 0, 0.3);
    z-index: 1;
    pointer-events: none;
}

/* Dark mode adjustments if needed can be added here using body.dark-mode selector */
body.dark-mode .calendar-grid {
    background: #2d2d2d;
    color: #e0e0e0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

body.dark-mode .calendar-header {
    border-bottom-color: #444;
}

body.dark-mode .header-cell {
    color: #bbb;
    border-left-color: #444;
}

body.dark-mode .calendar-row {
    border-bottom-color: #444;
}

body.dark-mode .calendar-row:hover {
    background-color: #383838;
}

body.dark-mode .month-cell {
    border-left-color: #444;
}

body.dark-mode .animal-name {
    background: rgba(45, 45, 45, 0.95);
    color: #e0e0e0;
}

body.dark-mode .date-range {
    color: #aaa;
}

body.dark-mode .filter-btn {
    background-color: #3d3d3d;
    color: #e0e0e0;
    border-color: #555;
}

body.dark-mode .filter-btn:hover {
    background-color: #4d4d4d;
}

body.dark-mode .filter-btn.active {
    background-color: #66bb6a;
    color: #121212;
    border-color: #66bb6a;
}

body.dark-mode .season-bar {
    background-color: #66bb6a;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    :root {
        --calendar-col-width: 100px;
    }

    .calendar-header, 
    .calendar-row {
        /* Use variable for consistency */
        min-width: 100%; /* Fit to screen */
    }

    .header-cell {
        font-size: 0.7rem;
        padding: 5px 1px;
    }

    /* Rotate month headers to fit in narrow columns */
    .header-cell:not(:first-child) {
        writing-mode: vertical-lr;
        transform: rotate(180deg);
        height: 60px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .animal-name {
        font-size: 0.8rem;
        padding: 8px 5px;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .date-range {
        font-size: 0.65rem;
        display: block;
        margin-top: 2px;
    }

    .header-cell:first-child,
    .animal-name {
        position: sticky;
        left: 0;
        z-index: 20;
        background-color: #fff;
        border-right: 1px solid #ddd;
        box-shadow: 4px 0 8px -2px rgba(0,0,0,0.1);
    }

    body.dark-mode .header-cell:first-child,
    body.dark-mode .animal-name {
        background-color: #2d2d2d;
        border-right-color: #444;
        box-shadow: 4px 0 8px -2px rgba(0,0,0,0.3);
    }
}