/* ==================================================================
   Eintrag erstellen und bearbeiten

   Die ganze Seite nimmt die Farbe der gewaehlten Art des Tages an:
   Training gruen, Pause weiss, Krank blau, Skip rot (base.css). main
   traegt data-daytype - beim Laden vom Server, beim Wechsel von
   entry.js -, daraus leiten sich --tone, --tone-bg und --tone-line ab.
   Ohne Auswahl ist alles neutral grau. Jede Kachel der Auswahl hat ihr
   eigenes data-daytype und zeigt damit immer ihre eigene Farbe.
   ================================================================== */

.entry-editor {
    --tone: var(--daytype-color, #8c948d);
    --tone-bg: var(--daytype-bg, rgba(140, 148, 141, 0.08));
    --tone-line: var(--daytype-line, rgba(140, 148, 141, 0.32));
    --tone-ease: 280ms ease;
}

.container.entry-editor {
    max-width: 900px;
}

.entry-editor svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* --- Kopf ------------------------------------------------------------ */

.entry-editor-head {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
    padding: 28px 28px 28px 34px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: linear-gradient(180deg, var(--surface-soft), var(--panel));
    box-shadow: var(--shadow-md);
}

/* Streifen links und ein weicher Schein oben rechts - beide in der Farbe des Tages */
.entry-editor-head::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 5px;
    background: var(--tone);
    transition: background-color var(--tone-ease);
}

.entry-editor-head::after {
    content: "";
    position: absolute;
    top: -120px;
    right: -90px;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: var(--tone);
    opacity: 0.13;
    filter: blur(60px);
    pointer-events: none;
    transition: background-color var(--tone-ease);
}

.entry-editor-heading {
    position: relative;
    z-index: 1;
    min-width: 0;
}

.entry-editor-kicker {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin: 0 0 8px;
    color: var(--tone);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    transition: color var(--tone-ease);
}

.entry-editor-kicker::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: var(--radius-sm);
    background: var(--tone);
    box-shadow: 0 0 0 4px var(--tone-bg);
    transition: background-color var(--tone-ease), box-shadow var(--tone-ease);
}

.entry-editor-head h1 {
    margin: 0;
    font-size: 31px;
    letter-spacing: -0.025em;
}

.entry-editor-date {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 14.5px;
}

.entry-editor-date svg {
    flex: none;
    width: 16px;
    height: 16px;
}

/* Grosses Symbol der gewaehlten Art */
.entry-editor-mark {
    position: relative;
    z-index: 1;
    display: grid;
    flex: none;
    place-items: center;
    width: 78px;
    height: 78px;
    border: 1px solid var(--tone-line);
    border-radius: var(--radius);
    background: var(--tone-bg);
    color: var(--tone);
    transition: background-color var(--tone-ease), border-color var(--tone-ease), color var(--tone-ease);
}

.entry-editor-mark > span {
    display: none;
}

.entry-editor-mark svg {
    display: block;
    width: 38px;
    height: 38px;
}

.entry-editor:not([data-daytype]) .entry-editor-mark > [data-icon="NONE"],
.entry-editor[data-daytype="TRAINING"] .entry-editor-mark > [data-icon="TRAINING"],
.entry-editor[data-daytype="REST"] .entry-editor-mark > [data-icon="REST"],
.entry-editor[data-daytype="SICK"] .entry-editor-mark > [data-icon="SICK"],
.entry-editor[data-daytype="SKIP"] .entry-editor-mark > [data-icon="SKIP"] {
    display: block;
    animation: tone-in 320ms ease;
}

/* --- Art des Tages: Kacheln ------------------------------------------ */

.daytype-picker {
    min-width: 0;
    margin: 0 0 14px;
    padding: 0;
    border: 0;
}

.daytype-legend {
    display: block;
    margin: 0 0 10px;
    padding: 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.daytype-legend .muted.small {
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
}

.daytype-options {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.daytype-option {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    min-width: 0;
    min-height: 136px;
    padding: 16px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background-color: var(--panel);
    cursor: pointer;
    transition: border-color 200ms ease, background-color 200ms ease, box-shadow 200ms ease, transform 200ms ease,
        opacity 200ms ease;
}

.daytype-option:hover {
    border-color: var(--daytype-line);
    background-color: var(--surface-soft);
}

.daytype-option:has(.daytype-input:checked) {
    border-color: var(--daytype-color);
    background-color: var(--surface-soft);
    background-image: linear-gradient(160deg, var(--daytype-bg), rgba(0, 0, 0, 0) 75%);
    box-shadow: inset 0 0 0 1px var(--daytype-color), 0 16px 32px -20px var(--daytype-color);
}

/* Nach der Wahl treten die anderen Kacheln etwas zurueck */
.daytype-options:has(.daytype-input:checked) .daytype-option:not(:has(.daytype-input:checked)) {
    opacity: 0.68;
}

.daytype-options:has(.daytype-input:checked) .daytype-option:hover {
    opacity: 1;
}

.daytype-option:has(.daytype-input:focus-visible) {
    box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--daytype-color);
}

/* Das echte Optionsfeld bleibt bedienbar (Tastatur, Vorlesen), ist aber unsichtbar - die Kachel zeigt den Zustand. */
.daytype-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 1px;
    margin: 0;
    opacity: 0;
    pointer-events: none;
}

