/* ------------------------------------------------------------------
 * THEME: modern and simple - black text, white background, petrol
 * as the accent color (each employment has its own color). Bootstrap's colored
 * classes (success, warning, info, ...) are mapped onto this palette below,
 * so the templates can keep using the usual Bootstrap classes.
 * Errors and deleting use a dark wine red.
 * ------------------------------------------------------------------ */

:root {
    --accent: #0F5C6E;            /* petrol */
    --accent-dark: #0A4453;       /* hover / active */
    --accent-light: #E8F3F5;      /* light backgrounds */
    --accent-mid: #A5CCD5;
    --line: #E3E3E3;              /* thin borders */
    --red-delete: #6B1B1B;
    --red-day: #C8102E;           /* Saturdays, Sundays, public holidays */
    --green: #1B7F3B;             /* positive balance */
    --error-bg: #FDECEC;
    --error-line: #E8B4B4;
    --red-delete-dark: #4E1212;

    --bs-body-color: #000;
    --bs-body-color-rgb: 0, 0, 0;
    --bs-body-bg: #fff;
    --bs-secondary-color: #5F6368;
    --bs-primary: var(--accent);
    --bs-primary-rgb: 15, 92, 110;
    --bs-link-color: var(--accent);
    --bs-link-color-rgb: 15, 92, 110;
    --bs-link-hover-color: var(--accent-dark);
    --bs-link-hover-color-rgb: 10, 68, 83;
    --bs-border-color: var(--line);
    --bs-font-sans-serif: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: #fff;
    color: #000;
}

h1, h2, h3, h4, h5, .h1, .h2, .h3, .h4, .h5 {
    font-weight: 600;
    letter-spacing: -.01em;
}

a {
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.btn:hover, .nav-link:hover, .dropdown-item:hover, .calendar-entry:hover {
    text-decoration: none;
}

/* Navigation: white with a thin colored line */
.navbar, .navbar.bg-body-tertiary {
    background-color: #fff !important;
    border-bottom: 3px solid var(--accent) !important;
}

.navbar-brand {
    color: var(--accent) !important;
    font-weight: 600;
}

.navbar .nav-link {
    color: #000;
}

.navbar .nav-link.active {
    color: var(--accent) !important;
    font-weight: 600;
}

/* Cards and dialogs: no shadows, thin border */
.card, .modal-content {
    border: 1px solid var(--line);
    box-shadow: none !important;
}

.card-highlight {
    border-color: var(--accent-mid);
    background-color: var(--accent-light);
}

/* --- Buttons --- */

.btn-primary, .btn-success {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--accent);
    --bs-btn-border-color: var(--accent);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--accent-dark);
    --bs-btn-hover-border-color: var(--accent-dark);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--accent-dark);
    --bs-btn-active-border-color: var(--accent-dark);
    --bs-btn-disabled-bg: var(--accent);
    --bs-btn-disabled-border-color: var(--accent);
    --bs-btn-focus-shadow-rgb: 15, 92, 110;
}

.btn-outline-primary, .btn-outline-success {
    --bs-btn-color: var(--accent);
    --bs-btn-bg: #fff;
    --bs-btn-border-color: var(--accent);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--accent);
    --bs-btn-hover-border-color: var(--accent);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--accent-dark);
    --bs-btn-active-border-color: var(--accent-dark);
    --bs-btn-focus-shadow-rgb: 15, 92, 110;
}

.btn-danger {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--red-delete);
    --bs-btn-border-color: var(--red-delete);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: var(--red-delete-dark);
    --bs-btn-hover-border-color: var(--red-delete-dark);
    --bs-btn-active-bg: var(--red-delete-dark);
    --bs-btn-active-border-color: var(--red-delete-dark);
}

/* Neutral actions (e.g. "Abbrechen", "Abmelden"): black outline */
.btn-secondary, .btn-warning, .btn-outline-secondary, .btn-outline-dark {
    --bs-btn-color: #000;
    --bs-btn-bg: #fff;
    --bs-btn-border-color: #000;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #000;
    --bs-btn-hover-border-color: #000;
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: #333;
    --bs-btn-active-border-color: #333;
    --bs-btn-focus-shadow-rgb: 0, 0, 0;
}

