/* ============================================================
   Custom Calendar — Style fidèle aux captures d'écran
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700&family=DM+Sans:wght@400;500;600&display=swap');

:root {
    --cc-bg:          #f5f0ea;   /* fond crème */
    --cc-bg-weekend:  #ede8e2;   /* week-end légèrement plus sombre */
    --cc-bg-empty:    #efebe5;
    --cc-border:      #ddd8d0;
    --cc-text:        #2c2c2c;
    --cc-text-muted:  #8a8580;
    --cc-head-bg:     #f0ebe4;
    --cc-today-bg:    #1c1c1c;
    --cc-today-color: #fff;
    --cc-radius:      12px;
}

/* ---- Wrapper ---- */
.custom-calendar-wrapper {
    max-width: 960px;
    margin: 0 auto;
    font-family: 'DM Sans', sans-serif;
    color: var(--cc-text);
    position: relative;
    background: transparent;
}

/* ---- Navigation (titre + flèches) ---- */
.cc-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.cc-month-label {
    font-family: 'Playfair Display', serif;
    font-size: 2em;
    font-weight: 700;
    color: var(--cc-text);
    flex: 1;
    letter-spacing: -0.01em;
}

.cc-prev,
.cc-next {
    background: none;
    border: 1.5px solid var(--cc-border);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em;
    cursor: pointer;
    color: var(--cc-text-muted);
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
    padding: 0;
}

.cc-prev:hover,
.cc-next:hover {
    background: var(--cc-border);
    color: var(--cc-text);
}

.cc-prev:disabled,
.cc-next:disabled {
    opacity: 0.3;
    cursor: default;
}

/* ---- Légende (en haut à droite) ---- */
.cc-legend {
    display: flex;
    align-items: center;
    gap: 6px 18px;
    flex-wrap: wrap;
    font-size: 0.82em;
    color: var(--cc-text-muted);
}

/* On positionne la légende à droite dans la nav */
.cc-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    flex-wrap: wrap;
    gap: 8px;
}

.cc-nav-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cc-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82em;
    color: var(--cc-text-muted);
    font-weight: 500;
}

.cc-legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ---- Grille ---- */
.cc-grid {
    border: 1px solid var(--cc-border);
    border-radius: var(--cc-radius);
    overflow: hidden;
    background: var(--cc-bg);
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

/* display:contents rend les wrappers transparents : toutes les cellules
   (entêtes + jours) partagent la même grille → alignement garanti */
.cc-grid-head,
.cc-grid-body {
    display: contents;
}

.cc-grid-head-cell {
    padding: 12px 10px;
    font-size: 0.72em;
    font-weight: 600;
    color: var(--cc-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--cc-head-bg);
    border-bottom: 1px solid var(--cc-border);
    box-sizing: border-box;
}

.cc-grid-head-cell:not(:last-child) {
    border-right: 1px solid var(--cc-border);
}

/* ---- Cellule jour ---- */
.cc-grid-day {
    min-height: 110px;
    padding: 8px 8px 8px;
    border-right: 1px solid var(--cc-border);
    border-bottom: 1px solid var(--cc-border);
    box-sizing: border-box;
    background: var(--cc-bg);
}

.cc-grid-day:nth-child(7n) {
    border-right: none;
}

.cc-day--empty {
    background: var(--cc-bg-empty);
}

.cc-day--weekend {
    background: var(--cc-bg-weekend);
}

/* Numéro du jour */
.cc-day-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    font-size: 0.85em;
    font-weight: 500;
    color: var(--cc-text);
    border-radius: 50%;
    margin-bottom: 4px;
}

/* Jours du mois suivant/précédent (cellules vides avec numéro) */
.cc-day--other-month .cc-day-num {
    color: var(--cc-text-muted);
    opacity: 0.5;
}

.cc-day--today .cc-day-num {
    background: var(--cc-today-bg);
    color: var(--cc-today-color);
    font-weight: 700;
}

