/* ============================================================================
   TMS date / date-time field (Components/Shared/TmsDateInput.razor)

   The visible box is a normal text input so the operator sees 17-Oct-2026.
   The calendar is a Blazor panel pinned with position:fixed by date-input.js,
   so a grid / card with overflow:auto can never clip it.
   ============================================================================ */

.tms-date {
    position: relative;
    display: block;
    width: 100%;
    max-width: 100%;
}

/* Room for the calendar button without moving any surrounding field. */
.tms-date > .tms-date-text {
    padding-right: 24px;
    background-image: none;
}

.tms-date > .tms-date-btn {
    position: absolute;
    top: 50%;
    right: 2px;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 3px;
    background: transparent;
    color: currentColor;
    opacity: 0.55;
    cursor: pointer;
    line-height: 1;
}

.tms-date > .tms-date-btn:hover:not(:disabled) {
    opacity: 0.95;
    background: rgba(0, 0, 0, 0.06);
}

.tms-date > .tms-date-btn:disabled {
    cursor: default;
    opacity: 0.25;
}

.tms-date > .tms-date-btn .bi {
    font-size: 12px;
    pointer-events: none;
}

/* ============================ calendar panel ============================ */
/* A transparent full-screen layer closes the panel on any outside click. */
.tms-cal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 2299;
    background: transparent;
}

.tms-cal {
    position: fixed;
    z-index: 2300;
    padding: 6px;
    border: 1px solid #c8c6c4;
    border-radius: 4px;
    background: #fff;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
    color: #323130;
    font-family: inherit;
    font-size: 12px;
    user-select: none;
}

.tms-cal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2px;
    padding-bottom: 4px;
}

.tms-cal-title {
    flex: 1 1 auto;
    text-align: center;
    font-weight: 600;
    font-size: 12px;
    color: #323130;
}

.tms-cal-nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 0;
    border-radius: 3px;
    background: transparent;
    color: #605e5c;
    cursor: pointer;
    line-height: 1;
}

.tms-cal-nav:hover {
    background: #f3f2f1;
    color: #0078d4;
}

.tms-cal-weekdays,
.tms-cal-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
}

.tms-cal-weekdays > span {
    padding: 2px 0;
    text-align: center;
    color: #8a8886;
    font-size: 9.5px;
    font-weight: 600;
    text-transform: uppercase;
}

.tms-cal-day {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 26px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 3px;
    background: transparent;
    color: #323130;
    font-family: inherit;
    font-size: 11.5px;
    cursor: pointer;
    font-variant-numeric: tabular-nums;
}

.tms-cal-day:hover:not(.is-blank) {
    background: #eff6fc;
    border-color: #c7e0f4;
}

.tms-cal-day.is-blank {
    cursor: default;
}

.tms-cal-day.is-today {
    border-color: #c7e0f4;
    color: #0078d4;
    font-weight: 600;
}

.tms-cal-day.is-selected {
    background: #0078d4;
    border-color: #0078d4;
    color: #fff;
    font-weight: 600;
}

.tms-cal-time {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #edebe9;
}

.tms-cal-time-label {
    color: #605e5c;
    font-size: 10.5px;
    font-weight: 600;
}

.tms-cal-time-input {
    width: 44px;
    padding: 2px 4px;
    border: 1px solid #c8c6c4;
    border-radius: 3px;
    font-family: inherit;
    font-size: 11.5px;
    text-align: center;
}

.tms-cal-time-sep {
    color: #605e5c;
}

.tms-cal-foot {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #edebe9;
}

.tms-cal-today {
    margin-right: auto;
    border: 0;
    background: transparent;
    color: #0078d4;
    font-family: inherit;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    padding: 3px 4px;
    border-radius: 3px;
}

.tms-cal-today:hover {
    background: #eff6fc;
}

.tms-cal-cancel,
.tms-cal-ok {
    padding: 3px 10px;
    border: 1px solid #c8c6c4;
    border-radius: 3px;
    background: #fff;
    color: #323130;
    font-family: inherit;
    font-size: 11.5px;
    cursor: pointer;
}

.tms-cal-cancel:hover {
    background: #f3f2f1;
}

.tms-cal-ok {
    border-color: #0078d4;
    background: #0078d4;
    color: #fff;
    font-weight: 600;
}

.tms-cal-ok:hover {
    background: #106ebe;
}

/* Editable grids: the native input used to fill the cell, so the wrapper must too. */
.d365-grid-cell > .tms-date,
.d365-grid-cell .tms-date,
td > .tms-date {
    width: 100%;
}

.d365-grid-cell .tms-date > .tms-date-text,
td > .tms-date > .tms-date-text {
    width: 100%;
    box-sizing: border-box;
}

/* Inline (col-auto) fields keep their natural width instead of stretching the row. */
.row .col-auto > .tms-date {
    width: auto;
    display: inline-block;
}

/* Dark appearance keeps the icon readable. */
[data-appearance="dark"] .tms-date > .tms-date-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.12);
}

