/*
 * TimeSpy – time-tracking
 * Teil der aufgeteilten timespy.css (siehe base.css für Variablen).
 * Reihenfolge der <link>-Tags in layout.php/login.php ist wichtig
 * und entspricht exakt der ursprünglichen Reihenfolge in dieser Datei.
 */

/* =========================================================
   TIME PAGE
   ========================================================= */

.time-page {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.time-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;

    background: var(--accent-soft);
    border-color: rgba(37, 99, 235, .18);
}

.time-toolbar-title {
    min-width: 0;
}

.time-month-title {
    margin: 5px 0 0;
    font-size: 1.8rem;
    font-weight: 650;
    letter-spacing: -.04em;
}

.time-toolbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.time-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.time-view-tabs {
    display: inline-flex;
    gap: 4px;

    padding: 4px;
    margin: 0;

    background: rgba(0, 0, 0, .035);
    border-radius: 12px;
}

.time-view-tab {
    min-height: 34px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 0 14px;

    color: var(--text-secondary);
    text-decoration: none;

    border-radius: 9px;

    font-size: .78rem;
    font-weight: 650;

    transition:
        background var(--transition),
        color var(--transition),
        box-shadow var(--transition);
}

.time-view-tab:hover {
    color: var(--text);
}

.time-view-tab.active {
    color: var(--text);
    background: white;
    box-shadow: var(--shadow-sm);
}


/* =========================================================
   SUMMARY
   ========================================================= */

.time-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0,1fr));
    gap: 14px;
}

.time-summary-card {
    padding: 18px 20px;

    border: 1px solid var(--border);
    border-radius: var(--radius-lg);

    background: rgba(255,255,255,.64);

    box-shadow: var(--shadow-sm);
}

.time-summary-card span,
.time-summary-card small {
    display: block;

    color: var(--text-muted);

    font-size: .72rem;
}

.month-certification-card {
    margin-top: 14px;
    padding: 16px 18px;
}

.month-certification-status {
    display: flex;
    align-items: center;

    gap: 14px;
    flex-wrap: wrap;
}

.month-certification-status form {
    margin-left: auto;
}

.month-certification-icon {
    display: flex;
    align-items: center;
    justify-content: center;

    flex-shrink: 0;

    width: 34px;
    height: 34px;

    border-radius: 50%;

    background: rgba(22, 163, 74, .12);
    color: #16a34a;

    font-size: 1rem;
    font-weight: 700;
}

.month-certification-icon--pending {
    background: var(--bg-solid);
    color: var(--text-muted);
}

.time-summary-card strong {
    display: block;

    margin: 10px 0 5px;

    font-size: 1.45rem;
    letter-spacing: -.04em;
}

.time-summary-card strong.positive {
    color: var(--success);
}

.time-summary-card strong.negative {
    color: var(--danger);
}


/* =========================================================
   TIME TIMELINE
   ========================================================= */

.time-timeline {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.time-day-card {
    padding: 0;
    overflow: hidden;
}

.time-day-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 24px;

    padding: 20px 22px;
}

.time-day-weekday {
    font-size: .95rem;
    font-weight: 650;
}

.time-day-date {
    margin-top: 4px;

    color: var(--text-muted);

    font-size: .74rem;
}

.time-day-metrics {
    display: flex;
    align-items: center;
    gap: 18px;
}

.time-day-number {
    text-align: right;
}

.time-day-number strong {
    display: block;

    font-size: 1rem;
}

.time-day-number span {
    display: block;

    margin-top: 3px;

    color: var(--text-muted);

    font-size: .7rem;
}

.time-day-balance {
    min-width: 70px;

    text-align: right;

    font-weight: 700;
    font-size: .82rem;
}

.time-day-balance.positive {
    color: var(--success);
}

.time-day-balance.negative {
    color: var(--danger);
}

.time-day-entries {
    padding: 4px 22px 20px;
}

.time-line-entry {
    display: flex;
    align-items: center;

    gap: 12px;

    padding: 10px 0;
}

.time-line-dot {
    width: 9px;
    height: 9px;

    flex: 0 0 auto;

    border-radius: 999px;

    background: var(--text-muted);
}

.time-line-dot.running {
    background: var(--success);

    box-shadow:
        0 0 0 5px
        rgba(22,163,74,.10);
}