/* ---- Chips événements (style pill avec barre colorée) ---- */
.cc-day-events {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.cc-chip {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 7px 3px 0;
    border-radius: 5px;
    font-size: 0.78em;
    font-weight: 500;
    color: var(--cc-text);
    background: rgba(255,255,255,0.55);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
    border: none;
    min-height: 22px;
}

.cc-chip:hover {
    background: rgba(255,255,255,0.85);
}

.cc-chip:focus {
    outline: 2px solid #1a73e8;
    outline-offset: 1px;
}

/* Barre colorée à gauche du chip */
.cc-chip-bar {
    display: inline-block;
    width: 3px;
    min-width: 3px;
    height: 100%;
    min-height: 18px;
    border-radius: 2px;
    align-self: stretch;
    flex-shrink: 0;
}

.cc-chip-time {
    font-weight: 600;
    font-size: 0.9em;
    color: var(--cc-text-muted);
    flex-shrink: 0;
    letter-spacing: -0.01em;
}

.cc-chip-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

/* ---- Popup événement ---- */
.cc-popup {
    position: fixed;
    z-index: 99999;
    background: #faf8f5;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.18), 0 4px 16px rgba(0,0,0,0.08);
    padding: 28px 28px 24px;
    min-width: 280px;
    max-width: 340px;
    animation: cc-popup-in 0.18s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-family: 'DM Sans', sans-serif;
}

@keyframes cc-popup-in {
    from { opacity: 0; transform: scale(0.92) translateY(6px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.cc-popup-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: #ede9e3;
    border: none;
    font-size: 1em;
    line-height: 1;
    cursor: pointer;
    color: var(--cc-text-muted);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    font-weight: 600;
}

.cc-popup-close:hover {
    background: #ddd9d2;
    color: var(--cc-text);
}

/* Tag type (ex: "COURS · MODULE A1") */
.cc-popup-tag {
    font-size: 0.68em;
    font-weight: 600;
    color: var(--cc-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
}

/* Titre */
.cc-popup-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.45em;
    font-weight: 700;
    color: var(--cc-text);
    line-height: 1.25;
    margin-bottom: 18px;
    padding-right: 28px;
}

.cc-popup-title a {
    color: inherit;
    text-decoration: none;
}
.cc-popup-title a:hover {
    text-decoration: underline;
}

/* Tableau de métadonnées */
.cc-popup-meta {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85em;
    margin-bottom: 6px;
}

.cc-popup-meta tr {
    border-top: 1px solid var(--cc-border);
}

.cc-popup-meta td {
    padding: 9px 0;
    vertical-align: top;
}

.cc-popup-meta td:first-child {
    color: var(--cc-text-muted);
    font-weight: 400;
    width: 45%;
    padding-right: 12px;
}

.cc-popup-meta td:last-child {
    color: var(--cc-text);
    font-weight: 500;
    text-align: right;
}

/* Description */
.cc-popup-desc {
    font-size: 0.82em;
    color: #5f6368;
    margin-top: 10px;
    line-height: 1.5;
    border-top: 1px solid var(--cc-border);
    padding-top: 10px;
    max-height: 100px;
    overflow-y: auto;
}

/* Bouton "Voir le module complet" */
.cc-popup-btn {
    display: inline-block;
    margin-top: 16px;
    padding: 10px 18px;
    border-radius: 50px;
    border: 1.5px solid var(--cc-border);
    background: transparent;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.82em;
    font-weight: 500;
    color: var(--cc-text);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
}

.cc-popup-btn:hover {
    background: var(--cc-border);
}

/* ---- Message vide ---- */
.cc-empty {
    text-align: center;
    padding: 40px 0;
    color: var(--cc-text-muted);
    font-style: italic;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 640px) {
    .cc-month-label {
        font-size: 1.5em;
    }

    .cc-grid-day {
        min-height: 72px;
        padding: 4px 4px 4px;
    }

    .cc-day-num {
        width: 22px;
        height: 22px;
        font-size: 0.75em;
    }

    .cc-chip-time,
    .cc-chip-title {
        font-size: 0;
    }

    .cc-chip {
        padding: 3px 2px;
        border-radius: 4px;
        justify-content: center;
    }

    .cc-chip-bar {
        width: 5px;
        min-width: 5px;
        height: 14px;
        border-radius: 3px;
    }

    .cc-grid-head-cell {
        font-size: 0.6em;
        padding: 8px 2px;
    }

    .cc-popup {
        position: fixed;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        max-width: calc(100vw - 32px);
        min-width: 260px;
    }

    .cc-legend {
        gap: 4px 12px;
    }
}