/* Style pour l'interface membres */

.login-body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0077be 0%, #004d7a 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-container {
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    padding: 2rem;
    width: 100%;
    max-width: 450px;
    animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    color: #0077be;
    margin: 0 0 0.5rem 0;
    font-size: 1.8rem;
}

.login-header h2 {
    color: #666;
    margin: 0;
    font-size: 1.2rem;
    font-weight: normal;
}

/* Styles pour les boutons d'inscription dans les modals */
.modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

#registrationButtons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    outline: none;
    box-shadow: none;
}

.btn-primary {
    background-color: #007bff;
    color: white;
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: #0056b3;
    box-shadow: none;
    outline: none;
}

.btn-danger {
    background-color: #dc3545;
    color: white;
}

.btn-danger:hover,
.btn-danger:focus {
    background-color: #c82333;
    box-shadow: none;
    outline: none;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover,
.btn-secondary:focus {
    background-color: #545b62;
    box-shadow: none;
    outline: none;
}

.text-success {
    color: #28a745 !important;
}

.text-muted {
    color: #6c757d !important;
}

.ms-2 {
    margin-left: 0.5rem;
}

/* Styles pour la liste des participants */
.participants-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.participant-badge {
    background-color: #e9ecef;
    color: #495057;
    padding: 0.25rem 0.5rem;
    border-radius: 15px;
    font-size: 0.9rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.participant-badge:before {
    content: "\f007";
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    font-size: 0.8rem;
}

#modalParticipantsSection .detail-row {
    margin-bottom: 0.5rem;
}

/* Badge inscription dans my-registrations */
.inscription-badge {
    background-color: #28a745;
    color: white;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    margin-left: 0.5rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.inscription-badge i {
    font-size: 0.7rem;
}

/* Couleurs des types d'événements (identiques au calendrier) avec opacité améliorée */
.event-type.type-piscine {
    background-color: rgba(25, 118, 210, 0.15);
    color: #1565c0;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid rgba(25, 118, 210, 0.3);
}

.event-type.type-sortie {
    background-color: rgba(46, 125, 50, 0.15);
    color: #2e7d32;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid rgba(46, 125, 50, 0.3);
}

.event-type.type-formation {
    background-color: rgba(245, 124, 0, 0.15);
    color: #ef6c00;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid rgba(245, 124, 0, 0.3);
}

.event-type.type-reunion {
    background-color: rgba(123, 31, 162, 0.15);
    color: #6a1b9a;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid rgba(123, 31, 162, 0.3);
}

.event-type.type-autre {
    background-color: rgba(194, 24, 91, 0.15);
    color: #ad1457;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid rgba(194, 24, 91, 0.3);
}

.auth-tabs {
    display: flex;
    margin-bottom: 2rem;
    border-bottom: 2px solid #f0f0f0;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1rem;
    color: #666;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.tab-btn.active {
    color: #0077be;
    border-bottom-color: #0077be;
    font-weight: 600;
}

.tab-btn:hover {
    color: #0077be;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.login-form {
    width: 100%;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: #333;
    font-weight: 500;
}

.form-group label i {
    color: #0077be;
    margin-right: 0.5rem;
    width: 16px;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.form-group input:focus {
    outline: none;
    border-color: #0077be;
}

.form-group input:invalid {
    border-color: #dc3545;
}

.btn-full {
    width: 100%;
    padding: 15px;
    font-size: 1.1rem;
    margin-top: 1rem;
}

/* Make the empty-state action button smaller to avoid dominating the empty screen */
.empty-state .btn {
    padding: 8px 14px;
    font-size: 0.95rem;
    border-radius: 6px;
}

.empty-state .btn i { /* align icon exactly with text baseline */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px; /* explicit square container */
    height: 20px;
    font-size: 21px; /* control glyph size inside container */
    line-height: 1;
    vertical-align: middle;
    margin-right: 0.5rem;
    transform: translateY(8px); /* small nudge to perfectly center visually */
}

/* Ensure icons inside buttons are vertically centered across the site */
.btn i,
.btn .fa,
.btn .fas,
.btn .far,
.btn .fal,
.btn .fab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    line-height: 1;
}

/* Tweak the specific empty-state back button to ensure perfect centering */
.empty-state .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 10px 16px;
}

/* Center empty-state content and button */
.empty-state {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1.5rem 0;
}

.empty-state .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0.5rem auto 0 auto;
}

.empty-state .btn { line-height: 1; }

