@font-face {
    font-family: 'Megalopolis';
    src: url('MegalopolisExtra-Regular.woff2') format('woff2'),
         url('MegalopolisExtra-Regular.woff') format('woff'),
         url('MegalopolisExtra-Regular.eot') format('embedded-opentype');
    font-weight: normal;
    font-style: normal;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Megalopolis', Arial, sans-serif;
    background-color: #FFFEF8;
    color: #333;
}

.container {
    display: flex;
    min-height: 100vh;
    padding: 20px;
    gap: 30px;
}

/* SVG pour les traits irréguliers */
svg.rough-border {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: white;
    padding: 30px 20px;
    position: relative;
}

.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    box-shadow: 0 0 0 2px white, 0 0 0 6px #CD3D1D;
    pointer-events: none;
}

.back-link {
    display: block;
    color: #49728B;
    text-decoration: none;
    font-size: 1.2em;
    margin-bottom: 15px;
    transition: color 0.2s;
}

.back-link:hover {
    color: #EFAD00;
}

.sidebar h2 {
    font-size: 2em;
    color: #EFAD00;
    margin-bottom: 20px;
}

.filters {
    margin-bottom: 30px;
}

.filter-item {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    cursor: pointer;
    gap: 10px;
}

.filter-item input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 24px;
    height: 24px;
    border: 2px solid #333;
    border-radius: 4px;
    position: relative;
    transition: all 0.2s;
}

.checkmark.public {
    background-color: #EFAD00;
}

.checkmark.lieux {
    background-color: #58BAB0;
}

.checkmark.reunions {
    background-color: #CD3D1D;
}

.filter-item input[type="checkbox"]:not(:checked) + .checkmark {
    background-color: white;
}

.filter-item span:last-child {
    font-size: 1em;
}

.navigation {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nav-btn {
    font-family: 'Megalopolis', Arial, sans-serif;
    background: white;
    border: 2px solid #333;
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.2s;
}

.nav-btn:hover {
    border: 4px solid #CD3D1D !important;
}

/* Zone calendrier */
.calendar-area {
    flex: 1;
}

.calendar-header h1 {
    font-size: 3em;
    color: #49728B;
    text-align: center;
    margin-bottom: 30px;
}

.calendar-grid {
    background: white;
    padding: 20px;
    position: relative;
}

.calendar-grid::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 4px solid #333;
    pointer-events: none;
}

.weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

.weekday {
    font-size: 1em;
    text-align: center;
    padding: 10px;
    color: #49728B;
    font-weight: bold;
}

.days-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}

/* CRITIQUE : hauteur fixe pour garder l'alignement */
.day-cell {
    height: 120px;
    padding: 8px;
    border: 2px solid #333;
    position: relative;
    background: white;
    cursor: pointer;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.day-cell.empty {
    background: transparent;
    border: none;
    cursor: default;
}

.day-number {
    font-size: 1em;
    font-weight: bold;
    margin-bottom: 5px;
    color: #333;
    flex-shrink: 0;
}

.day-cell-events {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.day-cell.other-month {
    opacity: 0.3;
}

.day-cell.past {
    opacity: 0.5;
    background: #f5f5f5;
}

.day-cell.today {
    border: 3px solid #CD3D1D;
}

.event {
    font-size: 0.75em;
    padding: 3px 6px;
    margin: 3px 0;
    border: 1px solid #333;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.event.public {
    background: #EFAD00;
}

.event.lieux {
    background: #58BAB0;
}

.event.reunions {
    background: #CD3D1D;
    color: white;
}

.event:hover {
    transform: scale(1.05);
    box-shadow: 2px 2px 0 rgba(0,0,0,0.3);
}

/* Popup */
.popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.popup.hidden {
    display: none;
}

.popup-content {
    background: white;
    padding: 30px;
    border: 4px solid #333;
    max-width: 500px;
    max-height: 80vh;
    width: 90%;
    position: relative;
    display: flex;
    flex-direction: column;
}

.close-popup {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 2em;
    cursor: pointer;
}

.popup-content h3 {
    font-size: 2em;
    color: #49728B;
    margin-bottom: 15px;
}

.popup-details {
    max-height: 60vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.popup-details p {
    margin: 10px 0;
    font-size: 1em;
    word-wrap: break-word;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
    }
    
    .days-grid {
        grid-template-columns: 1fr;
    }
    
    .weekdays {
        display: none;
    }
    
    .day-cell {
        height: auto;
        min-height: 60px;
    }
    
    .day-cell.empty {
        display: none;
    }
}