.time-line-range {
    flex: 1;

    display: grid;
    grid-template-columns: 52px 1fr 52px;

    align-items: center;

    gap: 12px;
}

.time-line-range strong {
    font-size: .8rem;
}

.time-line-range strong:last-child {
    text-align: right;
}

.time-line-bar {
    height: 2px;

    overflow: hidden;

    border-radius: 999px;

    background: rgba(0,0,0,.08);
}

.time-line-bar span {
    display: block;

    width: 100%;
    height: 100%;

    background:
        linear-gradient(
            90deg,
            #2563eb,
            #7c3aed
        );
}


/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 900px) {

    .time-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .time-toolbar-right {
        width: 100%;

        align-items: stretch;
        flex-direction: column;
    }

    .time-view-tabs {
        width: fit-content;
    }

    .time-toolbar-actions {
        justify-content: space-between;
    }

    .time-summary {
        grid-template-columns:
            repeat(2, minmax(0,1fr));
    }

    .time-day-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .time-day-metrics {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 560px) {

    .time-summary {
        grid-template-columns: 1fr;
    }

    .time-line-range {
        grid-template-columns:
            44px 1fr 44px;

        gap: 8px;
    }
}

/* =========================================================
   PREMIUM 24H DAY TIMELINE
   ========================================================= */

.time-day-card {
    overflow: hidden;
    padding: 0;
}

/*
 * Feiertags-Karomuster: rotes, diagonales Karo über die gesamte
 * Kachel, damit auf einen Blick erkennbar ist, dass an diesem Tag
 * ein von HR erfasster Feiertag gilt - unabhängig davon, ob der
 * Tag Einträge hat oder leer ist. Bewusst hier zusammen definiert
 * (nicht in entry-cards.css, wo .month-day-row selbst herkommt),
 * damit beide Kontexte (Tages- und Monatsansicht) exakt dasselbe
 * Muster verwenden - die Spezifität (zwei Klassen) sorgt dafür,
 * dass diese Regel unabhängig von der Datei-Ladereihenfolge
 * gewinnt.
 */
.time-day-card.is-holiday,
.month-day-row.is-holiday {
    background-image:
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 8px,
            rgba(220, 38, 38, .10) 8px,
            rgba(220, 38, 38, .10) 16px
        ),
        repeating-linear-gradient(
            -45deg,
            transparent,
            transparent 8px,
            rgba(220, 38, 38, .10) 8px,
            rgba(220, 38, 38, .10) 16px
        );

    background-color: rgba(220, 38, 38, .03);
}

.time-day-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 32px;

    padding: 22px 24px;

    border-bottom: 1px solid var(--border);
}

.time-day-heading {
    min-width: 150px;
}

.time-day-title-row {
    display: flex;
    align-items: center;
    gap: 9px;
}

.time-day-weekday {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -.02em;
}

.time-today-marker {
    padding: 3px 7px;

    color: var(--accent);

    background: var(--accent-soft);

    border-radius: 999px;

    font-size: .65rem;
    font-weight: 650;
}

.time-day-date {
    margin-top: 4px;

    color: var(--text-muted);

    font-size: .72rem;
}


/* =========================================================
   DAY METRICS
   ========================================================= */

.time-day-metrics {
    display: flex;
    align-items: center;

    gap: 24px;
}

.time-day-stat {
    min-width: 68px;

    display: flex;
    flex-direction: column;

    text-align: right;
}

.time-day-stat span {
    color: var(--text-muted);

    font-size: .66rem;
}

.time-day-stat strong {
    margin-top: 3px;

    font-size: .88rem;

    letter-spacing: -.02em;
}

.time-day-stat strong.positive {
    color: var(--success);
}

.time-day-stat strong.negative {
    color: var(--danger);
}


/* =========================================================
   24H TIMELINE
   ========================================================= */

.day-timeline {
    padding:
        22px
        26px
        12px;
}

.day-timeline-scale {
    position: relative;

    height: 22px;

    margin:
        0
        0
        7px;
}

.day-timeline-scale span {
    position: absolute;
    top: 0;

    transform:
        translateX(-50%);

    color: var(--text-muted);

    font-size: .62rem;
}

.day-timeline-scale span:first-child {
    transform: none;
}

