:root {
    --module-radius: 35px;
    --color-border: #d8dde2;
    --color-bg: #ffffff;
    --color-accent: #0078C6;
    --color-accent-alt: #0b5ca8;
}

/* =================================
   Reset & Base
================================= */
* {
    box-sizing: border-box;
}
html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
}
body {
    font-family: "Poppins", Arial, sans-serif;
    background: #f5f7fa;
    color: #222;
    -webkit-font-smoothing: antialiased;
}
main {
    padding: 25px;
}
h1,
h2,
h3 {
    font-weight: 600;
    line-height: 1.2;
}
h1 {
    font-size: 34px;
}
h2 {
    font-size: 22px;
}
a {
    color: #0b6db3;
    text-decoration: none;
}

.bienvenue-text {
    text-align: center;
    color: var(--color-accent);
}
.box-titles {
    margin: 15px 0 35px;
    padding: 0;
}

/* =================================
   Header & Navigation
================================= */
header {
    background: #0078C6;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,.12);
    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
}
.header-inner {
    display: flex;
    align-items: stretch;
    width: 100%;
    padding: 0 30px;
}
.logo {
    text-decoration: none;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 5px 13px 0;
    white-space: nowrap;
    width: 130px;
    filter: brightness(0) invert(1);
}
.logo-mark {
    font-size: 22px;
    line-height: 1;
}
.main-nav {
    flex: 1;
    display: flex;
}
.nav-list {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 0;
}
.nav-list li {
    display: flex;
}
.nav-list a {
    display: flex;
    white-space: nowrap;
    align-items: center;
    padding: 0 20px;
    text-decoration: none;
    color: #fff;
    font-weight: 500;
    font-size: 15px;
    transition: background .25s;
    border-radius: 40px;
    margin: 10px 0;
}
.nav-list a:hover,
.nav-list a:focus {
    background: rgba(255,255,255,.18);
}

/* =================================
   Login Button & User Menu
================================= */
.login-wrapper {
    display: flex;
    align-items: stretch;
}
.login-btn {
    display: flex;
    align-items: center;
    background: #ffffff;
    color: #0078C6;
    font-weight: 600;
    margin: 12px 0;
    padding: 0 30px;
    border-radius: 40px;
    box-shadow: -6px 0 12px -6px rgba(0,0,0,.25);
    text-decoration: none;
    font-size: 15px;
    transition: background .25s, color .25s;
}
.login-btn:hover {
    background: #e8f3ff;
    color: #005a91;
}

.user-menu {
    align-content: center;
    position: relative;
    display: inline-block;
}

.user-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.3s ease;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 12px 0;
}

.user-toggle:hover {
    background-color: rgba(255, 255, 255, 0.18);
}

.user-toggle svg {
    display: block;
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 28px -6px rgba(24,48,74,.20), 0 2px 6px rgba(0,0,0,.06);
    min-width: 180px;
    padding: 8px 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
}

.user-menu:hover .user-dropdown,
.user-toggle:focus + .user-dropdown,
.user-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #333;
    text-decoration: none;
    transition: background-color 0.3s ease;
    font-size: 14px;
    font-weight: 500;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.dropdown-item:hover {
    background-color: #f5f7fa;
    color: #0078C6;
}

.dropdown-item svg {
    flex-shrink: 0;
    color: #666;
}

.dropdown-item:hover svg {
    color: #0078C6;
}

.mobile-login .user-menu {
    width: 100%;
}

.mobile-login .user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    font-weight: 600;
    color: #fff;
    font-size: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 8px;
}

.mobile-login .user-info svg {
    color: #fff;
}

.mobile-login .user-dropdown {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    background: transparent;
    padding: 0;
    min-width: auto;
}

.mobile-login .dropdown-item {
    padding: 14px 20px;
    border-left: 3px solid transparent;
    color: #fff;
    font-size: 15px;
    margin: 4px 0;
    border-radius: 0 40px 40px 0;
}

.mobile-login .dropdown-item:hover {
    background-color: rgba(255, 255, 255, 0.18);
    border-left-color: #fff;
    color: #fff;
}

