/* ============================================================
   DatePicker custom — styles scopés .dp-*
   Spec : docs/superpowers/specs/2026-04-17-datepicker-custom-design.md
   Aligne sur tokens globaux (--primary, --gray-*, --shadow-*)
   ============================================================ */

/* ---------- Wrapper & input décoratif ---------- */
.dp-wrapper {
    position: relative;
    display: block;
}

.dp-wrapper .dp-display {
    padding-right: 2.4rem; /* place pour l'icône */
    cursor: pointer;
    background: var(--surface);
    font-variant-numeric: tabular-nums;
    caret-color: transparent;
    user-select: none;
}

.dp-wrapper .dp-display:focus-visible {
    outline: none;
    border-color: var(--primary);
    box-shadow: var(--shadow-focus);
}

.dp-icon {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: auto;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    opacity: 0.55;
    transition: opacity var(--dur-fast) ease;
}

.dp-wrapper:hover .dp-icon,
.dp-wrapper:focus-within .dp-icon {
    opacity: 1;
}

/* ---------- Popup ---------- */
.dp-popup {
    position: fixed;
    z-index: 1000;
    background: var(--surface);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: 0.75rem;
    min-width: 280px;
    font-family: inherit;
    color: var(--text-primary);
    animation: dp-open 120ms cubic-bezier(0.2, 0.8, 0.2, 1);
    transform-origin: top left;
}

@keyframes dp-open {
    from { opacity: 0; transform: translateY(-4px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .dp-popup { animation: none; }
}

/* ---------- Raccourcis ---------- */
.dp-shortcuts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    padding-bottom: 0.6rem;
    margin-bottom: 0.6rem;
    border-bottom: 1px solid var(--gray-200);
}

.dp-shortcut {
    border: 1px solid var(--gray-200);
    background: var(--surface-alt);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.3rem 0.65rem;
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: all var(--dur-fast) ease;
    font-family: inherit;
    line-height: 1.2;
}

.dp-shortcut:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.dp-shortcut:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

/* ---------- Navigation mois ---------- */
.dp-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.2rem 0.5rem;
}

.dp-nav-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: var(--radius);
    font-size: 1.2rem;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--dur-fast) ease;
    font-family: inherit;
}

.dp-nav-btn:hover {
    background: var(--gray-100);
    color: var(--primary);
}

.dp-nav-btn:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

.dp-nav-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: capitalize;
    letter-spacing: -0.005em;
}

/* ---------- Grille calendrier ---------- */
.dp-grid {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dp-row {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.dp-row-header {
    margin-bottom: 0.25rem;
}

.dp-cell-header {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-align: center;
    padding: 0.35rem 0;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.dp-cell {
    width: 36px;
    height: 36px;
    margin: 0 auto;
    border: none;
    background: transparent;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background var(--dur-fast) ease, color var(--dur-fast) ease;
    font-family: inherit;
    font-variant-numeric: tabular-nums;
    position: relative;
}

.dp-cell:hover:not(.dp-cell-disabled):not(.dp-cell-selected) {
    background: var(--gray-100);
    color: var(--primary);
}

.dp-cell:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

/* Jour en dehors du mois courant */
.dp-cell-outside {
    color: var(--text-tertiary);
    opacity: 0.55;
}

/* Weekend — fond gris très clair, non cliquable en mode terrain */
.dp-cell-weekend {
    color: var(--gray-400);
    background: var(--weekend-bg);
}

/* Jour férié — point d'accent discret en bas à droite */
.dp-cell-holiday::after {
    content: '';
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--holiday-accent);
    box-shadow: 0 0 0 1px var(--surface);
}

/* Désactivé (weekend en mode terrain, hors min/max) */
.dp-cell-disabled {
    cursor: not-allowed;
    color: var(--gray-300);
    background: var(--weekend-bg);
}

.dp-cell-disabled:hover {
    background: var(--weekend-bg);
    color: var(--gray-300);
}

/* Aujourd'hui — liseré primary, sans remplissage */
.dp-cell-today:not(.dp-cell-selected) {
    box-shadow: inset 0 0 0 1.5px var(--primary);
    color: var(--primary);
    font-weight: 600;
}

/* Sélectionné — fond primary, texte blanc (prime sur tout) */
.dp-cell-selected,
.dp-cell-selected:hover {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(var(--primary-rgb), 0.35);
}

.dp-cell-selected.dp-cell-holiday::after {
    background: #fff;
    box-shadow: 0 0 0 1px var(--primary);
}

/* ---------- Mobile — composant custom masqué (fallback natif via JS) ---------- */
@media (pointer: coarse) {
    .dp-popup { display: none; }
}