@media (max-width: 480px) {
    .empty-state .btn {
        padding: 10px 16px;
        font-size: 0.95rem;
    }
}

.login-footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e0e0e0;
    text-align: center;
    font-size: 0.9rem;
    color: #666;
}

.login-footer p {
    margin: 0.5rem 0;
}

.back-link {
    display: inline-block;
    margin-top: 1rem;
    color: #0077be;
    text-decoration: none;
    transition: color 0.3s ease;
}

.back-link:hover {
    color: #005a8b;
}

/* Dashboard membres */
.member-body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
}

.member-container {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-height: 100vh;
}

.member-sidebar {
    background: linear-gradient(180deg, #0077be 0%, #005a8b 100%);
    color: white;
    padding: 1.5rem;
}

.sidebar-header {
    margin-bottom: 2rem;
}

.member-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.member-logo img {
    height: 120px;
    width: auto;
    display: block;
}

.sidebar-header h2 {
    margin: 0 0 0.5rem 0;
    font-size: 1.2rem;
    color: white;
}

.sidebar-header p {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.8;
}

.member-sidebar h2 {
    margin: 0 0 2rem 0;
    font-size: 1.2rem;
}

.sidebar-nav ul,
.member-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav li,
.member-nav li {
    margin-bottom: 0.5rem;
}

.sidebar-nav a,
.member-nav a {
    /* use flex so icon + label align perfectly */
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.sidebar-nav a:hover,
.sidebar-nav a.active,
.member-nav a:hover,
.member-nav a.active {
    background: rgba(255,255,255,0.1);
    color: white;
}

.member-nav a i,
.member-nav summary i,
.member-nav .nav-sub li a i {
    /* normalize all sidebar icon boxes to a fixed square and center glyphs */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    font-size: 16px;
    flex: 0 0 20px;
    margin: 0;
    vertical-align: middle;
    /* tiny nudge for optical centering on some fonts */
    transform: translateY(0.5px);
}

/* Details-based dropdown styles for sidebar (updated caret & animation)
   - Use a lightweight inline-SVG chevron for the caret (no FA dependency)
   - Use flex layout for the summary so text and caret align perfectly
   - Smooth rotate + subtle bounce when opening for a friendlier feel */
.member-nav .nav-details summary {
    list-style: none;
    cursor: pointer;
    padding: 12px 15px;
    color: rgba(255,255,255,0.95);
    border-radius: 8px;
    transition: background 180ms ease, color 180ms ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Fallback: center any raw <i> glyph that wasn't wrapped */
.member-nav summary i,
.member-nav a i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.member-nav .nav-details[open] > summary,
.member-nav .nav-details summary:hover {
    background: rgba(255,255,255,0.08);
    color: white;
}

/* remove list marker (default browser) */
.member-nav .nav-details summary::marker { display: none; }

/* Inline SVG chevron used as caret. encoded as UTF-8 SVG; color set to white for contrast */
.member-nav .nav-details summary::after {
    content: '';
    display: inline-block;
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 18px 18px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M6 9l6 6 6-6' fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2'/></svg>");
    transform-origin: center;
    transition: transform 220ms cubic-bezier(.2,.9,.2,1), opacity 180ms ease;
    opacity: 0.95;
}

/* Rotate and give a small friendly bounce when opening */
.member-nav .nav-details[open] > summary::after {
    transform: rotate(180deg) translateY(-1px);
    animation: nav-bounce 420ms ease;
}

@keyframes nav-bounce {
    0% { transform: rotate(180deg) translateY(-2px) scale(0.98); }
    40% { transform: rotate(180deg) translateY(0px) scale(1.04); }
    100% { transform: rotate(180deg) translateY(-1px) scale(1); }
}

.member-nav .nav-sub {
    list-style: none;
    margin: 8px 0 12px 0;
    padding: 0 0 0 12px;
}

.member-nav .nav-sub li a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.95rem;
}

.member-nav .nav-sub li a:hover {
    background: rgba(255,255,255,0.06);
    color: white;
}

/* Small animation for sublist appearing (kept similar but eased slightly) */
.member-nav .nav-sub {
    transform-origin: top;
    transition: transform 200ms cubic-bezier(.2,.9,.2,1), opacity 180ms ease, max-height 220ms ease;
    opacity: 1;
}
.member-nav .nav-details:not([open]) .nav-sub {
    transform: scaleY(0.985);
    opacity: 0.96;
    max-height: 0;
    overflow: hidden;
}
.member-nav .nav-details[open] .nav-sub {
    transform: scaleY(1);
    opacity: 1;
    max-height: 400px;
}

.member-main {
    padding: 2rem;
}

.member-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e0e0e0;
}

.member-header h1 {
    color: #333;
    margin: 0;
    font-size: 1.8rem;
}

.member-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.member-user span {
    color: #666;
}

/* Contenu principal */
.member-content {
    padding: 2rem;
}

/* Calendrier */
.calendar-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: hidden;
}