.day-timeline-scale span:last-child {
    transform:
        translateX(-100%);
}


.day-timeline-grid {
    position: relative;

    min-height: 94px;

    overflow: hidden;

    background:
        linear-gradient(
            180deg,
            rgba(37,99,235,.025),
            rgba(124,58,237,.025)
        );

    border:
        1px solid var(--border);

    border-radius: 16px;
}

.timeline-grid-line {
    position: absolute;

    top: 0;
    bottom: 0;

    width: 1px;

    background:
        rgba(0,0,0,.055);
}


/* =========================================================
   ENTRY BAR
   ========================================================= */

.timeline-entry-track {
    position: relative;

    width: 100%;
    height: 14px;

    margin: 5px 0;
}

.timeline-entry-track:first-of-type {
    margin-top: 10px;
}

.timeline-entry-bar {
    position: absolute;

    top: 2px;

    height: 10px;

    min-width: 5px;

    border-radius: 999px;

    background:
        linear-gradient(
            90deg,
            #3b82f6,
            #6366f1
        );

    box-shadow:
        0 3px 10px
        rgba(37,99,235,.16);

    cursor: pointer;

    transition:
        transform var(--transition),
        box-shadow var(--transition);
}

.timeline-entry-bar:hover {
    transform:
        scaleY(1.35);

    box-shadow:
        0 5px 16px
        rgba(37,99,235,.25);
}

.timeline-entry-bar.running {
    min-width: 10px;

    background: #16a34a;

    box-shadow:
        0 0 0 4px rgba(22,163,74,.10),
        0 4px 14px rgba(22,163,74,.22);

    animation: running-glow 1.8s ease-in-out infinite;
}

@keyframes running-glow {
    0%,
    100% {
        box-shadow:
            0 0 0 4px rgba(22,163,74,.08),
            0 4px 14px rgba(22,163,74,.18);
    }

    50% {
        box-shadow:
            0 0 0 7px rgba(22,163,74,.04),
            0 5px 18px rgba(22,163,74,.28);
    }
}




/* =========================================================
   ENTRY DETAILS
   ========================================================= */

.time-entry-details {
    display: flex;
    flex-wrap: wrap;

    gap: 8px;

    padding:
        4px
        24px
        20px;
}

.time-entry-detail {
    display: inline-flex;
    align-items: center;

    gap: 7px;

    padding:
        7px 10px;

    color: var(--text-secondary);

    background:
        rgba(255,255,255,.62);

    border:
        1px solid var(--border);

    border-radius: 10px;

    font-size: .72rem;
}

.time-entry-detail strong {
    color: var(--text);

    font-size: .74rem;
}

.time-entry-detail-dot {
    width: 7px;
    height: 7px;

    border-radius: 50%;

    background:
        var(--text-muted);
}

.time-entry-detail-dot.running {
    background:
        var(--success);
}


/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 800px) {

    .time-day-header {
        align-items: flex-start;
        flex-direction: column;

        gap: 16px;
    }

    .time-day-metrics {
        width: 100%;

        justify-content:
            space-between;

        gap: 10px;
    }

    .time-day-stat {
        min-width: 0;

        text-align: left;
    }

    .day-timeline {
        padding-left: 16px;
        padding-right: 16px;
    }

    .time-entry-details {
        padding-left: 16px;
        padding-right: 16px;
    }
}



/* =========================================================
   DAY SELECTOR / VIEW SWITCH
   ========================================================= */

.time-view-switch {
    padding: 12px;
}

.time-view-tabs {
    display: inline-flex;
    gap: 4px;

    padding: 4px;

    margin-bottom: 12px;

    background: rgba(0,0,0,.035);

    border-radius: 12px;
}

.time-view-tab {
    padding: 8px 14px;

    color: var(--text-secondary);

    text-decoration: none;

    border-radius: 9px;

    font-size: .78rem;
    font-weight: 650;

    transition:
        background var(--transition),
        color var(--transition),
        box-shadow var(--transition);
}

.time-view-tab.active {
    color: var(--text);

    background: white;

    box-shadow: var(--shadow-sm);
}

.day-selector-scroll {
    display: flex;
    gap: 7px;

    overflow-x: auto;

    padding:
        2px
        2px
        8px;

    scrollbar-width: thin;
}

