/* Variables de couleurs Material 3 */
:root {
    --m3-primary: #6750a4;
    --m3-on-primary: #ffffff;
    --m3-primary-container: #eaddff;
    --m3-on-primary-container: #21005d;
    --m3-surface: #fdfbff;
    --m3-surface-container: #f3f3fa;
    --m3-outline: #79747e;
    --m3-on-surface: #1c1b1f;
    --m3-on-surface-variant: #49454f;
    --m3-surface-variant: #e1e2ec;
    --m3-secondary-container: #e8def8;
    --m3-on-secondary-container: #1d192b;
    
    /* Couleurs Planning (Plus vives pour mobile) */
    --color-telework: #bbdefb; /* Bleu plus vif */
    --color-telework-text: #0d47a1;
    --color-shift-matin: #c8e6c9; /* Vert plus vif */
    --color-shift-apres-midi: #ffe0b2; /* Orange plus vif */
    --color-shift-soir: #e1bee7; /* Violet plus vif */
    --color-role-comptoir: #fce4ec; /* Rose */
    --color-leave-wish: #d81b60; /* Rose pour souhaits de congés */
    --color-event-pulse-blue: #2196f3;
    --color-event-pulse-violet: #6750a4;
}

/* Thème sombre Material 3 */
.dark {
    --m3-primary: #d0bcff;
    --m3-on-primary: #381e72;
    --m3-primary-container: #4f378b;
    --m3-on-primary-container: #eaddff;
    --m3-surface: #1c1b1f;
    --m3-surface-container: #2b2930;
    --m3-outline: #938f99;
    --m3-on-surface: #e6e1e5;
    --m3-on-surface-variant: #cac4d0;
    --m3-surface-variant: #49454f;
    --m3-secondary-container: #4f378b;
    --m3-on-secondary-container: #eaddff;

    background-color: #1c1b1f;
    color: #e6e1e5;

    /* Couleurs Planning Sombre */
    --color-telework: #0d47a1;
    --color-telework-text: #e3f2fd;
    --color-shift-matin: #1b5e20;
    --color-shift-apres-midi: #e65100;
    --color-shift-soir: #4a148c;
    --color-role-comptoir: #880e4f;
}

body {
    font-family: 'Inter', sans-serif;
    -webkit-font-smoothing: antialiased;
}

.font-mono {
    font-family: 'JetBrains Mono', monospace;
}

/* Transitions globales pour le changement de thème */
* {
    transition-property: background-color, border-color, color, fill, stroke;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 200ms;
}

/* Scrollbars personnalisées */
.custom-scrollbar::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.dark .custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Animations Modales */
#modalOverlay {
    transition: opacity 0.2s ease-out;
}

#modalOverlay.hidden {
    display: none;
    opacity: 0;
}

/* Responsive Essentials */
@media (max-width: 768px) {
    body {
        overflow: hidden; /* Main container handles scrolling */
    }
    
    .h-screen {
        height: 100vh;
        height: 100dvh;
    }

    /* Full-screen Modals on Mobile */
    #modalOverlay > div {
        max-width: 100% !important;
        height: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
        margin: 0 !important;
        padding: 1.5rem !important;
        overflow-y: auto !important;
    }

    /* Force vertical layouts in wide modals */
    #userEditModal .flex-col.md\:flex-row {
        flex-direction: column !important;
    }

    #userEditModal .md\:block.w-px {
        display: none !important;
    }

    /* Planning Horizontal Snap on Mobile */
    .mobile-snap-container {
        display: flex !important;
        overflow-x: auto !important;
        scroll-snap-type: x mandatory !important;
        -webkit-overflow-scrolling: touch;
        gap: 0 !important;
        padding: 0 !important;
        grid-template-columns: none !important; /* Override standard grid */
    }

    .mobile-snap-container > div {
        flex: 0 0 100% !important; /* Full width cards */
        scroll-snap-align: start !important;
        height: 100% !important;
        overflow-y: auto;
    }

    /* Adjust badges for mobile */
    .badge-wrapper {
        min-height: 50px;
    }

    /* Bottom Nav Safety */
    .pb-safe {
        padding-bottom: env(safe-area-inset-bottom);
    }

    /* Override for mobile lunch list */
    #mainContainer:has(.flex-1.space-y-4.pb-6) {
        overflow-y: auto !important;
    }

    /* Polish for mobile lunch list */
    .mobile-lunch-group-header {
        position: sticky;
        top: 0;
        z-index: 10;
        background-color: inherit;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }
}

