/* =========================
   myDateTime control
========================= */

/* Host custom element */
mydatetime,
mydate {
    display: block;
    width: 100%;
    box-sizing: border-box;
}

/* Élément réel : input texte en édition, div en readonly */
.myDateTime {
    box-sizing: border-box;
    width: 100%;
    height: var(--zen-ctrl-height);
    min-height: var(--zen-ctrl-height);
    padding: 0 var(--zen-ctrl-padding-x);
    border-top: none;
    border-left: none;
    border-right: none;
    border-bottom: 1px solid var(--zen-ctrl-border-color);
    border-radius: 0;
    background: transparent;
    color: var(--zen-ctrl-color);
    font-family: var(--zen-ctrl-font-family);
    font-size: var(--zen-ctrl-font-size);
    line-height: normal;
    outline: none;
}

/* Mode édition */
input.myDateTime {
    display: block;
}

/* Mode readonly */
div.myDateTime,
.myDateTime.is-readonly {
    display: flex;
    align-items: center;
    cursor: default;
    border-bottom: none;
}

/* Placeholder readonly */
.myDateTime.is-placeholder {
    color: var(--zen-theme-placeholder, #9ca3af);
}

/* Disabled / readonly */
input.myDateTime:disabled,
.myDateTime.is-readonly {
    color: var(--zen-ctrl-disabled-color);
    background: transparent;
    opacity: 1;
    border-bottom: none;
}

/* =========================================================
   CULTURE — éditeur date contrôlé par Zen
   Le modèle reste ISO ; seul l'affichage d'édition est localisé.
========================================================= */

/*
   Le host porte déjà les classes de layout (col-8, etc.).
   myBaseCtrl les recopie aussi sur l'input interne : le wrapper ci-dessous
   neutralise cette largeur interne pour que le champ + l'icône occupent
   exactement la largeur du contrôle, comme les autres composants Zen.
*/
.myDateTime-editor {
    display: flex;
    align-items: stretch;
    width: 100%;
    height: var(--zen-ctrl-height);
    min-height: var(--zen-ctrl-height);
    box-sizing: border-box;
    border-bottom: 1px solid var(--zen-ctrl-border-color);
}

.myDateTime-editor:focus-within {
    border-bottom-color: var(--zen-theme-focus, #0F6CB7);
}

.myDateTime-editor > input.myDateTime {
    flex: 1 1 auto !important;
    width: 0 !important;
    min-width: 0;
    max-width: none !important;
    height: 100%;
    min-height: 0;
    padding: 0 var(--zen-ctrl-padding-x);
    border-bottom: 0;
}

.myDateTime-pickerButton {
    position: static;
    flex: 0 0 var(--zen-ctrl-height);
    width: var(--zen-ctrl-height);
    min-width: var(--zen-ctrl-height);
    height: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.myDateTime-pickerButton:hover {
    background: var(--zen-theme-hover-bg, rgba(15, 108, 183, 0.06));
}

.myDateTime-pickerButton:focus-visible {
    outline: 1px solid var(--zen-theme-focus, #0F6CB7);
    outline-offset: -2px;
}

/* =========================================================
   Calendrier Zen — PopupManager
========================================================= */
.myDateTime-calendar {
    width: 276px;
    box-sizing: border-box;
    padding: 10px;
    background: var(--zen-theme-surface, #fff);
    border: 1px solid var(--zen-theme-border, #d5dbe3);
    border-radius: 4px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
    color: var(--zen-ctrl-color);
    font-family: var(--zen-ctrl-font-family);
    font-size: var(--zen-ctrl-font-size);
}

.myDateTime-calendarHeader {
    display: grid;
    grid-template-columns: 30px 1fr 30px;
    align-items: center;
    min-height: 32px;
    margin-bottom: 6px;
}

.myDateTime-calendarTitle {
    text-align: center;
    font-weight: 600;
    text-transform: none;
}

.myDateTime-calendarNav {
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 3px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.myDateTime-calendarNav:hover {
    background: var(--zen-theme-hover-bg, #f0f3f7);
}

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

.myDateTime-calendarWeekdays {
    margin-bottom: 3px;
}

.myDateTime-calendarWeekday {
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: var(--zen-theme-text-muted, #687385);
    user-select: none;
}

.myDateTime-calendarDay {
    min-width: 0;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 3px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font: inherit;
}

.myDateTime-calendarDay:hover {
    background: var(--zen-theme-hover-bg, #edf4fb);
}

.myDateTime-calendarDay.is-outside {
    color: var(--zen-theme-text-muted, #a7afba);
}

.myDateTime-calendarDay.is-today {
    outline: 1px solid var(--zen-theme-selection-border, #0F6CB7);
    outline-offset: -2px;
}

.myDateTime-calendarDay.is-selected {
    background: var(--zen-theme-selection-bg, #0F6CB7);
    color: var(--zen-theme-selection-text, #fff);
    font-weight: 600;
}

.myDateTime-calendarDay.is-selected:hover {
    background: var(--zen-theme-selection-bg, #0F6CB7);
}

/* =========================================================
   CULTURE — DatePicker Zen enrichi
   Navigation jours / mois / années + actions Effacer / Aujourd'hui.
   PopupManager reste l'unique gestionnaire de popup.
========================================================= */

.myDateTime-calendarTitleButton {
    width: 100%;
    min-width: 0;
    min-height: 30px;
    padding: 0 6px;
    border: 0;
    border-radius: 3px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.myDateTime-calendarTitleButton:hover {
    background: var(--zen-theme-hover-bg, #f0f3f7);
}

.myDateTime-calendarMonthGrid,
.myDateTime-calendarYearGrid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 4px 0 8px;
}

.myDateTime-calendarMonth,
.myDateTime-calendarYear {
    min-width: 0;
    min-height: 38px;
    padding: 6px 4px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font: inherit;
}

.myDateTime-calendarMonth:hover,
.myDateTime-calendarYear:hover {
    background: var(--zen-theme-hover-bg, #edf4fb);
}

.myDateTime-calendarMonth.is-today,
.myDateTime-calendarYear.is-today {
    outline: 1px solid var(--zen-theme-selection-border, #0F6CB7);
    outline-offset: -2px;
}

.myDateTime-calendarMonth.is-selected,
.myDateTime-calendarYear.is-selected {
    background: var(--zen-theme-selection-bg, #0F6CB7);
    color: var(--zen-theme-selection-text, #fff);
    font-weight: 600;
}

.myDateTime-calendarFooter {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--zen-theme-border, #e2e7ed);
}

.myDateTime-calendarAction {
    min-height: 32px;
    padding: 5px 8px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--zen-theme-text, #44505f);
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
}

.myDateTime-calendarAction:hover {
    background: var(--zen-theme-hover-bg, #f0f3f7);
}

.myDateTime-calendarAction--primary {
    color: var(--zen-theme-action, #0F6CB7);
}

@media (max-width: 760px) {
    .myDateTime-calendar {
        width: min(330px, calc(100vw - 16px));
        padding: 12px;
    }

    .myDateTime-calendarHeader {
        grid-template-columns: 38px 1fr 38px;
        min-height: 40px;
    }

    .myDateTime-calendarNav {
        width: 38px;
        height: 38px;
    }

    .myDateTime-calendarTitleButton {
        min-height: 38px;
    }

    .myDateTime-calendarWeekday {
        height: 28px;
        font-size: 12px;
    }

    .myDateTime-calendarDay {
        height: 38px;
    }

    .myDateTime-calendarMonth,
    .myDateTime-calendarYear {
        min-height: 44px;
    }

    .myDateTime-calendarAction {
        min-height: 40px;
        padding: 7px 10px;
    }
}


/* =========================================================
   myDateTime composite — mode="datetime"
   The outer control owns the model; myDate + myTime own presentation/pickers.
========================================================= */
.myDateTimeCombined,
.myDateTimeCombined-editor {
    box-sizing: border-box;
    width: 100% !important;
    max-width: none !important;
    flex-basis: auto !important;
}

.myDateTimeCombined {
    min-height: var(--zen-ctrl-height);
    display: flex;
    align-items: center;
    padding: 0 var(--zen-ctrl-padding-x);
    border-bottom: none;
    color: var(--zen-ctrl-color);
    font-family: var(--zen-ctrl-font-family);
    font-size: var(--zen-ctrl-font-size);
}

.myDateTimeCombined.is-placeholder {
    color: var(--zen-theme-placeholder, #9ca3af);
}

.myDateTimeCombined-editor {
    display: flex;
    align-items: stretch;
    flex-wrap: wrap;
    gap: 10px;
    min-width: 0;
}

.myDateTimeCombined-dateHost,
.myDateTimeCombined-timeHost {
    min-width: 0;
    width: auto;
    box-sizing: border-box;
}

/*
   Le composite doit rester lisible quelle que soit la largeur que lui
   donne le layout (col-*, grille, template...).
   Date a besoin d'un peu plus d'espace que Heure, mais aucune partie
   ne doit pouvoir écraser l'autre. Si la place manque réellement, le
   flex-wrap les place naturellement sur deux lignes et chaque partie
   reprend alors toute la largeur disponible.
*/
.myDateTimeCombined-dateHost {
    flex: 1.35 1 145px;
    min-width: 125px;
}

.myDateTimeCombined-timeHost {
    flex: 1 1 112px;
    min-width: 102px;
}

@media (max-width: 760px) {
    .myDateTimeCombined-editor {
        gap: 6px;
    }
}