.btn-link {
    --bs-btn-color: var(--accent);
    --bs-btn-hover-color: var(--accent-dark);
}

.link-danger, .btn-link.link-danger {
    color: var(--red-delete) !important;
}

/* --- Badges: colored, or white with a black outline --- */
.badge.text-bg-primary, .badge.text-bg-info, .badge.text-bg-success {
    color: #fff !important;
    background-color: var(--accent) !important;
}

.badge.text-bg-warning, .badge.text-bg-secondary, .badge.text-bg-danger, .badge.text-bg-light {
    color: #000 !important;
    background-color: #fff !important;
    border: 1px solid #000;
    font-weight: 500;
}

.badge.text-bg-light {
    border-color: var(--line);
    color: var(--bs-secondary-color) !important;
}

.badge {
    font-weight: 600;
}

.progress {
    background-color: #F1F1F1;
}

.progress-bar.bg-success {
    background-color: var(--accent) !important;
}

/* --- Messages --- */
.alert-info, .alert-success {
    --bs-alert-color: #000;
    --bs-alert-bg: var(--accent-light);
    --bs-alert-border-color: var(--accent-mid);
    --bs-alert-link-color: var(--accent);
}

.alert-danger {
    --bs-alert-color: #8A1414;
    --bs-alert-bg: #FDF1F1;
    --bs-alert-border-color: #E8B4B4;
}

.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 .2rem rgba(15, 92, 110, .2);
}

.form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}

.nav-tabs .nav-link.active {
    color: var(--accent);
    font-weight: 600;
}

.nav-tabs .nav-link {
    color: #000;
}

/* ------------------------------------------------------------------
 * LAYOUT
 * ------------------------------------------------------------------ */

#content {
    flex: 1;
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
}

/* Cards and forms use the full width on phones and stay narrow on larger screens. */
.card-narrow {
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
}

.card-wide {
    max-width: 960px;
    margin-left: auto;
    margin-right: auto;
}

.alert {
    max-width: 560px;
    margin: 0 auto 1rem auto;
    border-radius: .75rem;
}

.alert ul {
    margin-bottom: 0;
}

