:root {
    --hour-height: 50px;
    --time-col-width: 60px;
    --grid-line-color: rgba(0, 0, 0, 0.06);
    --cal-primary: #7C3AED;
    --cal-bg-hover: #f3f4f6;
    --cal-text-muted: #6b7280;
}

.calendar-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    user-select: none;
    background: white;
    color: #1f2937;
}

/* Header */
.cal-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
}

.cal-nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cal-btn {
    padding: 5px 12px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    background: white;
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.cal-btn:hover {
    background: var(--cal-bg-hover);
}

.cal-btn-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 6px;
    color: var(--cal-text-muted);
}

.cal-btn-icon:hover {
    background: var(--cal-bg-hover);
    color: #111;
}

.cal-date-label {
    font-weight: 600;
    font-size: 1rem;
    min-width: 150px;
}

/* Body & Grid */
.cal-body {
    flex: 1;
    overflow-y: auto;
    display: flex;
    position: relative;
}

.cal-time-col {
    width: var(--time-col-width);
    flex-shrink: 0;
    /* border-right removed, moved to slot */
    background: white;
    z-index: 10;
    position: sticky;
    left: 0;
}

.time-slot {
    height: var(--hour-height);
    position: relative;
    border-right: 1px solid #e5e7eb;
    box-sizing: border-box;
}

.time-label {
    position: absolute;
    top: -8px;
    right: 8px;
    font-size: 0.7rem;
    color: var(--cal-text-muted);
    font-weight: 500;
}

.cal-grid {
    flex: 1;
    display: flex;
    position: relative;
}

.cal-day-col {
    flex: 1;
    border-right: 1px solid #e5e7eb;
    position: relative;
    min-width: 150px;
}

.cal-day-col.today {
    background: rgba(124, 58, 237, 0.02);
}

.grid-hour-line {
    height: var(--hour-height);
    border-bottom: 1px solid var(--grid-line-color);
    box-sizing: border-box;
}

/* Header de colonne (Semaine) */
.day-header {
    height: 60px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 5;
    text-transform: uppercase;
    color: var(--cal-text-muted);
}

.day-header.today {
    color: var(--cal-primary);
}

.day-num {
    font-size: 1.4rem;
    font-weight: 700;
    margin-top: 1px;
}

/* Events */
.cal-event {
    position: absolute;
    left: 4px;
    right: 4px;
    border-radius: 6px;
    padding: 4px 8px;
    border-left: 3px solid transparent;
    cursor: pointer;
    overflow: hidden;
    z-index: 2;
    transition: box-shadow 0.15s, transform 0.1s;
    font-size: 0.8rem;
    background-clip: padding-box;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.cal-event:hover {
    z-index: 15;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.cal-event.selected {
    outline: 2px solid var(--cal-primary);
    z-index: 20;
    box-shadow: 0 6px 16px rgba(124, 58, 237, 0.2);
}

.cal-event.locked {
    cursor: default;
}

.cal-event-title {
    font-weight: 600;
    margin-bottom: 2px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.cal-event-time {
    font-size: 0.7rem;
    opacity: 0.75;
    font-weight: 500;
}

.cal-resize-handle {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 8px;
    cursor: ns-resize;
    background: transparent;
}

.cal-resize-handle:hover {
    background: rgba(0, 0, 0, 0.05);
}

.cal-lock-icon {
    position: absolute;
    bottom: 4px;
    right: 6px;
    font-size: 0.7rem;
    opacity: 0.4;
}

/* Now Line */
.now-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: #ef4444;
    z-index: 5;
    pointer-events: none;
}

.now-label {
    position: absolute;
    left: -54px;
    top: -8px;
    background: #ef4444;
    color: white;
    font-size: 0.65rem;
    padding: 2px 4px;
    border-radius: 4px;
    font-weight: 700;
}

/* Popover & Menus */
.cal-popover-box {
    position: fixed;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    padding: 6px;
    min-width: 220px;
    animation: calFadeIn 0.15s ease-out;
}

@keyframes calFadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cal-menu-item {
    padding: 10px 12px;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 500;
    color: #374151;
}

.cal-menu-item:hover {
    background: var(--cal-bg-hover);
}

.cal-menu-item.danger {
    color: #dc2626;
}

.cal-menu-item .kb {
    font-size: 0.75rem;
    color: var(--cal-text-muted);
    opacity: 0.6;
}

.cal-menu-colors {
    display: flex;
    gap: 10px;
    padding: 10px;
    justify-content: center;
}

.color-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s;
}

.color-dot:hover {
    transform: scale(1.2);
}

.color-dot.active {
    border-color: rgba(0, 0, 0, 0.15);
    box-shadow: 0 0 0 2px white inset;
}

.cal-menu-sep {
    height: 1px;
    background: #f3f4f6;
    margin: 6px 0;
}

.cal-editor {
    padding: 10px;
}

.cal-editor input {
    width: 100%;
    border: 2px solid #f3f4f6;
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.cal-editor input:focus {
    border-color: var(--cal-primary);
}

.cal-btn-primary {
    background: var(--cal-primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    width: 100%;
}

/* Now Label Global (in time col) */
.now-label-global {
    position: absolute;
    right: 2px;
    transform: translateY(-50%);
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    z-index: 20;
    pointer-events: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Ensure time-col can hold absolute children properly */
.cal-time-col {
    position: sticky;
    left: 0;
    z-index: 30 !important;
}