/* ==========================================================================
   Speedy Admin — Datepicker
   Custom calendar popover replacing native <input type="date">.
   Theme-aware via CSS variables (light + dark), flat business look.
   ========================================================================== */

/* ---------- Enhanced input ---------- */
.dp-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}
.field .dp-wrap { display: flex; width: 100%; }

.dp-wrap input {
    padding-right: 34px;
    cursor: pointer;
}
.dp-wrap input::selection { background: transparent; }

.dp-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
    transition: color var(--transition), background var(--transition);
}
.dp-toggle:hover { color: var(--primary); background: var(--primary-soft); }

/* ---------- Popover ---------- */
.datepicker {
    position: fixed;
    z-index: 130; /* above modals (90) and toasts (120) */
    width: 288px;
    padding: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    opacity: 0;
    transform: translateY(-6px) scale(0.97);
    transition: opacity 0.16s ease, transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
.datepicker.show { opacity: 1; transform: translateY(0) scale(1); }
.datepicker.above { transform-origin: bottom left; }

/* ---------- Header ---------- */
.dp-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 8px;
}

.dp-nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-2);
    cursor: pointer;
    transition: color var(--transition), background var(--transition), border-color var(--transition);
}
.dp-nav:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }

.dp-label {
    flex: 1;
    padding: 5px 8px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    font-family: var(--font);
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.dp-label:hover:not(:disabled) { background: var(--primary-soft); color: var(--primary); }
.dp-label:disabled { cursor: default; }

/* ---------- Day grid ---------- */
.dp-grid {
    display: grid;
    grid-template-columns: 26px repeat(7, 1fr);
    gap: 2px;
    align-items: center;
}

.dp-weekdays {
    margin-bottom: 2px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}
.dp-weekdays span {
    text-align: center;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-3);
}

.dp-wk {
    text-align: center;
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text-3);
    opacity: 0.7;
    user-select: none;
}

.dp-day {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 30px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    font-family: var(--font);
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    transition: background var(--transition), color var(--transition), transform var(--transition);
}
.dp-day:hover:not(:disabled) { background: var(--primary-soft); color: var(--primary); }
.dp-day:active:not(:disabled) { transform: scale(0.92); }
.dp-day:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

.dp-day.other { color: var(--text-3); opacity: 0.55; }

.dp-day.today { color: var(--primary); font-weight: 700; }
.dp-day.today::after {
    content: '';
    position: absolute;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--primary);
}

.dp-day.selected,
.dp-day.selected:hover {
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.dp-day.selected.today::after { background: #fff; }

.dp-day.disabled,
.dp-day:disabled { color: var(--text-3); opacity: 0.35; cursor: not-allowed; }

/* ---------- Month / year grids ---------- */
.dp-grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    padding: 2px 0;
}

.dp-cell {
    height: 42px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    font-family: var(--font);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.dp-cell:hover { background: var(--primary-soft); color: var(--primary); }
.dp-cell.today { border-color: var(--primary); color: var(--primary); }
.dp-cell.selected, .dp-cell.selected:hover { background: var(--primary); color: #fff; }

/* ---------- Body slide animation (month navigation) ---------- */
.dp-body { overflow: hidden; }
.dp-body.slide-left { animation: dp-slide-left 0.18s ease; }
.dp-body.slide-right { animation: dp-slide-right 0.18s ease; }

@keyframes dp-slide-left {
    from { opacity: 0.4; transform: translateX(14px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes dp-slide-right {
    from { opacity: 0.4; transform: translateX(-14px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ---------- Footer ---------- */
.dp-foot {
    display: flex;
    justify-content: space-between;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}
.dp-foot .btn:last-child { color: var(--text-3); }
.dp-foot .btn:last-child:hover { color: var(--danger); }