.daytype-icon {
    display: grid;
    flex: none;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--daytype-line);
    border-radius: var(--radius);
    background: var(--daytype-bg);
    color: var(--daytype-color);
    transition: background-color 200ms ease, border-color 200ms ease, color 200ms ease;
}

.daytype-icon svg {
    width: 23px;
    height: 23px;
}

.daytype-option:has(.daytype-input:checked) .daytype-icon {
    border-color: var(--daytype-color);
    background: var(--daytype-color);
    color: var(--on-day);
}

.daytype-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.daytype-name {
    font-size: 15.5px;
    line-height: 1.25;
    /* "Trainingstag" nie mitten im Wort trennen (body bricht sonst ueberall um) */
    overflow-wrap: normal;
}

.daytype-option:has(.daytype-input:checked) .daytype-name {
    color: var(--daytype-color);
}

.daytype-summary {
    color: var(--muted);
    font-size: 12.5px;
    line-height: 1.35;
}

.daytype-check {
    position: absolute;
    top: 12px;
    right: 12px;
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border: 1.5px solid var(--border-strong);
    /* rund wie ein Optionsfeld: Es gibt nur eine Auswahl */
    border-radius: 50%;
    color: transparent;
    transition: background-color 200ms ease, border-color 200ms ease, color 200ms ease;
}

.daytype-check svg {
    width: 14px;
    height: 14px;
    stroke-width: 3;
}

.daytype-option:has(.daytype-input:checked) .daytype-check {
    border-color: var(--daytype-color);
    background: var(--daytype-color);
    color: var(--on-day);
}

/* --- Hinweis zur gewaehlten Art -------------------------------------- */

.daytype-notes {
    margin: 0 0 24px;
}

.daytype-note {
    display: none;
    margin: 0;
    padding: 11px 14px 11px 16px;
    border: 1px solid var(--tone-line);
    border-left: 3px solid var(--tone);
    border-radius: var(--radius-sm);
    background: var(--tone-bg);
    font-size: 13.5px;
    line-height: 1.5;
}

.entry-editor:not([data-daytype]) .daytype-note[data-note="NONE"],
.entry-editor[data-daytype="TRAINING"] .daytype-note[data-note="TRAINING"],
.entry-editor[data-daytype="REST"] .daytype-note[data-note="REST"],
.entry-editor[data-daytype="SICK"] .daytype-note[data-note="SICK"],
.entry-editor[data-daytype="SKIP"] .daytype-note[data-note="SKIP"] {
    display: block;
    animation: tone-in 260ms ease;
}

@keyframes tone-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
}

/* --- Abschnitte ------------------------------------------------------ */

.entry-editor #entry-form .panel {
    border-top: 2px solid var(--tone-line);
    transition: border-color var(--tone-ease), box-shadow var(--tone-ease);
}

.entry-editor #entry-form .panel:focus-within {
    border-color: var(--tone-line);
    box-shadow: var(--shadow-sm), 0 14px 34px -26px var(--tone);
}

.entry-editor .section-title {
    display: flex;
    align-items: center;
    gap: 11px;
}

.entry-editor .section-icon {
    display: inline-grid;
    flex: none;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--tone-line);
    border-radius: var(--radius-sm);
    background: var(--tone-bg);
    color: var(--tone);
    transition: background-color var(--tone-ease), border-color var(--tone-ease), color var(--tone-ease);
}

.entry-editor .section-icon svg {
    width: 17px;
    height: 17px;
}

/* Rehab behaelt seine eigene, warme Farbe - wie auf der Detailseite */
.entry-editor #rehab-panel .section-icon {
    border-color: var(--warm-line);
    background: var(--warm-bg);
    color: var(--warm);
}

/* --- Felder und Knoepfe in der Farbe des Tages ------------------------ */

