@media (prefers-color-scheme: light) {
    .calendar-table .day_number {
        background: #cfd6de !important;
    }
}
@media (prefers-color-scheme: light) {
    .calendar-table .day_content {
        background: #cfd6de !important;
    }
}
@media (prefers-color-scheme: light) {
    .calendar-table.calendar-body-table td {
        background: #cfd6de !important;
        color: var(--conges-text) !important;
    }
}
/* Header de planning kinés */
.planning-header {
    display: flex;
    align-items: center;
    gap: 1em;
}

.header-icon {
    width: 32px;
    height: 32px;
    cursor: pointer;
}

.planning-title {
    flex: 1;
    text-align: center;
    margin: 0;
}

.planning-table {
    position: relative;
}

.planning-time-header {
    width: 80px;
    min-width: 60px;
    max-width: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.planning-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 10px 24px;
    border-radius: 6px;
    z-index: 9999;
    display: none;
    min-width: 120px;
    text-align: center;
    font-size: 1.1em;
}
/* Header de planning */
.planning-header {
    display: flex;
    align-items: center;
    gap: 1em;
}

.header-icon {
    width: 32px;
    height: 32px;
    cursor: pointer;
}

.planning-title {
    flex: 1;
    text-align: center;
    margin: 0;
}

.table-container {
    margin-top: 0;
}

.planning-table {
    position: relative;
}
/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f5f5;
    color: #333;
    width: 100vw;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
}

/* Sidebar overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 3500;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: -300px;
    width: 300px;
    height: 100vh;
    background: white;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 3600;
    transition: left 0.3s ease;
    overflow-y: auto;
}

.sidebar.active {
    left: 0;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #1976D2;
    color: white;
}

.sidebar-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.2;
}

.close-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 32px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: transform 0.2s;
}

.close-btn:hover {
    transform: scale(1.1);
}

.sidebar-content {
    padding: 20px;
}

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

.sidebar-content nav li {
    margin-bottom: 10px;
}

.sidebar-content nav a {
    display: block;
    padding: 12px 15px;
    color: #333;
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.2s;
}

.sidebar-content nav a:hover {
    background: #e3f2fd;
    color: #1976D2;
}

@media (prefers-color-scheme: dark) {
    .sidebar {
        background: #2d2d2d;
    }
    
    .sidebar-header {
        background: #1565C0;
        border-bottom-color: #404040;
    }
    
    .sidebar-content nav a {
        color: #e0e0e0;
    }
    
    .sidebar-content nav a:hover {
        background: #1e3a5f;
        color: #64B5F6;
    }
}

.container {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    margin: 0;
}

/* Header with navigation */
header {
    /* width: 45px; */
    /* max-width: 45px; */
    left: 0;
    width: 100vw;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 15px;
    background: white;
    border-radius: 0;
    margin: 0;
    width: 100%; 
    min-width: 100%; 
    max-width: 100%;
    flex-shrink: 0;
    min-height: 50px;
    max-width: 100vw;
    box-sizing: border-box;
}