.day-selector-item {
    min-width: 58px;
    height: 72px;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    flex: 0 0 auto;

    color: var(--text-secondary);

    text-decoration: none;

    border: 1px solid transparent;

    border-radius: 14px;

    transition:
        background var(--transition),
        border-color var(--transition),
        transform var(--transition),
        box-shadow var(--transition);
}

.day-selector-item:hover {
    background: rgba(255,255,255,.75);

    transform: translateY(-1px);
}

.day-selector-weekday {
    font-size: .66rem;

    color: var(--text-muted);
}

.day-selector-item strong {
    margin-top: 4px;

    font-size: 1rem;
}

.day-selector-item small {
    margin-top: 3px;

    color: var(--accent);

    font-size: .56rem;
    font-weight: 650;
}

.day-selector-item.today {
    border-color:
        rgba(37,99,235,.18);
}

.day-selector-item.active {
    color: white;

    background:
        linear-gradient(
            135deg,
            #2563eb,
            #6d4aff
        );

    box-shadow:
        0 8px 20px
        rgba(37,99,235,.20);
}

.day-selector-item.active .day-selector-weekday,
.day-selector-item.active small {
    color:
        rgba(255,255,255,.72);
}

.time-day-view {
    animation:
        page-enter
        .25s
        ease both;
}



/* =========================================================
   TIME EDIT MODAL
   ========================================================= */

.day-view-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 20px;
}

.time-modal-backdrop {
    position: fixed;
    inset: 0;

    z-index: 1000;

    display: grid;
    place-items: center;

    padding: 24px;

    background: rgba(20, 24, 32, .26);

    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.time-modal-backdrop[hidden] {
    display: none;
}

.time-modal {
    width: min(500px, 100%);

    padding: 24px;

    border-radius: 24px;

    box-shadow:
        0 30px 90px rgba(0,0,0,.20);

    animation:
        time-modal-enter
        .22s
        ease both;
}

@keyframes time-modal-enter {
    from {
        opacity: 0;
        transform:
            translateY(10px)
            scale(.98);
    }

    to {
        opacity: 1;
        transform:
            translateY(0)
            scale(1);
    }
}

.time-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;

    gap: 20px;

    margin-bottom: 24px;
}

.time-modal-header h3 {
    margin: 5px 0 0;

    font-size: 1.45rem;
    letter-spacing: -.035em;
}

.time-modal-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;

    gap: 14px;
}

.time-modal-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 12px;

    margin-top: 24px;
}

.time-modal-actions-right {
    display: flex;
    gap: 8px;
}

.time-modal-error {
    margin-top: 14px;

    padding: 11px 13px;

    color: var(--danger);

    background:
        rgba(220,38,38,.07);

    border:
        1px solid
        rgba(220,38,38,.15);

    border-radius: 10px;

    font-size: .78rem;
}

.time-delete-button {
    color: var(--danger);
}

.time-entry-detail-button {
    appearance: none;
    -webkit-appearance: none;

    font: inherit;

    margin: 0;

    cursor: pointer;
}

.time-entry-detail-button:hover {
    background: white;

    border-color: var(--border-strong);

    transform: translateY(-1px);
}

@media (max-width: 560px) {

    .time-modal-fields {
        grid-template-columns: 1fr;
    }

    .time-modal-actions {
        align-items: stretch;
        flex-direction: column-reverse;
    }

    .time-modal-actions-right {
        width: 100%;
    }

    .time-modal-actions-right .btn {
        flex: 1;
    }

    .time-delete-button {
        width: 100%;
    }
}



.timeline-entry-bar.continues-left::before {
    content: "◀";

    position: absolute;
    left: 4px;
    top: 50%;

    z-index: 2;

    transform: translateY(-50%);

    color: rgba(255,255,255,.95);

    font-size: 7px;
    line-height: 1;

    pointer-events: none;
}

.timeline-entry-bar.continues-right::after {
    content: "▶";

    position: absolute;
    right: 4px;
    top: 50%;

    z-index: 2;

    transform: translateY(-50%);

    color: rgba(255,255,255,.95);

    font-size: 7px;
    line-height: 1;

    pointer-events: none;
}

.timeline-entry-bar.continues-left,
.timeline-entry-bar.continues-right {
    min-width: 12px;
}