.calendar-header {
    background: linear-gradient(90deg, #0077be 0%, #00a859 100%);
    color: white;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.calendar-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.calendar-nav button {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.calendar-nav button:hover {
    background: rgba(255,255,255,0.3);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.calendar-day-header {
    background: #f8f9fa;
    padding: 1rem;
    text-align: center;
    font-weight: 600;
    color: #666;
    border-bottom: 1px solid #e0e0e0;
}

.calendar-day {
    min-height: 120px;
    padding: 0.5rem;
    border-bottom: 1px solid #e0e0e0;
    border-right: 1px solid #e0e0e0;
    position: relative;
    background: white;
    transition: background-color 0.3s ease;
}

.calendar-day:hover {
    background: #f8f9fa;
}

.calendar-day.other-month {
    background: #fafafa;
    color: #ccc;
}

.calendar-day.today {
    background: #e3f2fd;
}

.calendar-day-number {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #333;
}

.event-item {
    font-size: 0.8rem;
    padding: 2px 6px;
    margin: 1px 0;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: transform 0.2s ease;
}

.event-item:hover {
    transform: scale(1.02);
}

.event-item.piscine {
    background: #e3f2fd;
    color: #1976d2;
    border-left: 3px solid #1976d2;
}

.event-item.sortie {
    background: #e8f5e8;
    color: #2e7d32;
    border-left: 3px solid #2e7d32;
}

.event-item.formation {
    background: #fff3e0;
    color: #f57c00;
    border-left: 3px solid #f57c00;
}

.event-item.reunion {
    background: #f3e5f5;
    color: #7b1fa2;
    border-left: 3px solid #7b1fa2;
}

.event-item.autre {
    background: #fce4ec;
    color: #c2185b;
    border-left: 3px solid #c2185b;
}

/* Modal pour les événements */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e0e0e0;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: #999;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1001;
    line-height: 0;
    padding: 0;
    margin: 0;
    text-align: center;
    vertical-align: middle;
    font-family: Arial, sans-serif;
    font-weight: normal;
}

.modal-close:hover {
    color: #0077b6;
    background: rgba(255, 255, 255, 0.9);
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(0, 119, 182, 0.3);
    filter: brightness(1.2);
}

.modal-close:active {
    transform: scale(0.95);
}

.event-details {
    margin-bottom: 1.5rem;
}

.event-details h3 {
    color: #333;
    margin: 0 0 1rem 0;
}

.event-info {
    display: grid;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
}

.event-info-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.event-info-item i {
    color: #0077be;
    width: 16px;
}

.participants-section {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #e0e0e0;
}

.participants-count {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 1rem;
}

.action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* Responsive */
@media (max-width: 768px) {
    .member-container {
        grid-template-columns: 1fr;
    }
    
    .member-sidebar {
        display: none;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .calendar-day {
        min-height: 80px;
        font-size: 0.9rem;
    }
    
    .calendar-day-header {
        padding: 0.5rem;
        font-size: 0.9rem;
    }
    
    .member-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
}

/* Styles pour les événements et inscriptions */
.events-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

.event-separator {
    margin: 1.5rem 0;
    border: none;
    border-top: 1px solid #e5e5e5;
    position: relative;
    width: 100%;
}

.event-separator::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 2px;
    background: linear-gradient(90deg, #0066cc, #4a90e2);
    border-radius: 2px;
}

.event-card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 1.5rem;
    margin-bottom: 0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.event-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

/* === MENU HAMBURGER ET NAVIGATION MOBILE === */

/* Styles pour le header avec hamburger */
.member-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Menu hamburger - caché par défaut sur desktop */
.hamburger-menu {
    display: none;
    flex-direction: column;
    cursor: pointer;
    padding: 0.5rem;
    gap: 4px;
}

.hamburger-menu span {
    width: 25px;
    height: 3px;
    background-color: #0066cc;
    border-radius: 2px;
}

/* Animations du hamburger supprimées pour éviter la transformation en croix */

/* Sidebar mobile - cachée par défaut */
.member-sidebar-mobile {
    position: fixed;
    top: 0;
    left: -300px;
    width: 300px;
    height: 100vh;
    background: linear-gradient(180deg, #0077be 0%, #005a8b 100%);
    color: white;
    padding: 1.5rem;
    z-index: 1000;
    transition: left 0.3s ease;
    overflow-y: auto;
}

.member-sidebar-mobile.active {
    left: 0;
}

.mobile-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.mobile-sidebar-header h2 {
    margin: 0;
    font-size: 1.2rem;
}

.close-sidebar {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.close-sidebar:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Overlay pour mobile */
.mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-overlay.active {
    display: block;
    opacity: 1;
}

/* Responsive - afficher le hamburger sur mobile */
@media (max-width: 768px) {
    .member-container {
        grid-template-columns: 1fr;
    }
    
    .member-sidebar {
        display: none;
    }
    
    .hamburger-menu {
        display: flex;
    }
    
    .member-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 1rem;
    }
    
    .member-header-left {
        flex: 1;
    }
    
    .member-header h1 {
        font-size: 1.3rem;
        margin: 0;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .calendar-day {
        min-height: 80px;
        font-size: 0.9rem;
    }
    
    .calendar-day-header {
        padding: 0.5rem;
        font-size: 0.9rem;
    }
}

/* === BADGES DE STATUT === */

.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.375rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success {
    background-color: #28a745;
    color: white;
}

.badge-secondary {
    background-color: #6c757d;
    color: white;
}

.badge-danger {
    background-color: #dc3545;
    color: white;
}

.text-success {
    color: #28a745 !important;
}

.text-muted {
    color: #6c757d !important;
}

.text-danger {
    color: #dc3545 !important;
}

/* Keep calendar cells a fixed height on mobile and make event list scrollable inside the cell */
@media (max-width: 768px) {
    .calendar-day {
        /* enforce a fixed height so cells don't grow when many events are present */
        min-height: 84px;
        max-height: 84px;
        overflow: visible;
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    /* The events container will take remaining space and be scrollable when necessary */
    .calendar-day .events-container {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        gap: 4px;
        padding-right: 4px; /* room for scrollbar on some platforms */
    }

    /* Make individual event items wrap and show ellipsis if too long */
    .calendar-day .event-item {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* Ensure the full month fits vertically on small screens by adapting row height to viewport.
   We calculate rows for up to 6 weeks (max), subtract header/controls space, and set grid-auto-rows
   so the calendar always shows the whole month without requiring page scroll. */
@media (max-width: 480px) {
    .calendar-container {
        max-height: calc(100vh - 110px); /* leave space for header/nav/padding */
        overflow: hidden;
    }

    .calendar-header {
        padding: 0.6rem 0.8rem;
    }

    .calendar-grid {
        /* Make 7 columns fit the viewport by using a viewport-based column width.
           This ensures the full month is visible horizontally without needing zoom.
           As a fallback, the container still allows horizontal scroll if content exceeds viewport. */
        grid-template-columns: repeat(7, calc((100vw - 20px) / 7));
        width: 100vw;
        /* Reserve up to 6 rows (some months span 6 weeks). This divides available height equally. */
        grid-auto-rows: calc((100vh - 160px) / 6);
        gap: 0;
    }

    .calendar-day {
        min-height: 0;
        max-height: none;
        padding: 0.35rem;
        font-size: 0.85rem;
        display: flex;
        flex-direction: column;
    }

    .calendar-day-number {
        font-size: 0.85rem;
    }

    .calendar-day .events-container {
        max-height: calc((100vh - 160px) / 6 - 28px); /* leave room for day number */
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        /* Allow event text to wrap on very narrow columns so they don't force horizontal overflow */
        white-space: normal;
    }

    .event-item {
        font-size: 0.72rem;
        padding: 2px 4px;
    }

    /* Reduce header controls size so they don't push the calendar off-screen */
    .calendar-nav button {
        padding: 6px 8px;
        font-size: 0.85rem;
    }

    /* If the calculated columns are still too tight for some devices, allow horizontal scroll
       rather than clipping content (smooth touch scrolling on mobile). */
    .calendar-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Make individual event labels wrap where necessary to avoid ellipsis that hides info */
    .calendar-day .event-item {
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        display: block;
    }
}