/* Global Styles & Variables */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #34495e;
    --accent-color: #e74c3c;
    --avemaria-color: #3498db;
    --cenacoli-color: #9b59b6;
    --bg-color: #ecf0f1;
    --card-bg: #ffffff;
    --text-color: #2c3e50;
    --border-radius: 8px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 3px;
    /* Reduced padding */
    line-height: 1.4;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* Header & Navigation */
header {
    text-align: center;
    margin-bottom: 30px;
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

h1 {
    margin: 0 0 10px 0;
    color: var(--primary-color);
    font-size: 1.5rem;
    /* Default reduced size */
}

h1 a {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

@media (max-width: 400px) {
    h1 {
        font-size: 1.2rem;
        /* Smaller for mobile to ensure single line */
    }
}

.nav-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    /* Space between Month and Year groups */
    margin-bottom: 10px;
}

.nav-group {
    display: flex;
    align-items: center;
    font-size: 1.2rem;
    gap: 20px;
}

/* Navigation Buttons */
.nav-btn {
    background: none;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 2px 8px;
    font-size: 1rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    font-weight: bold;
}

.nav-btn:hover {
    background-color: var(--primary-color);
    color: #fff;
}

.nav-label {
    min-width: 80px;
    text-align: center;
    display: inline-block;
    font-weight: bold;
    color: var(--secondary-color);
}


/* Filter Controls */
.filter-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 5px;
}

.btn-filter {
    text-decoration: none;
    padding: 6px 12px;
    background-color: #f1f1f1;
    color: var(--secondary-color);
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.btn-filter:hover {
    background-color: #e2e6ea;
}

/* Active states specific per tipo per evitare il "negativo" */
.btn-filter.entry-cenacoli.active {
    background-color: #cceeff;
    color: navy;
    font-weight: bold;
    border: 2px solid navy;
    box-shadow: inset 0 0 5px rgba(0, 0, 128, 0.2);
}

.btn-filter.entry-avemaria.active {
    background-color: #fffeaa;
    color: green;
    font-weight: bold;
    border: 2px solid green;
    box-shadow: inset 0 0 5px rgba(0, 128, 0, 0.2);
}

/* Calendar Grid */
.calendar-wrapper {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.month-block {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.month-title {
    font-size: 1.5rem;
    color: var(--secondary-color);
    border-bottom: 2px solid var(--bg-color);
    padding-bottom: 10px;
    margin-bottom: 20px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Responsive Grid for Days */
.days-grid {
    display: grid;
    /* Allows 3 columns on ~360px+ screens (3*100 + gaps) */
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 4px;
    /* Reduced gap */
}

/* Mobile: Ensure we don't force single column unless very small */
@media (max-width: 350px) {
    .days-grid {
        grid-template-columns: repeat(2, 1fr);
        /* Force 2 cols on very small screens */
    }
}

.day-cell {
    border: 1px solid #eee;
    border-radius: var(--border-radius);
    padding: 4px;
    /* Reduced padding */
    min-height: 80px;
    /* Reduced min-height */
    background: #fff;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
}

.day-cell:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.day-number {
    font-weight: bold;
    font-size: 0.9rem;
    margin-bottom: 3px;
    background-color: #34495e;
    /* Dark Gray */
    color: #ffffff;
    /* White text */
    padding: 4px;
    border-radius: 4px;
    border-bottom: none;
    text-align: center;
}

.day-name {
    font-size: 0.75rem;
    color: #bdc3c7;
    margin-bottom: 3px;
}

/* Data Cells */
.data-entry {
    margin-top: 1px;
    padding: 1px 4px;
    border-radius: 2px;
    font-size: 0.8rem;
    color: var(--text-color);
    margin-bottom: 1px;
    line-height: 1.2;
}

.entry-avemaria {
    background-color: #fffeaa;
    color: green;
    border: 1px solid #e6e600;
}

.entry-cenacoli {
    background-color: #cceeff;
    color: navy;
    border: 1px solid #99ccff;
}

.no-data {
    color: #ccc;
    font-style: italic;
    font-size: 0.8rem;
    margin-top: auto;
    /* Push to bottom */
}

/* Bottom Navigation */
.bottom-nav {
    margin-top: 10px;
    margin-bottom: 15px;
    text-align: center;
}

.btn-wide-next {
    width: 100%;
    max-width: 400px;
    /* Limit width on desktop */
    padding: 5px 0;
    background-color: #999999;
    /* Gray as requested */
    color: #fff;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1.5rem;
    cursor: pointer;
    transition: background-color 0.3s;
    font-weight: bold;
    line-height: 1.2;
}

.btn-wide-next:hover {
    background-color: #777;
    box-shadow: var(--shadow);
}

.btn-participa {
    width: 100%;
    max-width: 400px;
    padding: 5px 0;
    background-color: blue;
    color: #fff;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1.5rem;
    cursor: pointer;
    transition: background-color 0.3s;
    font-weight: bold;
    line-height: 1.2;
}

.btn-participa:hover {
    background-color: darkblue;
    box-shadow: var(--shadow);
}

/* History List Styles */
.history-year {
    background-color: #f0f0f0;
    padding: 8px;
    font-weight: bold;
    margin-top: 15px;
    border-radius: 4px;
    color: var(--primary-color);
}

.history-month {
    background-color: #34495e;
    /* Dark Gray */
    color: #fff;
    /* White text */
    font-weight: bold;
    margin-top: 10px;
    padding: 6px 10px;
    border-radius: 4px;
}

.history-row {
    padding: 6px 10px;
    /* Reduced padding */
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-left: 5px;
}