.sql-output {
    font-size: .85rem;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ------------------------------------------------------------------
 * CALENDAR (month)
 * ------------------------------------------------------------------ */

.calendar-head, .calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-head div {
    font-size: .8rem;
    font-weight: 600;
    text-align: center;
    padding: .25rem 0;
    border-bottom: 2px solid #000;
}

.calendar-day {
    min-height: 6.5rem;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    padding: .25rem;
    overflow: hidden;
}

.calendar-grid > .calendar-day:nth-child(7n+1) {
    border-left: 1px solid var(--line);
}

.calendar-weekend {
    background-color: #FAFAFA;
}

.calendar-outside {
    background-color: #F4F4F4;
}

.calendar-date {
    font-size: .8rem;
    color: var(--bs-secondary-color);
    text-align: right;
}

.calendar-weekday {
    display: none;
}

.calendar-today .calendar-date {
    color: var(--accent);
    font-weight: 700;
}

.calendar-today {
    box-shadow: inset 0 0 0 2px var(--accent);
}

.calendar-entry {
    display: block;
    font-size: .78rem;
    line-height: 1.25;
    color: #fff;
    background-color: var(--accent);
    border-radius: .3rem;
    padding: .2rem .3rem;
    margin-top: .2rem;
    overflow-wrap: anywhere;
}

.calendar-entry:hover {
    background-color: var(--accent-dark);
    color: #fff;
}

.calendar-time {
    font-weight: 600;
}

/* Phones: one day per line, days without entries are hidden */
@media (max-width: 767.98px) {
    .calendar-head {
        display: none;
    }
    .calendar-grid {
        display: block;
    }
    .calendar-day {
        min-height: 0;
        border: none !important;
        border-bottom: 1px solid var(--line) !important;
        display: flex;
        gap: .75rem;
        flex-wrap: wrap;
        padding: .5rem 0;
    }
    .calendar-empty, .calendar-outside {
        display: none;
    }
    .calendar-date {
        text-align: left;
        min-width: 3.5rem;
        font-size: .9rem;
    }
    .calendar-weekday {
        display: inline;
    }
    .calendar-entry {
        flex: 1 1 12rem;
        margin-top: 0;
        font-size: .85rem;
    }
    .calendar-weekend {
        background-color: transparent;
    }
}

/* ------------------------------------------------------------------
 * TIME RECORDING
 * ------------------------------------------------------------------ */

/* The employments: one color each, set per user (see \view\employment_styles()) */
.employment-mark {
    display: inline-block;
    width: .75rem;
    height: .75rem;
    border-radius: .2rem;
    background-color: var(--employment);
}

.calendar-entry.employment-1, .calendar-entry.employment-2 {
    background-color: var(--employment);
    color: var(--employment-text);
}

.calendar-entry.employment-1:hover, .calendar-entry.employment-2:hover {
    background-color: var(--employment-dark);
    color: var(--employment-text);
}

/* Only suggested: dashed */
.calendar-entry.calendar-suggested, .calendar-entry.calendar-suggested:hover {
    background-color: #fff;
    color: var(--employment, #000);
    border: 1px dashed var(--employment, #000);
}

.calendar-work, .calendar-work:hover {
    background-color: #444;
}

.calendar-absence, .calendar-absence:hover {
    background-color: #F1F1F1;
    color: #000;
}

.calendar-note, .calendar-sum {
    display: block;
    font-size: .7rem;
    line-height: 1.25;
    margin-top: .2rem;
    color: var(--bs-secondary-color);
}

.calendar-warning {
    color: var(--red-delete);
    font-weight: 600;
}

.calendar-date a {
    color: inherit;
}

.day-red, .day-red a, .calendar-today .calendar-date.day-red, .calendar-head div.day-red {
    color: var(--red-day);
}

.balance-minus {
    color: var(--red-day);
}

.balance-plus {
    color: var(--green);
}

/* Today in the overview of the days; the margin keeps it below the sticky navigation when jumping to it */
#heute {
    scroll-margin-top: 5rem;
}

.table-today > :first-child {
    box-shadow: inset 3px 0 0 var(--accent);
    font-weight: 700;
}

.table-month > * {
    background-color: var(--accent-light);
    color: var(--accent-dark);
    font-size: .9rem;
}

.table-weekend > * {
    background-color: #FAFAFA;
}

.time-field {
    min-width: 4.5rem;
}

.running-dot {
    display: inline-block;
    width: .7rem;
    height: .7rem;
    border-radius: 50%;
    background-color: var(--accent);
    animation: running 1.6s ease-in-out infinite;
}

@keyframes running {
    50% { opacity: .3; }
}

@media (prefers-reduced-motion: reduce) {
    .running-dot {
        animation: none;
    }
}

.stat-tile {
    border: 1px solid var(--line);
    border-radius: 1rem;
    padding: 1rem 1.25rem;
    height: 100%;
}

.stat-label {
    font-size: .85rem;
    color: var(--bs-secondary-color);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.stat-note {
    font-size: .75rem;
    color: var(--bs-secondary-color);
}

.task-text {
    white-space: pre-line;
    color: var(--bs-secondary-color);
}

.calendar-task {
    white-space: pre-line;
    overflow-wrap: anywhere;
}

/* Time errors: light red, stronger than the red of weekends and holidays */
.calendar-error {
    background-color: var(--error-bg);
    box-shadow: inset 3px 0 0 var(--red-day);
}

.table-error > * {
    background-color: var(--error-bg);
}

.error-box, .day-errors {
    background-color: var(--error-bg);
    border: 1px solid var(--error-line);
    border-radius: .75rem;
    padding: .75rem 1rem;
}

.day-errors {
    list-style: none;
    margin: 0 0 1rem;
    color: var(--red-delete);
    font-weight: 600;
}

/* Week: one line per day. Name, axis and numbers side by side; on phones the axis gets its own line */
.week-list {
    border-top: 2px solid #000;
}

.week-scale, .week-day {
    display: grid;
    grid-template-columns: 5.5rem minmax(0, 1fr) 8.5rem;
    column-gap: .75rem;
}

.week-scale {
    border-bottom: 1px solid var(--line);
}

.week-hours {
    grid-column: 2;
    position: relative;
    height: 1.2rem;
    font-size: .7rem;
    color: var(--bs-secondary-color);
}

.week-hours span {
    position: absolute;
    top: .15rem;
    transform: translateX(-50%);
}

.week-day {
    align-items: center;
    padding: .45rem .25rem;
    border-bottom: 1px solid var(--line);
    color: #000;
}

.week-day:hover {
    background-color: #FAFAFA;
    color: #000;
    text-decoration: none;
}

.week-name {
    grid-column: 1;
    grid-row: 1 / 3;
}

.week-track {
    grid-column: 2;
    grid-row: 1;
    display: block;
    background-color: #F4F4F4;
    border-radius: .25rem;
    overflow: hidden;
}

.week-lane {
    display: block;
    position: relative;
    height: .75rem;
}

.week-lane + .week-lane {
    height: 1.1rem;
}

.week-bar {
    position: absolute;
    top: 0;
    bottom: 0;
}

.week-normal {
    background-color: var(--employment);
    opacity: .3;
}

.week-core {
    background-image: repeating-linear-gradient(135deg, var(--employment) 0 3px, transparent 3px 6px);
    border-bottom: 2px solid var(--employment);
}

.week-work {
    background-color: var(--employment);
}

.week-unassigned {
    background-color: #444;
}

.week-suggested {
    background-color: transparent;
    border: 1.5px dashed var(--employment);
}

.week-note {
    grid-column: 2;
    grid-row: 2;
    font-size: .75rem;
    line-height: 1.2;
    margin-top: .2rem;
    color: var(--bs-secondary-color);
}

.week-note:empty {
    display: none;
}

.week-numbers {
    grid-column: 3;
    grid-row: 1 / 3;
    display: flex;
    justify-content: space-between;
    gap: .5rem;
    font-size: .85rem;
    font-variant-numeric: tabular-nums;
}

.week-today {
    box-shadow: inset 3px 0 0 var(--accent);
}

.week-error {
    background-color: var(--error-bg);
}

.week-free .week-track {
    display: none;
}

.week-free .week-name:not(.day-red) {
    color: var(--bs-secondary-color);
}

.week-free.week-day {
    padding-top: .2rem;
    padding-bottom: .2rem;
}

@media (max-width: 575.98px) {
    .week-scale, .week-day {
        grid-template-columns: minmax(0, 1fr) auto;
    }
    .week-hours {
        grid-column: 1 / 3;
    }
    .week-name {
        grid-column: 1;
        grid-row: 1;
    }
    .week-numbers {
        grid-column: 2;
        grid-row: 1;
    }
    .week-track {
        grid-column: 1 / 3;
        grid-row: 2;
        margin-top: .25rem;
    }
    .week-note {
        grid-column: 1 / 3;
        grid-row: 3;
    }
}

.free-period {
    border: 1px solid var(--line);
    border-radius: .5rem;
    padding: .4rem;
    margin-bottom: .5rem;
}

.month-box {
    background-color: var(--accent-light);
    border: 1px solid var(--accent-mid);
    border-radius: .75rem;
    padding: .75rem 1rem;
}

/* Time axis of a day */
.timeline-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .25rem;
}

.timeline-label {
    flex: 0 0 6.5rem;
    font-size: .75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.timeline-track, .timeline-hours {
    position: relative;
    flex: 1;
    height: 1rem;
}

.timeline-track {
    background-color: #F4F4F4;
    border-radius: .25rem;
    overflow: hidden;
}

.timeline-bar {
    position: absolute;
    top: 0;
    bottom: 0;
}

.timeline-normal {
    background-color: var(--employment);
    opacity: .35;
}

.timeline-core {
    background-color: var(--employment);
}

.timeline-work {
    background-color: #333;
}

.timeline-running {
    background-color: #888;
}

.timeline-hours {
    font-size: .65rem;
    color: var(--bs-secondary-color);
}

.timeline-hours span {
    position: absolute;
    transform: translateX(-50%);
}