.mobile-login .dropdown-item svg {
    color: #fff;
}

.mobile-login .dropdown-item:hover svg {
    color: #fff;
}

/* =================================
   Burger Button
================================= */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: transparent;
    border: 0;
    cursor: pointer;
    width: 44px;
    padding: 8px;
    margin-left: auto;
    position: relative;
}

.menu-toggle span {
    display: block;
    width: 25px;
    height: 4px;
    background: #fff;
    border-radius: 2px;
    margin: 2px 0;
    transition: .35s;
}

/* =================================
   Mobile Panel
================================= */
.mobile-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: auto;
    width: 280px;
    max-width: 80%;
    height: 100vh;
    background: #0078C6;
    box-shadow: -4px 0 18px -4px rgba(0,0,0,.35);
    display: flex;
    flex-direction: column;
    padding: 60px 15px 85px;
    gap: 28px;
    transform: translateX(-100%);
    transition: transform .38s cubic-bezier(.65,.05,.36,1);
    z-index: 300;
    overflow-y: auto;
}
html.nav-open .mobile-panel {
    transform: translateX(0);
}
.mobile-panel .nav-list {
    flex-direction: column;
}
.mobile-panel .nav-list a {
    margin: 0 0 10px;
    padding: 14px 18px;
    border-radius: 40px;
    font-size: 16px;
}
.mobile-panel .nav-list a:hover {
    background: rgba(255,255,255,.35);
}
.mobile-login .login-btn {
    width: 100%;
    justify-content: center;
    box-shadow: none;
    border-radius: 40px;
    padding: 14px 10px;
    margin: 0;
}

/* =================================
   Overlay
================================= */
.menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    opacity: 0;
    pointer-events: none;
    transition: opacity .35s;
    z-index: 260;
}
html.nav-open .menu-overlay {
    opacity: 1;
    pointer-events: auto;
}

.desktop-only {
    display: flex;
}
html.nav-open,
body.nav-open {
    overflow: hidden;
    touch-action: none;
}

/* =================================
   Burger Animation
================================= */
html.nav-open .menu-toggle span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
html.nav-open .menu-toggle span:nth-child(2) {
    opacity: 0;
}
html.nav-open .menu-toggle span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* =================================
   Layout Sections
================================= */
.home-sections {
    display: flex;
    align-items: stretch;
    gap: 40px;
    flex-wrap: nowrap;
    margin-top: 10px;
}
.home-sections .calendar-module {
    flex: 2 1 0;
}