header button {
    background: #4a5158;
    color: white;
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

header button:hover {
    background: #94979b;
}

header button:active {
    transform: scale(0.95);
}

h1 {
    background: rgba(25, 118, 210, 0.95);
    color: #fff;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 20px;
    text-transform: capitalize;
    margin: 0 10px;
    flex: 1;
    text-align: center;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Table container */
.table-container {
    flex: 1;
    overflow-x: auto;
    overflow-y: auto;
    width: 100%;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-top: 0;
}

.table-responsive {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

table {
    width: auto;
    min-width: 100%;
    border-collapse: collapse;
    table-layout: auto;
    height: 100%;
    border: 2px solid #333;
}

/* Planning table */
table thead th {
    position: sticky;
    top: 0;
    background: #1976D2;
    color: white;
    padding: 10px 3px;
    font-weight: 600;
    font-size: 12px;
    text-align: center;
    border: 2px solid #0D47A1;
    z-index: 10;
    min-width: 45px;
    width: 45px;
    max-width: 45px;
}

table thead th:first-child {
    width: 110px;
    background: #0D47A1;
    z-index: 15;
    left: 0;
}

th.header-icons {
    padding: 1px 1px !important;
    line-height: 1;
}

th.header-icons img {
    height: 3vh;
    max-height: 30px;
    width: auto;
    object-fit: contain;
    margin: 0 10px;
    display: inline-block;
    vertical-align: middle;
}

#menu-hamburger {
    cursor: pointer;
}

table tbody tr {
    border-bottom: 2px solid #666;
    background: #f5f5f5;
}

table tbody tr:hover {
    background: #e8e8e8;
}

table tbody td {
    padding: 15px 3px;
    text-align: center;
    border: 2px solid #666;
    font-size: 11px;
    height: auto;
    vertical-align: middle;
}

.time-cell {
    font-weight: 600;
    color: #555;
    background: #fafafa;
    position: sticky;
    left: 0;
    z-index: 5;
    font-size: 16px;
    line-height: 1.3;
    white-space: nowrap;
    width: 90px;
    min-width: 90px;
    max-width: 90px;
}

.event-cell {
    min-width: 45px;
    width: 45px;
    max-width: 45px;
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.event-cell:hover {
    background: #e3f2fd !important;
}

.event-cell.editing {
    padding: 2px;
}

.event-cell textarea {
    width: 100%;
    height: 100%;
    min-height: 40px;
    border: 2px solid #1976D2;
    border-radius: 4px;
    padding: 4px;
    font-size: 13px;
    font-family: inherit;
    resize: none;
    background: white;
}

.event-cell.has-event {
    background: #bbdefb;
    font-weight: 500;
}

/* Special event colors */
.event-cell.balneo {
    background: #2196F3 !important;
    color: white;
    font-weight: 600;
}

.event-cell.balneo-femme {
    background: #0D47A1 !important;
    color: white;
    font-weight: 600;
}

.event-cell.kine {
    background: #c8e6c9 !important;
    color: #1b5e20;
    font-weight: 600;
}

.event-cell.repos {
    background: #9e9e9e !important;
    color: white;
    font-weight: 600;
}

.event-cell.secretariat {
    background: #1B5E20 !important;
    color: white;
    font-weight: 600;
}

/* Style pour les kinés en repos */
.event-cell.kine-repos {
    opacity: 0.5 !important;
    position: relative;
}

.event-cell.kine-repos::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 5px,
        rgba(255, 255, 255, 0.2) 5px,
        rgba(255, 255, 255, 0.2) 10px
    );
    pointer-events: none;
}

/* Style pour les cellules avec plusieurs kinés */
.event-cell.double-kine {
    padding: 2px !important;
    display: flex;
    flex-direction: column;
    gap: 2px;
    justify-content: center;
    align-items: stretch;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 100%;
    min-height: 100%;
    box-sizing: border-box;
}

.event-cell.double-kine > .kine-item {
    flex: 1 1 0;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.kine-item {
    padding: 2px 3px;
    border-radius: 2px;
    font-size: 10px;
    font-weight: 600;
    text-align: center;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 16px;
    position: relative;
}

.kine-item.kine-repos::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 3px,
        rgba(255, 255, 255, 0.2) 3px,
        rgba(255, 255, 255, 0.2) 6px
    );
    pointer-events: none;
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 14px;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Loading state */
.loading {
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 14px;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    body {
        background: #1a1a1a;
        color: #e0e0e0;
    }

    header {
        background: #2d2d2d;
    }

    h1 {
        background: rgba(21, 101, 192, 0.3);
        color: #fff;
    }

    .table-container {
        background: #2d2d2d;
    }

    table thead th {
        background: #1565C0;
        border-color: #0D47A1;
    }

    table thead th:first-child {
        background: #0D47A1;
    }

    table tbody tr {
        border-color: #404040;
    }

    table tbody tr:hover {
        background: #3a3a3a;
    }

    table tbody td {
        border-color: #404040;
        background: #2d2d2d;
    }

    .time-cell {
        background: #252525;
        color: #b0b0b0;
    }

    .event-cell:hover {
        background: #1e3a5f !important;
    }

    .event-cell.has-event {
        background: #1e3a5f;
    }

    .event-cell textarea {
        background: #3a3a3a;
        color: #e0e0e0;
        border-color: #64B5F6;
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .container {
        padding: 5px;
    }

    h1 {
        font-size: 20px;
    }

    header button {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }

    table {
        font-size: 12px;
    }

    table thead th,
    table tbody td {
        padding: 6px 4px;
    }

    .time-cell {
        width: 90px;
        font-size: 15px;
    }
}

/* Ligne indiquant l'heure courante dans le planning */
.now-line {
    position: absolute;
    height: 2px;
    background: #d32f2f; /* rouge */
    box-shadow: 0 1px 4px rgba(211,47,47,0.6);
    z-index: 2500;
    pointer-events: none;
}

/* (Overrides forcés light supprimés pour suivre la préférence du navigateur) */

/* Effet pulse pour attirer l'attention */
.now-line.pulse {
    animation: nowPulse 1.6s ease-in-out infinite;
}

@keyframes nowPulse {
    0% { box-shadow: 0 1px 4px rgba(211,47,47,0.6); }
    50% { box-shadow: 0 2px 10px rgba(211,47,47,0.85); }
    100% { box-shadow: 0 1px 4px rgba(211,47,47,0.6); }
}

/* Petit label affichant l'heure courante collé à droite de la table */
.now-label {
    position: absolute;
    background: rgba(211,47,47,0.95);
    color: #fff;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    z-index: 2550;
    pointer-events: none;
    transform: translateY(-50%);
    white-space: nowrap;
}

@media (prefers-color-scheme: dark) {
    .now-label { background: rgba(255,127,127,0.95); color: #1b1b1b; }
}

/* Toast affichant le jour lors d'un swipe */
.day-toast {
    position: fixed;
    top: 7vh;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(25, 118, 210, 0.3);
    color: #fff;
    padding: 0.35rem 0.8rem;
    border-radius: 6px;
    font-weight: 600;
    z-index: 3000;
    opacity: 1;
    transition: opacity 260ms ease, transform 260ms ease;
    pointer-events: none;
}

.day-toast.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(-6px);
}

@media (prefers-color-scheme: dark) {
    .day-toast { background: rgba(21, 101, 192, 0.3); color: #fff; }
}

/* Légende en bas de page */
.legend {
    background: white;
    margin-top: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: sticky;
    bottom: 0;
    z-index: 100;
}

.legend-items {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    row-gap: 4px;
    width: 100%;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 8px;
    background: #f5f5f5;
    border-radius: 4px;
    border: 1px solid #ddd;
    justify-content: center;
    min-width: 0;
}

.legend-color {
    width: 25px;
    height: 18px;
    border-radius: 3px;
    border: 1px solid #333;
    flex-shrink: 0;
}

.legend-name {
    font-size: 12px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

@media (prefers-color-scheme: dark) {
    .legend {
        background: #2d2d2d;
    }
    
    .legend h2 {
        color: #64B5F6;
    }
    
    .legend-item {
        background: #1a1a1a;
        border-color: #404040;
    }
    
    .legend-name {
        color: #e0e0e0;
    }
}

/* Mode clair - Inversion de l'icône de menu pour la rendre noire */
@media (prefers-color-scheme: light) {
    .header-icon,
    .menu-hamburger-icon {
        filter: invert(1);
    }
}

/* Desktop enhancements */
@media (min-width: 992px) {
    /* Conteneur centré, espace respirant, moins large */
    .container {
        padding: 12px 16px;
        max-width: 640px;
        margin: 0 auto;
    }

    .table-container {
        max-width: clamp(560px, 50vw, 640px);
        margin: 10px auto;
        border-radius: 10px;
    }

    header {
        padding: 10px 20px;
    }

    h1 {
        font-size: 22px;
        padding: 0.4rem 0.8rem;
    }

    header button {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    /* Colonnes plus larges sur desktop */
    table thead th {
        min-width: 70px;
        width: 70px;
        max-width: 70px;
        font-size: 14px;
        padding: 12px 6px;
    }

    table thead th:first-child {
        width: 140px;
    }

    .time-cell {
        width: 140px;
        min-width: 140px;
        max-width: 140px;
        font-size: 18px;
    }

    table tbody td {
        padding: 18px 6px;
        font-size: 13px;
    }

    .event-cell {
        min-width: 70px;
        width: 70px;
        max-width: 70px;
        font-size: 13px;
    }

    .kine-item {
        font-size: 12px;
        min-height: 20px;
    }
}

@media (min-width: 1400px) {
    .table-container {
        max-width: clamp(600px, 45vw, 700px);
    }

    table thead th {
        min-width: 90px;
        width: 90px;
        max-width: 90px;
        font-size: 15px;
        padding: 14px 8px;
    }

    table thead th:first-child,
    .time-cell {
        width: 160px;
        min-width: 160px;
        max-width: 160px;
    }

    .time-cell {
        font-size: 19px;
    }

    table tbody td {
        padding: 20px 8px;
        font-size: 14px;
    }

    .event-cell {
        min-width: 90px;
        width: 90px;
        max-width: 90px;
        font-size: 14px;
    }

    .kine-item {
        font-size: 13px;
        min-height: 22px;
    }
}