/* Application styles and design tokens. */

:root {
    --ap-accent-red: #cc0000;
    --ap-accent-red-dark: #990000;
    --ap-white: #ffffff;
    --ap-grey-96: #eff0f4;
    --ap-grey-90: #dfe0e6;
    --ap-grey-80: #c4c5cc;
    --ap-grey-70: #a9aab2;
    --ap-grey-60: #909299;
    --ap-grey-50: #777980;
    --ap-grey-40: #5d5e66;
    --ap-grey-30: #43444b;
    --ap-grey-18: #28292e;
    --ap-grey-12: #181a1e;
    --ap-ru: 0.5rem;
    --ap-font-desktop: "Roboto", sans-serif;
    --ap-font-embedded: "Nimbus Sans Novus", sans-serif;
    --ap-icon-size: 24px;
    --ap-icon-live-area: 20px;
    --ap-icon-stroke: 2px;
    --ap-signal-error: #ff001a;
    --ap-signal-success: #32b46e;
    --ap-signal-warning: #ff9b00;
    --ap-signal-info: #2b78c4;
    --ap-radius: 4px;
}

html, body {
    font-family: var(--ap-font-desktop);
    color: var(--ap-grey-18);
    background-color: var(--ap-grey-96);
}

h1, h2, h3, h4 {
    font-weight: 500;
    color: var(--ap-grey-18);
}

.ap-toast {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1080;
    width: min(28rem, calc(100vw - 2rem));
    margin: 0;
    box-shadow: 0 0.5rem 1.25rem rgb(0 0 0 / 18%);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}

a, .btn-link {
    color: var(--ap-signal-info);
}

a:hover {
    color: var(--ap-accent-red);
}

/* Buttons */
.btn-primary {
    color: var(--ap-white);
    background-color: var(--ap-accent-red);
    border-color: var(--ap-accent-red);
}

.btn-primary:hover, .btn-primary:active, .btn-primary:focus {
    background-color: var(--ap-accent-red-dark);
    border-color: var(--ap-accent-red-dark);
}

.btn-outline-secondary {
    color: var(--ap-grey-30);
    border-color: var(--ap-grey-70);
}

.btn:focus-visible, .form-control:focus, .form-select:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem var(--ap-white), 0 0 0 0.25rem var(--ap-signal-info);
    outline: none;
}

:focus-visible {
    outline: 2px solid var(--ap-signal-info);
    outline-offset: 1px;
}

/* Cards and surfaces */
.ap-card {
    background: var(--ap-white);
    border: 1px solid var(--ap-grey-90);
    border-radius: var(--ap-radius);
    padding: calc(var(--ap-ru) * 2);
}

.content {
    padding-top: 1.1rem;
}

/* Status badges */
.ap-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.5rem;
    border-radius: var(--ap-radius);
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
    max-width: 100%;
}