/* Scroll Snap for mobile planning */
.snap-center {
    scroll-snap-align: center;
}

/* Animation for Mobile Menu */
#mobileMenuContent {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#mobileMenu.hidden #mobileMenuContent {
    transform: translateX(100%);
}

#mobileMenu:not(.hidden) #mobileMenuContent {
    transform: translateX(0);
}

/* Styles spécifiques aux badges */
.badge-present {
    background-color: #c8e6c9; /* Vivid Green */
    color: #1b5e20;
}

.badge-comptoir {
    background-color: var(--color-role-comptoir);
    color: #d81b60;
    border: 1px solid rgba(216, 27, 96, 0.2);
}

.badge-afternoon {
    background-color: var(--color-shift-apres-midi);
    color: #e65100;
    border: 1px solid rgba(230, 81, 0, 0.2);
}

/* Groupement Télétravail */
.telework-group {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border: 1px dashed #1565c0;
}

/* Timeline Lunch */
.timeline-row {
    display: grid;
    grid-template-columns: 180px 1fr;
    min-height: 60px;
}

.lunch-block {
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}

.lunch-block:hover {
    transform: scale(1.02);
}

/* Blinking dot animation */
@keyframes blink {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
    100% { opacity: 1; transform: scale(1); }
}

.blink-dot {
    animation: blink 1.5s infinite ease-in-out;
}

/* Pulse animation for validation button */
@keyframes pulse-orange {
    0% { box-shadow: 0 0 0 0 rgba(255, 165, 0, 0.7); border-color: rgba(255, 140, 0, 1); }
    70% { box-shadow: 0 0 0 10px rgba(255, 165, 0, 0); border-color: rgba(255, 140, 0, 0.5); }
    100% { box-shadow: 0 0 0 0 rgba(255, 165, 0, 0); border-color: rgba(255, 140, 0, 1); }
}

.btn-pulse-orange {
    animation: pulse-orange 2s infinite;
    border: 2px solid darkorange;
}

@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); background-color: rgba(239, 68, 68, 1); }
    70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); background-color: rgba(239, 68, 68, 0.8); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); background-color: rgba(239, 68, 68, 1); }
}

.pulse-red {
    animation: pulse-red 2s infinite;
}

/* Event Pulse Animation */
@keyframes pulse-event-blue {
    0% { box-shadow: 0 0 0 0 rgba(33, 150, 243, 0.4); border-color: rgba(33, 150, 243, 1); }
    70% { box-shadow: 0 0 0 10px rgba(33, 150, 243, 0); border-color: rgba(33, 150, 243, 0.5); }
    100% { box-shadow: 0 0 0 0 rgba(33, 150, 243, 0); border-color: rgba(33, 150, 243, 1); }
}
@keyframes pulse-event-violet {
    0% { box-shadow: 0 0 0 0 rgba(103, 80, 164, 0.4); border-color: rgba(103, 80, 164, 1); }
    70% { box-shadow: 0 0 0 10px rgba(103, 80, 164, 0); border-color: rgba(103, 80, 164, 0.5); }
    100% { box-shadow: 0 0 0 0 rgba(103, 80, 164, 0); border-color: rgba(103, 80, 164, 1); }
}

.pulse-event-blue {
    animation: pulse-event-blue 2s infinite;
    border-width: 2px !important;
}
.pulse-event-violet {
    animation: pulse-event-violet 2s infinite;
    border-width: 2px !important;
}

.event-dot-pulse-blue {
    width: 8px;
    height: 8px;
    background-color: var(--color-event-pulse-blue);
    border-radius: 50%;
    display: inline-block;
    animation: blink 1s infinite ease-in-out;
}
.event-dot-pulse-violet {
    width: 8px;
    height: 8px;
    background-color: var(--color-event-pulse-violet);
    border-radius: 50%;
    display: inline-block;
    animation: blink 1s infinite ease-in-out;
}

