* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 30px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 3px solid #667eea;
    position: relative;
}

/* Onglets de service */
.service-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

.service-tab {
    padding: 12px 24px;
    background: #f5f5f5;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    color: #666;
    transition: all 0.3s ease;
    border-radius: 8px 8px 0 0;
}

.service-tab:hover {
    background: #e8e8e8;
    color: #333;
}

.service-tab.active {
    background: white;
    color: #667eea;
    border-bottom-color: #667eea;
    box-shadow: 0 -2px 5px rgba(102, 126, 234, 0.1);
}

.save-indicator {
    position: absolute;
    top: -5px;
    right: 20px;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 1000;
}

.save-indicator.saving {
    background: linear-gradient(135deg, #ffd93d 0%, #ffb75e 100%);
    color: #333;
    opacity: 1;
}

.save-indicator.saved {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    opacity: 1;
}

.save-indicator.error {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    color: white;
    opacity: 1;
}

h1 {
    color: #333;
    font-size: 2.5em;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-secondary {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    color: white;
}

.week-selector {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
    padding: 20px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 15px;
}

.week-display {
    font-size: 1.5em;
    font-weight: bold;
    color: #333;
    min-width: 200px;
    text-align: center;
}

.btn-nav {
    padding: 10px 20px;
    background: white;
    border: 2px solid #667eea;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    color: #667eea;
    transition: all 0.3s ease;
}

.btn-nav:hover {
    background: #667eea;
    color: white;
}

.planning-container {
    margin-bottom: 30px;
    overflow-x: auto;
    background: white;
    border-radius: 10px;
    padding: 10px;
}

/* En-tête avec échelle horaire */
.timeline-header {
    display: grid;
    grid-template-columns: 180px 1fr 120px;
    border-bottom: 3px solid #667eea;
    margin-bottom: 5px;
    align-items: stretch;
}

.day-label-cell {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 10px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px 0 0 0;
    box-sizing: border-box;
}

.timeline-hours {
    display: flex;
    position: relative;
    background: #f5f5f5;
    min-height: 40px;
    overflow: visible;
    box-sizing: border-box;
}

/* Lignes verticales pour chaque quart d'heure */
.timeline-hours::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        linear-gradient(to right, #e0e0e0 1px, transparent 1px);
    background-size: calc(100% / 56) 100%;
    background-position: 0 0;
    pointer-events: none;
    z-index: 1;
}

/* Lignes verticales plus marquées pour chaque heure */
.timeline-hours::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        linear-gradient(to right, #ccc 1px, transparent 1px);
    background-size: calc(100% / 14) 100%;
    background-position: 0 0;
    pointer-events: none;
    z-index: 2;
}

.hour-label {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 9px;
    font-weight: 700;
    color: #444;
    padding: 2px 3px;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 2px;
    line-height: 1.1;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(102, 126, 234, 0.15);
    min-width: 20px;
    text-align: center;
    z-index: 5;
}

.quarter-hour-label {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 7px;
    font-weight: 500;
    color: #888;
    padding: 1px 2px;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 2px;
    line-height: 1;
    z-index: 3;
    pointer-events: none;
}

.total-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 10px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0 8px 0 0;
    box-sizing: border-box;
}

/* Grille de planning */
.planning-grid {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

/* Ligne de jour */
.day-row {
    display: grid;
    grid-template-columns: 180px 1fr 120px;
    border-bottom: 1px solid #e0e0e0;
    align-items: start;
}

/* Cellule de label du jour */
.day-label {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 10px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    font-weight: bold;
    border-left: 5px solid #667eea;
    box-sizing: border-box;
    border-bottom: 2px solid #ccc;
}

.day-name {
    font-size: 0.95em;
    color: #333;
    margin-bottom: 2px;
}

.day-date {
    font-size: 0.75em;
    color: #666;
}

/* Wrapper des lignes d'employés - utilise CSS Grid pour aligner sur 3 colonnes */
.employees-rows-wrapper {
    display: contents;
}

/* Une ligne complète pour un employé (nom + timeline) - s'étale sur les 3 colonnes */
.employee-full-row {
    display: contents;
}

/* Info employé (bouton + nom) - va dans la 1ère colonne (celle du jour) */
.employee-info {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: rgba(245, 247, 250, 0.5);
    border-left: 5px solid transparent;
    min-height: 28px;
    box-sizing: border-box;
    border-bottom: 1px dashed #e8e8e8;
    grid-column: 1;
}

.add-shift-btn-left {
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    line-height: 1;
    padding: 0;
}

.add-shift-btn-left:hover {
    transform: scale(1.15);
    box-shadow: 0 3px 8px rgba(102, 126, 234, 0.4);
}

.employee-label-left {
    font-size: 0.75em;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 8px;
    white-space: nowrap;
    color: white;
    text-align: center;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Timeline individuelle pour chaque employé - va dans la 2ème colonne */
.employee-timeline {
    position: relative;
    min-height: 28px;
    background: #f9f9f9;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    box-sizing: border-box;
    border-bottom: 1px dashed #e8e8e8;
    grid-column: 2;
}

/* Lignes verticales pour chaque timeline */
.employee-timeline::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        linear-gradient(to right, #ddd 1px, transparent 1px);
    background-size: calc(100% / 14) 100%;
    background-position: 0 0;
    pointer-events: none;
    z-index: 1;
}

.employee-timeline:hover {
    background-color: rgba(102, 126, 234, 0.05);
}

/* Shift positionné sur la timeline */
.shift {
    position: absolute;
    top: 3px;
    bottom: 3px;
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    padding: 3px 6px;
    border-radius: 6px;
    cursor: grab;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    overflow: hidden;
    font-size: 0.75em;
    font-weight: 600;
    border: 2px solid rgba(255, 255, 255, 0.4);
    z-index: 10;
    box-sizing: border-box;
}

.shift:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
    z-index: 15;
    border-color: rgba(255, 255, 255, 0.6);
}

.shift:active {
    cursor: grabbing;
}

.shift.dragging {
    opacity: 0.6;
    cursor: grabbing;
    z-index: 100;
}

.shift-content {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.85em;
    position: relative;
    z-index: 3;
}

.shift-time {
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.shift-duration {
    font-size: 0.75em;
    opacity: 0.9;
    background: rgba(0, 0, 0, 0.15);
    padding: 2px 6px;
    border-radius: 8px;
}

.shift-note {
    font-size: 0.7em;
    margin-left: 3px;
    opacity: 0.85;
    font-style: italic;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Zone de pause dans le créneau */
.shift-break {
    position: absolute;
    top: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        45deg,
        rgba(150, 150, 150, 0.7),
        rgba(150, 150, 150, 0.7) 4px,
        rgba(200, 200, 200, 0.7) 4px,
        rgba(200, 200, 200, 0.7) 8px
    );
    border-left: 1px solid rgba(100, 100, 100, 0.5);
    border-right: 1px solid rgba(100, 100, 100, 0.5);
    pointer-events: none;
    z-index: 2;
}

/* Total de la journée */
.day-total {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    background: linear-gradient(135deg, #f5f7fa 0%, #e0e7ee 100%);
    font-weight: bold;
    color: #667eea;
    font-size: 1.1em;
    border-left: 2px solid #ddd;
    box-sizing: border-box;
}

/* Styles pour les jours fériés */
.holiday-row {
    background-color: #ffebee !important;
}

.holiday-row .day-label,
.holiday-label {
    background: linear-gradient(135deg, #ffcdd2 0%, #ef9a9a 100%) !important;
    border-left: 5px solid #d32f2f !important;
}

.holiday-row .employee-full-row {
    background-color: #ffebee !important;
}

.holiday-row .employee-info {
    background-color: #ffebee !important;
}

.holiday-row .employee-timeline {
    background-color: #ffebee !important;
}

.holiday-row .day-total {
    background: linear-gradient(135deg, #ffcdd2 0%, #ef9a9a 100%) !important;
    color: #c62828 !important;
    border-left: 2px solid #d32f2f !important;
}

/* Styles pour les vacances scolaires (zone A) */
.school-holiday-row {
    background-color: #fff3e0 !important;
}

.school-holiday-row .day-label,
.school-holiday-label {
    background: linear-gradient(135deg, #ffe0b2 0%, #ffcc80 100%) !important;
    border-left: 5px solid #f57c00 !important;
}

.school-holiday-row .employee-full-row {
    background-color: #fff3e0 !important;
}

.school-holiday-row .employee-info {
    background-color: #fff3e0 !important;
}

.school-holiday-row .employee-timeline {
    background-color: #fff3e0 !important;
}

.school-holiday-row .day-total {
    background: linear-gradient(135deg, #ffe0b2 0%, #ffcc80 100%) !important;
    color: #e65100 !important;
    border-left: 2px solid #f57c00 !important;
}

.day-total:hover {
    background: linear-gradient(135deg, #e8f0ff 0%, #d5e3f5 100%);
}

.stats-panel {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 20px;
    border-radius: 15px;
}

.stats-panel h3 {
    color: #333;
    margin-bottom: 15px;
}

#statsContent {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.stat-card {
    background: white;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.stat-label {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.5em;
    font-weight: bold;
    color: #667eea;
}

/* Modals */
.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;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    position: relative;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
    transition: color 0.3s;
}

.close:hover {
    color: #000;
}

.modal-content h2 {
    color: #333;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.form-actions {
    display: flex;
    gap: 10px;
}

.form-actions button {
    flex: 1;
}


/* Responsive */
@media (max-width: 1200px) {
    .timeline-header {
        grid-template-columns: 140px 1fr 100px;
    }
    
    .day-row {
        grid-template-columns: 140px 1fr 100px;
    }
    
    .hour-label {
        font-size: 0.7em;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    h1 {
        font-size: 1.8em;
    }
    
    .header-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .header-actions button {
        width: 100%;
    }
    
    .timeline-header {
        grid-template-columns: 100px 1fr 70px;
    }
    
    .day-row {
        grid-template-columns: 100px 1fr 70px;
    }
    
    .employee-label-left {
        font-size: 0.65em;
        padding: 2px 4px;
    }
    
    .add-shift-btn-left {
        width: 18px;
        height: 18px;
        font-size: 12px;
    }
    
    .shift {
        font-size: 0.7em;
        padding: 3px 5px;
    }
}

/* Animation pour les éléments ajoutés */
.fade-in {
    animation: fadeInElement 0.5s ease;
}

@keyframes fadeInElement {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ========================================
   STYLES D'IMPRESSION - A4 PAYSAGE
   ======================================== */
@page {
    size: A4 landscape;
    margin: 0.3cm;
}

@media print {
    /* Supprimer l'arrière-plan du body */
    body {
        background: white;
        padding: 0;
        margin: 0;
    }
    
    /* Container ultra compact */
    .container {
        max-width: 100%;
        margin: 0;
        padding: 0;
        box-shadow: none;
        background: white;
    }
    
    /* Cacher les éléments non nécessaires à l'impression */
    header .header-actions,
    .week-selector button,
    .stats-panel,
    .modal,
    .day-total,
    .total-header,
    .add-shift-btn-left,
    .save-indicator,
    #saveIndicator {
        display: none !important;
    }
    /* Ne pas imprimer les onglets de service et la barre de semaine */
    .service-tabs,
    .week-selector {
        display: none !important;
    }
    
    /* Header minimaliste */
    header {
        display: none !important;
    }
    
    /* Week selector compact */
    .week-selector {
        background: none;
        padding: 0;
        margin: 0;
        justify-content: center;
    }
    
    .week-display {
        font-size: 11px;
        color: #333;
        font-weight: bold;
        line-height: 1.2;
        margin-bottom: 3px;
    }
    
    /* Planning container compact */
    .planning-container {
        page-break-inside: avoid;
        page-break-after: avoid;
        page-break-before: avoid;
        overflow: visible;
        padding: 0;
        margin: 0;
        width: 100% !important;
    }
    
    /* Timeline header compact */
    .timeline-header {
        background: white;
        border-bottom: 2px solid #333;
        grid-template-columns: 120px 1fr;
        min-height: auto;
    }
    
    .day-label-cell {
        background: #e0e0e0 !important;
        color: #333 !important;
        border: 1px solid #333;
        padding: 3px;
        font-size: 9px;
        font-weight: bold;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
        grid-column: 1;
        line-height: 1.2;
    }
    
    .timeline-hours {
        background: white !important;
        border: 1px solid #333;
        min-height: 18px;
        grid-column: 2;
    }
    
    .timeline-hours::before {
        background-image: linear-gradient(to right, #ddd 1px, transparent 1px) !important;
        background-size: calc(100% / 56) 100% !important;
    }
    
    .timeline-hours::after {
        background-image: linear-gradient(to right, #999 1px, transparent 1px) !important;
        background-size: calc(100% / 14) 100% !important;
    }
    
    .hour-label {
        color: #333;
        font-weight: bold;
        font-size: 8px;
        padding: 1px 2px;
        min-width: 16px;
        background: transparent;
        border: none;
        line-height: 1.2;
    }
    
    /* Lignes de jours ultra compactes */
    .day-row {
        border-bottom: 1px solid #ccc;
        page-break-inside: avoid;
        grid-template-columns: 120px 1fr;
        min-height: auto;
    }
    
    .day-label {
        background: #f5f5f5 !important;
        border: 1px solid #999;
        padding: 2px 3px;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
        grid-column: 1;
        border-left: 2px solid #667eea;
    }
    
    .day-name {
        color: #333;
        font-size: 9px;
        font-weight: bold;
        margin: 0 0 1px 0;
        line-height: 1.2;
    }
    
    .day-date {
        color: #666;
        font-size: 7px;
        line-height: 1.2;
    }
    
    /* Wrapper des employés pour l'impression */
    .employees-rows-wrapper {
        display: contents !important;
    }
    
    .employee-full-row {
        display: contents !important;
    }
    
    /* Info employé visible à l'impression */
    .employee-info {
        display: flex !important;
        align-items: center;
        padding: 1px 2px;
        background: rgba(245, 247, 250, 0.3) !important;
        border-bottom: 0.5px dashed #ddd;
        min-height: 22px;
        max-height: 22px;
        grid-column: 1;
        gap: 2px;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
    
    .employee-label-left {
        font-size: 8px !important;
        padding: 2px 4px !important;
        border-radius: 3px;
        flex: 1;
        print-color-adjust: exact !important;
        -webkit-print-color-adjust: exact !important;
        border: 0.5px solid rgba(0, 0, 0, 0.2);
        line-height: 1.2;
    }
    
    /* Timelines compactes */
    .employee-timeline {
        background: white !important;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
        min-height: 22px;
        max-height: 22px;
        border-bottom: 0.5px dashed #ddd;
        grid-column: 2 !important;
    }
    
    .employee-timeline::before {
        background-image: linear-gradient(to right, #ddd 1px, transparent 1px) !important;
        display: block !important;
    }
    
    /* Shifts ultra compacts */
    .shift {
        font-size: 7.5px;
        padding: 1px 3px;
        min-height: auto;
        top: 1px;
        bottom: 1px;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
        border: 0.5px solid rgba(0, 0, 0, 0.3);
        border-radius: 2px;
    }
    
    .shift-content {
        color: white;
        gap: 2px;
        font-size: 1em;
        line-height: 1.2;
    }
    
    .shift-time {
        font-size: 1em;
        font-weight: bold;
    }
    
    .shift-duration {
        font-size: 0.85em;
        padding: 0 2px;
    }
    
    .shift-note {
        display: none;
    }
    
    /* Zone de pause à l'impression */
    .shift-break {
        background: repeating-linear-gradient(
            45deg,
            rgba(100, 100, 100, 0.8) !important,
            rgba(100, 100, 100, 0.8) 2px !important,
            rgba(180, 180, 180, 0.8) 2px !important,
            rgba(180, 180, 180, 0.8) 4px !important
        ) !important;
        print-color-adjust: exact !important;
        -webkit-print-color-adjust: exact !important;
    }
    
    
    /* Footer (désactivé à l'impression pour éviter une 2e page) */
    .planning-container::after {
        content: none !important;
        display: none !important;
    }
    
    /* Réduire les espacements */
    .planning-container {
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
    }
    
    .planning-grid {
        gap: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        page-break-inside: avoid;
        page-break-after: avoid;
    }
    
    .timeline-header {
        margin: 0 !important;
    }
    
    /* Forcer l'impression des couleurs */
    * {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
        color-adjust: exact;
    }
    
    /* Réduire tous les espaces inutiles */
    .planning-grid {
        gap: 0;
    }
}