.ap-badge__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ap-badge--office { background: var(--ap-grey-90); color: var(--ap-grey-18); }
.ap-badge--homeoffice { background: #d8ecfb; color: #10507f; }
.ap-badge--vacation { background: #fff0d6; color: #8a5600; }
.ap-badge--sick { background: #fde0e0; color: #9a1b1b; }
.ap-badge--priority { background: #eadcff; color: #5c2b82; }
.ap-badge--parental-leave { background: #dff3e5; color: #176b3a; }
.ap-badge--special-situation { background: #e7e9ff; color: #3f468f; }

.ap-status-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    align-items: center;
    margin-bottom: 1rem;
    color: var(--ap-grey-30);
    font-size: 0.8rem;
}

.ap-status-legend__item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
}

.ap-status-legend__swatch {
    width: 0.8rem;
    height: 0.8rem;
    border-radius: 50%;
}

.ap-status-legend__swatch--homeoffice { background: #d8ecfb; border: 1px solid #10507f; }
.ap-status-legend__swatch--vacation { background: #fff0d6; border: 1px solid #8a5600; }
.ap-status-legend__swatch--sick { background: #fde0e0; border: 1px solid #9a1b1b; }
.ap-status-legend__swatch--priority { background: #eadcff; border: 1px solid #5c2b82; }
.ap-status-legend__swatch--parental-leave { background: #dff3e5; border: 1px solid #176b3a; }
.ap-status-legend__swatch--special-situation { background: #e7e9ff; border: 1px solid #3f468f; }

/* Capacity cells */
.ap-capacity {
    display: flex;
    flex-direction: column;
    min-height: 5.2rem;
    border: 1px solid var(--ap-grey-90);
    border-radius: var(--ap-radius);
    background: var(--ap-white);
    padding: calc(var(--ap-ru));
    text-align: center;
}

/* Planning board: equal-width day columns regardless of content */
.ap-board-table {
    table-layout: fixed;
    width: 100%;
}

.ap-board-table th,
.ap-board-table td {
    min-width: 10rem;
    vertical-align: top;
}

.ap-board-status-cell {
    min-height: 4rem;
}

.ap-board-week + .ap-board-week {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--ap-grey-90);
}

.ap-board-week__title {
    color: var(--ap-grey-50);
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.ap-status-card {
    display: flex;
    align-items: center;
    min-width: 0;
    min-height: 1.8rem;
    margin-bottom: 0.3rem;
    padding: 0.15rem 0.25rem;
    border-radius: var(--ap-radius);
    background: var(--ap-white);
}

.ap-status-card:last-child {
    margin-bottom: 0;
}

.ap-status-card--supervisor {
    margin-top: 0.25rem;
    padding-top: 0.35rem;
    border-top: 1px solid var(--ap-grey-80);
    background: var(--ap-grey-96);
}

.ap-status-card--current {
    border-left: 3px solid var(--ap-signal-info);
    background: rgb(43 120 196 / 8%);
}

/* Department calendar matrix (members × days) */
.ap-calendar__member {
    text-align: left;
    white-space: nowrap;
    min-width: 12rem;
}

.ap-calendar {
    table-layout: fixed;
    width: 100%;
}

.ap-calendar__member-column {
    width: 12rem;
}

.ap-calendar__day-column {
    width: auto;
}

.ap-calendar td .ap-badge {
    font-size: 0.7rem;
    padding: 0.1rem 0.35rem;
}

.ap-calendar th:not(.ap-calendar__member),
.ap-calendar td:not(:first-child) {
    min-width: 0;
}

.ap-calendar-week + .ap-calendar-week {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--ap-grey-90);
}

.ap-calendar-week__title {
    color: var(--ap-grey-50);
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.ap-calendar .ap-capacity {
    min-width: 5.5rem;
    padding: 0.35rem;
}

.ap-calendar .ap-capacity__reason {
    max-width: 10rem;
    margin-inline: auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ap-calendar .ap-capacity__reason--blocked {
    max-width: none;
    margin-inline: -0.5rem;
}

/* Admin proxy booking: clickable calendar cells. */
.ap-cell-toggle {
    border: none;
    cursor: pointer;
    font-size: 0.7rem;
    line-height: 1.2;
    padding: 0.1rem 0.4rem;
    border-radius: var(--ap-radius);
}

.ap-cell-toggle:hover {
    outline: 1px solid var(--ap-signal-info);
}

.ap-cell-book {
    background: transparent;
    color: var(--ap-grey-60);
    min-width: 1.6rem;
    font-weight: 700;
}

.ap-cell-book:hover {
    background: #d8ecfb;
    color: #10507f;
    outline: none;
}

/* Clickable calendar cells: group the home office / sick controls side by side. */
.ap-cell-actions {
    display: inline-flex;
    gap: 0.2rem;
    justify-content: center;
    flex-wrap: nowrap;
}

.ap-cell-sick {
    background: transparent;
    color: #9a1b1b;
    border: 1px dashed #e0a0a0;
    font-weight: 600;
}

.ap-cell-sick:hover {
    background: #fde0e0;
    color: #9a1b1b;
    outline: none;
}

.ap-cell-vac {
    background: transparent;
    color: #8a5600;
    border: 1px dashed #e0c48a;
    font-weight: 600;
}

.ap-cell-vac:hover {
    background: #fff0d6;
    color: #8a5600;
    outline: none;
}

/* Manual slot-block reason shown under a capacity cell. */
.ap-capacity__reason {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    min-width: 0;
    margin-top: auto;
    padding-top: 0.3rem;
    border-top: 1px solid var(--ap-grey-90);
    font-size: 0.7rem;
    color: var(--ap-signal-error);
    line-height: 1.2;
}

.ap-capacity__reason--blocked {
    align-self: stretch;
    width: calc(100% + 1rem);
    background: #fde0e0;
    border-top-color: #f2a6a6;
    margin-inline: -0.5rem;
    margin-bottom: -0.5rem;
    padding: 0.3rem 0.5rem 0.5rem;
    border-radius: 0 0 var(--ap-radius) var(--ap-radius);
}

.ap-capacity__reason-label {
    flex: 0 0 auto;
    font-weight: 700;
}

.ap-capacity__reason-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ap-week-section + .ap-week-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--ap-grey-90);
}

.ap-week-section__title {
    color: var(--ap-grey-50);
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.ap-week-nav .btn {
    min-width: 2.25rem;
    min-height: 2rem;
    padding: 0.1rem 0.45rem;
    font-size: 1.35rem;
    line-height: 1;
}

/* The supervisor is irrelevant to the planning numbers: set apart and pinned to the bottom. */
.ap-calendar__supervisor {
    border-top: 2px solid var(--ap-accent-red);
    background-color: var(--ap-grey-96);
}

.ap-calendar__supervisor .ap-calendar__member {
    font-style: italic;
}

.ap-capacity--free { border-left: 4px solid var(--ap-signal-success); }
.ap-capacity--full { border-left: 4px solid var(--ap-grey-60); }
.ap-capacity--over { border-left: 4px solid var(--ap-signal-error); }
.ap-capacity--blocked { border-left: 4px solid var(--ap-signal-error); }

.ap-capacity__count { font-size: 1.25rem; font-weight: 700; }
.ap-capacity__label { font-size: 0.75rem; color: var(--ap-grey-50); }

/* Tables */
.table thead th {
    background: var(--ap-grey-96);
    color: var(--ap-grey-30);
    font-weight: 500;
    border-bottom: 2px solid var(--ap-grey-80);
}

/* Validation */
.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--ap-signal-success);
}

.invalid {
    outline: 1px solid var(--ap-signal-error);
}

.validation-message {
    color: var(--ap-signal-error);
}

h1:focus {
    outline: none;
}

.blazor-error-boundary {
    background: var(--ap-accent-red-dark);
    padding: 1rem;
    color: var(--ap-white);
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

.darker-border-checkbox.form-check-input {
    border-color: var(--ap-grey-60);
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* KPI cards */
.ap-kpi {
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.ap-kpi__value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--ap-grey-18);
}

.ap-kpi__label {
    font-size: 0.8rem;
    color: var(--ap-grey-50);
    margin-top: 0.25rem;
}

/* Bar chart (horizontal, CSS bars) */
.ap-chart__axis { margin-bottom: 0.5rem; }

.ap-bars {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.ap-bars__row {
    display: grid;
    grid-template-columns: minmax(6rem, 11rem) 1fr auto;
    align-items: center;
    gap: 0.5rem;
}

.ap-bars__label {
    font-size: 0.85rem;
    color: var(--ap-grey-30);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ap-bars__track {
    background: var(--ap-grey-96);
    border-radius: var(--ap-radius);
    overflow: hidden;
    height: 1.1rem;
}

.ap-bars__fill {
    display: block;
    height: 100%;
    min-width: 2px;
    border-radius: var(--ap-radius);
    transition: width 0.3s ease;
}

.ap-bars__value {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--ap-grey-30);
    min-width: 2ch;
    text-align: right;
}

/* Pie chart (SVG + legend) */
.ap-pie {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.25rem;
}

.ap-pie__svg {
    width: 180px;
    height: 180px;
    flex: 0 0 auto;
}

.ap-pie__legend {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1 1 12rem;
    min-width: 12rem;
}

.ap-pie__legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    padding: 0.15rem 0;
}

.ap-pie__swatch {
    flex: 0 0 auto;
    width: 0.85rem;
    height: 0.85rem;
    border-radius: 2px;
}

.ap-pie__legend-label {
    color: var(--ap-grey-30);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ap-pie__legend-value {
    margin-left: auto;
    color: var(--ap-grey-50);
    white-space: nowrap;
}

/* Responsive refinements. Desktop layout remains unchanged above the mobile breakpoint. */
@media (max-width: 640.98px) {
    html,
    body {
        overflow-x: hidden;
    }

    .content {
        padding: 0.65rem 0.6rem 1.25rem !important;
    }

    h1 {
        font-size: 1.45rem;
        margin-bottom: 0.7rem;
    }

    .ap-card {
        padding: 0.7rem;
    }

    .ap-status-legend {
        gap: 0.55rem 0.9rem;
        margin-bottom: 0.85rem;
    }

    .ap-week-nav {
        display: flex;
        width: 100%;
    }

    .ap-week-nav .btn {
        flex: 1 1 0;
        min-height: 2.35rem;
        white-space: nowrap;
    }

    .table-responsive {
        position: relative;
        margin-inline: -0.2rem;
        padding-inline: 0.2rem;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .ap-board-table,
    .ap-calendar {
        min-width: 34rem;
        font-size: 0.85rem;
    }

    .ap-board-table th,
    .ap-board-table td {
        min-width: 7rem;
    }

    .ap-calendar__member {
        min-width: 9rem;
    }

    .ap-calendar th:not(.ap-calendar__member),
    .ap-calendar td:not(:first-child) {
        min-width: 6.25rem;
    }

    .ap-capacity {
        min-height: 4.6rem;
        padding: 0.35rem;
    }

    .ap-capacity__reason {
        align-items: flex-start;
        flex-wrap: wrap;
    }

    .ap-capacity__reason-text {
        flex-basis: 100%;
        padding-left: 1.25rem;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
    }

    .ap-bars__row {
        grid-template-columns: minmax(5.5rem, 8rem) 1fr auto;
        gap: 0.35rem;
    }

    .ap-bars__label,
    .ap-bars__value {
        font-size: 0.78rem;
    }

    .ap-pie {
        align-items: flex-start;
        gap: 0.85rem;
    }

    .ap-pie__svg {
        width: 140px;
        height: 140px;
    }

    .ap-pie__legend {
        min-width: 0;
    }

    .form-control,
    .form-select,
    .btn {
        min-height: 2.35rem;
        font-size: 0.9rem;
    }

    .btn-sm {
        min-height: 2.15rem;
    }

    .ap-cell-toggle {
        min-width: 2.35rem;
        min-height: 2.35rem;
        padding: 0.25rem 0.35rem;
        font-size: 0.68rem;
    }

    .ap-cell-actions {
        gap: 0.25rem;
    }

    .ap-toast {
        top: 4.25rem;
        right: 0.5rem;
        left: 0.5rem;
        width: auto;
    }
}