/* Intervention Gradient */
.badge-intervention {
    background-image: linear-gradient(to right, #ed6ea0 0%, #ec8c69 100%) !important;
    color: white !important;
    border: 1px solid #c2185b !important;
}

/* Leave Wish Style */
.badge-leave-wish {
    background-color: #fff0f5 !important;
    border: 1px solid var(--color-leave-wish) !important;
    color: var(--color-leave-wish) !important;
}

.badge-evening-telework {
    background-color: rgba(26, 35, 126, 0.7) !important;
    border-color: #1a237e !important;
    color: white !important;
}

/* Tooltip container */
.has-tooltip {
    position: relative;
}

.tooltip {
    visibility: hidden;
    width: 160px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 8px;
    padding: 8px;
    position: absolute;
    z-index: 100;
    bottom: 125%;
    left: 50%;
    margin-left: -80px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 10px;
    pointer-events: none;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.dark .tooltip {
    background-color: #49454f;
    color: #e6e1e5;
}

.tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}

.dark .tooltip::after {
    border-top-color: #49454f;
}

.has-tooltip:hover .tooltip {
    visibility: visible;
    opacity: 1;
}

/* Matrix Monthly View */
.matrix-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.matrix-header-row {
    display: grid;
    grid-template-columns: 200px repeat(var(--col-count, 22), 1fr);
    background: #f3f3fa;
    position: sticky;
    top: 0;
    z-index: 20;
    border-bottom: 2px solid #79747e/20;
}

.dark .matrix-header-row {
    background: #2b2930;
    border-bottom-color: rgba(255, 255, 255, 0.2);
}

.matrix-row {
    display: grid;
    grid-template-columns: 200px repeat(var(--col-count, 22), 1fr);
    border-bottom: 1px solid rgba(121, 116, 126, 0.1);
}

.matrix-tech-cell {
    padding: 8px 12px;
    background: white;
    border-right: 1px solid rgba(121, 116, 126, 0.1);
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: sticky;
    left: 0;
    z-index: 10;
}

.dark .matrix-tech-cell {
    background: #1c1b1f;
    border-right-color: rgba(255, 255, 255, 0.1);
}

.matrix-day-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    min-height: 40px;
    transition: all 0.2s;
    cursor: pointer;
    border-right: 1px solid rgba(121, 116, 126, 0.05);
}

.matrix-day-cell:hover {
    background-color: rgba(103, 80, 164, 0.05);
}

.dark .matrix-day-cell:hover {
    background-color: rgba(208, 188, 255, 0.1);
}

.matrix-status-icon {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.matrix-site-divider {
    grid-column: 1 / -1;
    background: rgba(103, 80, 164, 0.05);
    padding: 4px 12px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #6750a4;
    border-bottom: 1px solid rgba(103, 80, 164, 0.1);
}

.dark .matrix-site-divider {
    background: rgba(208, 188, 255, 0.05);
    color: #d0bcff;
    border-bottom-color: rgba(208, 188, 255, 0.1);
}

.week-divider {
    border-right: 2px solid rgba(121, 116, 126, 0.2) !important;
}

.matrix-day-header {
    padding: 10px 4px;
    text-align: center;
    font-size: 10px;
    font-weight: bold;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-right: 1px solid rgba(121, 116, 126, 0.1);
}

.matrix-day-header.today {
    background-color: #6750a4 !important;
    color: white !important;
    border-radius: 8px 8px 0 0;
}

.holiday-cell {
    background-color: rgba(121, 116, 126, 0.1) !important;
    background-image: repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(121, 116, 126, 0.05) 10px, rgba(121, 116, 126, 0.05) 20px) !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
}

.dark .holiday-cell {
    background-color: rgba(255, 255, 255, 0.05) !important;
    background-image: repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(255, 255, 255, 0.02) 10px, rgba(255, 255, 255, 0.02) 20px) !important;
}

.holiday-name {
    font-size: 8px;
    font-weight: 800;
    text-transform: uppercase;
    color: #79747e;
    margin-top: 2px;
    text-align: center;
    line-height: 1;
}

.dark .holiday-name {
    color: #938f99;
}

.dark .matrix-day-header.today {
    background-color: #d0bcff !important;
    color: #381e72 !important;
}

/* Sidebar Toggle */
.sidebar-collapsed {
    display: none !important;
}

.main-expanded {
    grid-column: span 12 / span 12 !important;
}

.rotate-180 {
    transform: rotate(180deg);
}

/* Settings Refonte Styles */
.settings-nav-btn {
    color: var(--m3-on-surface-variant);
    border: 1px solid transparent;
}

.settings-nav-btn:hover {
    background-color: rgba(103, 80, 164, 0.08);
}

.dark .settings-nav-btn:hover {
    background-color: rgba(208, 188, 255, 0.08);
}

.settings-nav-btn.active {
    background-color: var(--m3-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(103, 80, 164, 0.2);
}

.dark .settings-nav-btn.active {
    background-color: var(--m3-primary);
    color: var(--m3-on-primary);
}

.settings-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.settings-card:hover {
    border-color: var(--m3-primary);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.05);
    transform: translateY(-2px);
}

.dark .settings-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.action-btn-discrete {
    opacity: 0.6;
    transition: all 0.2s ease;
}