.entry-editor input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):focus,
.entry-editor select:focus,
.entry-editor textarea:focus {
    border-color: var(--tone);
    box-shadow: 0 0 0 2px var(--tone-line);
}

.entry-editor input[type="checkbox"] {
    accent-color: var(--tone);
}

.entry-editor button.primary,
.entry-editor button.primary:hover {
    border-color: var(--tone);
    background: var(--tone);
    color: var(--on-day);
}

.entry-editor button.primary {
    transition: background-color var(--tone-ease), border-color var(--tone-ease), filter var(--ease);
}

.entry-editor button.primary:hover {
    filter: brightness(1.1);
}

.entry-editor #training-panel .actions button,
.entry-editor .cardio-add,
.entry-editor .photo-add-button {
    border-color: var(--tone-line);
    background: transparent;
    color: var(--tone);
}

.entry-editor .cardio-add,
.entry-editor .photo-add-button {
    border-style: dashed;
}

.entry-editor #training-panel .actions button:hover:not(:disabled),
.entry-editor .cardio-add:hover:not(:disabled),
.entry-editor .photo-add-button:hover:not(:disabled) {
    border-color: var(--tone);
    background: var(--tone-bg);
    color: var(--tone);
}

.entry-editor .cardio-add-icon,
.entry-editor .photo-add-icon {
    background: var(--tone);
    color: var(--on-day);
}

.entry-editor .setindex,
.entry-editor .settable td.setindex,
.entry-editor .settable td.setindex::before {
    color: var(--tone);
}

.entry-editor .cardio-session {
    border-left-color: var(--tone-line);
}

.entry-editor .photo-counter {
    background: var(--tone-bg);
    color: var(--tone);
}

.entry-editor .photo-select-button {
    border-color: var(--tone);
    color: var(--tone);
}

.entry-editor .photo-select-button:hover {
    background: var(--tone-bg);
}

.entry-editor .photo-public {
    border-color: var(--tone-line);
    background: var(--tone-bg);
}

/* Fotokarten in fester Breite: Ein einzelnes Foto fuellte sonst auf dem Desktop die ganze Zeile - im Hochformat
   ueber 1000px hoch. Auf dem Handy bleibt es bei einer Karte je Zeile (entries.css). */
.entry-editor .photo-slots {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
}

/* --- Schwebende Speichern-Leiste --------------------------------------- */

.entry-editor #entry-form > .entry-actions {
    position: sticky;
    bottom: calc(12px + env(safe-area-inset-bottom));
    z-index: 5;
    flex-wrap: nowrap;
    gap: 10px;
    margin: 28px 0 0;
    padding: 12px 12px 12px 18px;
    border: 1px solid var(--tone-line);
    border-radius: var(--radius);
    background: rgba(18, 20, 18, 0.9);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    backdrop-filter: blur(12px) saturate(140%);
    box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(0, 0, 0, 0.4);
    transition: border-color var(--tone-ease);
}

.entry-status {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    margin: 0 auto 0 0;
    color: var(--text);
    font-size: 14px;
    font-weight: 650;
}

.entry-status-dot {
    flex: none;
    width: 10px;
    height: 10px;
    border-radius: var(--radius-sm);
    background: var(--tone);
    box-shadow: 0 0 0 4px var(--tone-bg);
    transition: background-color var(--tone-ease), box-shadow var(--tone-ease);
}

.entry-status-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.entry-status-name > span {
    display: none;
}

.entry-editor:not([data-daytype]) .entry-status-name > [data-name="NONE"] {
    display: inline;
    color: var(--muted);
    font-weight: 500;
}

.entry-editor[data-daytype="TRAINING"] .entry-status-name > [data-name="TRAINING"],
.entry-editor[data-daytype="REST"] .entry-status-name > [data-name="REST"],
.entry-editor[data-daytype="SICK"] .entry-status-name > [data-name="SICK"],
.entry-editor[data-daytype="SKIP"] .entry-status-name > [data-name="SKIP"] {
    display: inline;
}

.entry-editor .entry-submit {
    min-width: 200px;
}

.entry-editor .draft-notice {
    border-color: var(--tone-line);
    border-left-color: var(--tone);
    background: var(--tone-bg);
}

.entry-editor .draft-notice svg {
    stroke: var(--tone);
}

.entry-editor .entry-actions .button,
.entry-editor .entry-actions button {
    white-space: nowrap;
}

/* Abbrechen: Text, auf schmalen Handys nur das Kreuz */
.entry-cancel-icon {
    display: none;
    width: 18px;
    height: 18px;
}

/* --- Sperrzeit statt Formular ----------------------------------------- */

.entry-timeout {
    border-left-width: 4px;
}