/* =================================
   Module: Accès & Règles
================================= */
.access-module {
    flex: 1.15 1 0;
    background: #fff;
    padding: 28px 30px 40px;
    box-shadow: 0 10px 28px -6px rgba(24,48,74,.20), 0 2px 6px rgba(0,0,0,.06);
    border-radius: var(--module-radius);
    position: relative;
    overflow: hidden;
}
.access-switch-group,
.rules-switch-group {
    display: flex;
    gap: 14px;
    margin: 0 0 18px;
    flex-wrap: nowrap;
}
.access-switch,
.rules-switch {
    flex: 1 1 0;
    background: #d2d8dd;
    border: 0;
    padding: 12px 20px;
    border-radius: 40px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 600;
    color: #28343d;
    transition: .25s;
    box-shadow: 0 3px 10px -2px rgba(0,0,0,.15);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    text-decoration: none;
}
.access-switch.active,
.rules-switch.active {
    background: var(--color-accent);
    color: #fff;
}
.access-switch:not(.active):hover,
.rules-switch:hover {
    background: #c5ccd1;
}
.access-plan {
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #eef2f5;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    margin: 0 0 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}
.access-plan img {
    height: 100%;
    object-fit: contain;
    display: block;
}
.rules-title {
    margin: 0 0 14px;
    font-size: 20px;
}

/* =================================
   Module: Calendrier Wrapper
================================= */
.home-calendar-wrapper {
    width: 100%;
    margin: 10px 0 70px;
    padding: 40px 48px 54px;
    background: #fff;
    box-shadow: 0 10px 28px -6px rgba(24,48,74,.20), 0 2px 6px rgba(0,0,0,.06);
    position: relative;
    overflow: hidden;
}
.home-calendar-wrapper h2 {
    margin-top: 0;
}

/* =================================
   Flex Safety
================================= */
.calendar-module,
.access-module {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}
.cal-scroll {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

/* =================================
   Utilities
================================= */
.container {
    width: 100%;
    padding: 0 32px;
}

/* =================================
   Responsive
================================= */
@media (max-width: 1100px) {
    .home-sections {
        gap: 28px;
    }
}

@media (max-width: 980px) {
    .home-sections {
        display: block;
        gap: 0;
    }
    .home-sections .calendar-module,
    .home-sections .access-module {
        flex: none;
        width: 100%;
        max-width: 100%;
        margin: 20px 0px;
    }
}

@media (max-width: 860px) {
    .nav-list a {
        font-size: 14px;
        padding: 0 14px;
    }
    .menu-toggle {
        display: flex;
        margin-left: 10px;
        margin-right: auto;
        z-index: 2;
    }
    .desktop-only {
        display: none !important;
    }
    .header-inner {
        position: relative;
        height: 60px;
        padding-left: 0;
        padding-right: 0;
    }
    h1 {
        font-size: 28px;
        padding: 0 18px;
    }
    .header-inner .logo {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        margin: 0;
        padding: 12px 0;
        width: 130px;
    }
    .home-calendar-wrapper {
        padding: 34px 22px 46px;
    }
    main {
        padding: 12px;
    }

    /* Ajustements du menu utilisateur en mobile */
    .mobile-login .user-info {
        padding: 14px 16px;
        font-size: 15px;
    }

    .mobile-login .dropdown-item {
        padding: 12px 18px;
        font-size: 14px;
    }
}

@media (max-width: 760px) {
    .access-switch-group,
    .rules-switch-group {
        flex-wrap: wrap;
    }
    .access-switch,
    .rules-switch {
        flex: 1 1 calc(50% - 7px);
        min-width: 140px;
    }
}

@media (max-width: 640px) {
    .access-plan {
        aspect-ratio: 16 / 11;
    }
}

@media (max-width: 560px) {
    .home-calendar-wrapper {
        padding: 28px 18px 40px;
    }
    .nav-list a {
        font-size: 13px;
        padding: 0 12px;
    }
    .access-switch,
    .rules-switch {
        font-size: 13px;
        padding: 10px 16px;
    }
}

@media (max-width: 520px) {
    .access-switch-group,
    .rules-switch-group {
        flex-wrap: wrap;
    }
    .access-switch,
    .rules-switch {
        flex: 1 1 calc(50% - 10px);
    }
    .access-plan {
        aspect-ratio: 4 / 3;
    }
}

@media (max-width: 480px) {
    .access-module {
        padding: 22px 18px 32px;
    }
    .mobile-panel {
        width: 260px;
        padding: 50px 12px 75px;
    }
}

@media (max-width: 430px) {
    .access-switch,
    .rules-switch {
        flex: 1 1 100%;
        min-width: 0;
    }
    .access-plan {
        aspect-ratio: 3 / 2;
    }

    /* Ajustements finaux pour mobile très petit */
    .mobile-login .user-info {
        padding: 12px 14px;
        font-size: 14px;
    }

    .mobile-login .dropdown-item {
        padding: 10px 16px;
        font-size: 13px;
    }
}

/* Ajustements spécifiques pour le menu utilisateur en desktop */
@media (min-width: 861px) {
    .user-toggle {
        margin: 12px 0;
    }
}

/* =================================
   User Name in Desktop Menu
================================= */
.user-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 40px;
}

.user-name {
    font-weight: 500;
    font-size: 14px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Ajustement pour le survol */
.user-toggle:hover {
    background-color: rgba(255, 255, 255, 0.18);
}

/* Responsive pour les écrans moyens */
@media (max-width: 1000px) {
    .user-name {
        max-width: 100px;
        font-size: 13px;
    }
}

/* Cacher le nom sur les très petits écrans desktop */
@media (max-width: 900px) {
    .user-name {
        display: none;
    }
    .user-toggle {
        padding: 8px;
    }
}