.action-btn-discrete:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Modern Search Bar Styling */
.search-container-modern {
    position: relative;
    flex: 1;
}

.search-input-modern {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    border-radius: 1.25rem;
    border: 1px solid rgba(121, 116, 126, 0.2);
    background-color: #f3f3fa;
    outline: none;
    transition: all 0.2s ease;
}

.dark .search-input-modern {
    background-color: #1c1b1f;
    border-color: rgba(255, 255, 255, 0.1);
}

.search-input-modern:focus {
    border-color: var(--m3-primary);
    background-color: white;
    box-shadow: 0 0 0 4px rgba(103, 80, 164, 0.1);
}

.dark .search-input-modern:focus {
    background-color: #2b2930;
}

/* Password Strength & Criteria */
#reg-strength-bar, #comp-strength-bar {
    border-radius: 9999px;
    height: 100%;
}

[id$="-crit-length"], [id$="-crit-upper"], [id$="-crit-lower"], [id$="-crit-number"], [id$="-crit-special"] {
    transition: all 0.3s ease;
}

[id$="-crit-length"].text-green-600 i,
[id$="-crit-upper"].text-green-600 i,
[id$="-crit-lower"].text-green-600 i,
[id$="-crit-number"].text-green-600 i,
[id$="-crit-special"].text-green-600 i {
    transform: scale(1.2);
}

/* Weather Animations */
.weather-lottie {
    display: inline-block;
    vertical-align: middle;
}

.weather-lottie-dash {
    display: block;
    width: 48px;
    height: 48px;
}

/* Pulse for Dashboard weather today */
.weather-today-pulse {
    animation: weather-pulse 2s infinite ease-in-out;
}

@keyframes weather-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* School Holidays */
.school-holiday-banner {
    position: absolute;
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: fit-content;
    height: 3px;
    display: flex;
    gap: 2px;
    z-index: 5;
}

.zone-a-bar { background-color: #2196f3; } /* Blue */
.zone-b-bar { background-color: #4caf50; } /* Green */
.zone-c-bar { background-color: #ff9800; } /* Orange */

.school-holiday-banner .zone-a-bar,
.school-holiday-banner .zone-b-bar,
.school-holiday-banner .zone-c-bar {
    width: 12px;
    height: 3px;
    border-radius: 9999px;
}

.dark .zone-a-bar { background-color: #64b5f6; }
.dark .zone-b-bar { background-color: #81c784; }
.dark .zone-c-bar { background-color: #ffb74d; }

.matrix-day-header {
    position: relative;
}

.school-holiday-legend .zone-a-bar,
.school-holiday-legend .zone-b-bar,
.school-holiday-legend .zone-c-bar {
    width: 10px;
    height: 10px;
}

#dayPartContextMenu {
    animation: menu-pop 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes menu-pop {
    0% { transform: scale(0.9); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* --- GRIDSTACK CUSTOMIZATION --- */
.grid-stack-item-content {
    background: transparent !important;
    border: none !important;
}

.gs-is-editing .grid-stack-item-content {
    cursor: move;
}

.gs-is-editing .grid-stack-item::before {
    content: '';
    position: absolute;
    inset: 4px;
    border: 2px dashed #6750a450;
    border-radius: 36px;
    z-index: 0;
    pointer-events: none;
}

.dark .gs-is-editing .grid-stack-item::before {
    border-color: #d0bcff50;
}

.grid-stack-placeholder > .placeholder-content {
    background: rgba(103, 80, 164, 0.05) !important;
    border: 2px dashed #6750a4 !important;
    border-radius: 32px !important;
}

.dark .grid-stack-placeholder > .placeholder-content {
    background: rgba(208, 188, 255, 0.05) !important;
    border-color: #d0bcff !important;
}

.ui-resizable-handle {
    filter: invert(1);
    opacity: 0 !important;
    transition: opacity 0.2s;
}

.gs-is-editing .ui-resizable-handle {
    opacity: 0.5 !important;
}

.widget-config-btn, .widget-remove-btn {
    opacity: 0;
    transition: opacity 0.2s;
}

.gs-is-editing .widget-config-btn,
.gs-is-editing .widget-remove-btn,
.widget-card:hover .widget-config-btn,
.widget-card:hover .widget-remove-btn {
    opacity: 1;
}

.widget-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

#dashboardSidebar {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.widget-remove-btn {
    display: none;
}

.gs-is-editing .widget-remove-btn {
    display: flex;
}

/* Modal configuration widget */
#widgetConfigModal {
    z-index: 1000;
}