/* --- Bewegung nur bei Zeigern, die schweben koennen ------------------- */

@media (hover: hover) {
    .daytype-option:hover {
        transform: translateY(-2px);
    }
}

/* --- Tablet: Kacheln bleiben nebeneinander, etwas kompakter ----------- */

@media (max-width: 980px) {
    .daytype-option {
        min-height: 124px;
        padding: 14px;
    }
}

/* --- Handy ------------------------------------------------------------ */

@media (max-width: 680px) {
    .entry-editor-head {
        gap: 14px;
        margin-bottom: 18px;
        padding: 18px 16px 18px 22px;
    }

    .entry-editor-head::after {
        width: 200px;
        height: 200px;
    }

    .entry-editor-head h1 {
        font-size: 24px;
    }

    .entry-editor-date {
        font-size: 13.5px;
    }

    .entry-editor-mark {
        width: 54px;
        height: 54px;
    }

    .entry-editor-mark svg {
        width: 27px;
        height: 27px;
    }

    .daytype-options {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .daytype-option {
        gap: 10px;
        min-height: 0;
        padding: 12px;
    }

    .daytype-icon {
        width: 38px;
        height: 38px;
    }

    .daytype-icon svg {
        width: 20px;
        height: 20px;
    }

    .daytype-check {
        top: 10px;
        right: 10px;
    }

    .daytype-notes {
        margin-bottom: 18px;
    }

    .entry-editor .section-icon {
        width: 28px;
        height: 28px;
    }

    /* Satz-Karten (responsive.css) bekommen links die Farbe des Tages */
    .entry-editor .settable tbody .setrow:not(.hidden) {
        border-left: 3px solid var(--tone-line);
    }

    .entry-editor #entry-form > .entry-actions {
        bottom: calc(8px + env(safe-area-inset-bottom));
        gap: 8px;
        margin-right: -4px;
        margin-left: -4px;
        padding: 10px;
    }

    .entry-editor .entry-submit {
        flex: 1 1 auto;
        min-width: 0;
    }
}

@media (max-width: 460px) {
    /* Platz fuer die Knoepfe: die Art des Tages steht ohnehin oben und in der Farbe */
    .entry-status {
        display: none;
    }

    .entry-editor .entry-cancel {
        flex: none;
        width: 46px;
        padding: 0;
    }

    .entry-cancel-icon {
        display: block;
    }

    .entry-cancel-text {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
    }
}

/* Sehr schmale Handys: kompakte Kacheln ohne Beschreibung - der Name hat so die ganze Breite */
@media (max-width: 379px) {
    .entry-editor-mark {
        display: none;
    }

    .entry-editor-head h1 {
        font-size: 22px;
    }

    .daytype-option {
        gap: 8px;
        padding: 10px;
    }

    .daytype-icon {
        width: 32px;
        height: 32px;
    }

    .daytype-icon svg {
        width: 18px;
        height: 18px;
    }

    .daytype-name {
        font-size: 14px;
    }

    .daytype-summary {
        display: none;
    }

    .daytype-check {
        top: 8px;
        right: 8px;
        width: 18px;
        height: 18px;
    }

    .daytype-check svg {
        width: 11px;
        height: 11px;
    }
}

/* Querformat mit wenig Hoehe: flacher Kopf, Kacheln als Zeile, schmale Leiste */
@media (max-height: 500px) and (orientation: landscape) {
    .entry-editor-head {
        margin-bottom: 14px;
        padding-top: 14px;
        padding-bottom: 14px;
    }

    .entry-editor-kicker {
        margin-bottom: 4px;
    }

    .entry-editor-head h1 {
        font-size: 22px;
    }

    .entry-editor-date {
        display: none;
    }

    .entry-editor-mark {
        display: none;
    }

    .daytype-option {
        flex-direction: row;
        align-items: center;
        gap: 10px;
        min-height: 0;
        padding: 10px;
    }

    .daytype-summary {
        display: none;
    }

    .daytype-name {
        font-size: 14px;
    }

    .daytype-icon {
        width: 32px;
        height: 32px;
    }

    /* Die gewaehlte Kachel ist auch so klar zu erkennen (Rahmen, gefuelltes Symbol) */
    .daytype-check {
        display: none;
    }

    .entry-editor #entry-form > .entry-actions {
        bottom: 6px;
        padding-top: 6px;
        padding-bottom: 6px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .entry-editor *,
    .entry-editor *::before,
    .entry-editor *::after {
        animation: none !important;
        transition: none !important;
    }

    .daytype-option:hover {
        transform: none;
    }
}
