﻿/* === Base typography and layout === */
html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

a, .btn-link {
    color: #006bb7;
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.content {
    padding-top: 1.1rem;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC42NzgzIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDg2Ni4wNTQ3IDI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODc4OS43OTIxIDI2Ny4zODcgODcuMzAwNSAyNjYuMTE2IDg2LjA1NDcgMjYzLjU3NiA4Ni4wNTQ3WiIgZmlsbD0iI0ZGRTUwMCIgZmlsbC1ydWxlPSJldmVub2RkIi8+PC9nPjwvc3ZnPg==) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred.";
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

/* === TABLE LAYOUT & BEHAVIOR === */
thead th {
    position: relative;
    user-select: none;
    cursor: grab;
}

.drag-chosen {
    background: #f3f4f6;
    box-shadow: 0 2px 10px rgba(0,0,0,.08);
    border-radius: 8px;
}

.drag-ghost {
    opacity: .95;
    background: white;
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
    border-radius: 10px;
    outline: 2px solid #3b82f6;
}

.dragging {
    cursor: grabbing !important;
}

thead tr::after {
    content: "";
    position: absolute;
    height: 3px;
    left: 0;
    right: 0;
    bottom: -2px;
    background: transparent;
    transition: background .15s;
}

thead tr.sortable-placing::after {
    background: #3b82f6;
}

table {
    border-collapse: separate;
    border-spacing: 0;
}

thead th, tbody td {
    background: #fff;
}

thead th {
    padding: 10px 12px;
}

tbody td {
    padding: 1px 4px;
    border-top: 1px solid #e5e7eb;
}

table, th, td {
    box-sizing: border-box;
}

/* Lock widths (prevents drift) */
.table {
    table-layout: fixed;
    width: 100%;
}

/* === Variables === */
:root {
    --grip-w: 8px; /* app.css value overrides previous 8px */
    --grip-overlap: 4px;
    --no-drag-buffer: 3px;
    --action-w: 28px;
    --action-gap: 6px;
}

/* === Header & action: inline, wraps like text === */
th.th-head {
    position: relative;
}

    th.th-head .th-inner {
        display: flex;
        flex-flow: row wrap;
        align-items: center;
        gap: 4px 8px; /* row-gap, col-gap */
        box-sizing: border-box;
        width: 100%;
        padding-right: var(--grip-w); /* keep space for right grip */
        white-space: normal;
        overflow-wrap: anywhere;
        word-break: break-word;
        min-width: 0;
    }

        th.th-head .th-inner > span {
            flex: 1 1 auto; /* title can shrink/wrap */
            min-width: 0;
        }

    /* Inline action (delete) behaves like text, reveals on hover */
    th.th-head .th-action {
        position: static;
        transform: none;
        right: auto;
        top: auto;
        width: auto;
        height: auto;
        opacity: 0;
        pointer-events: none;
        padding: 2px 6px;
        line-height: 1.1;
        white-space: normal;
        flex: 0 0 auto;
    }

    th.th-head:hover .th-action {
        opacity: 1;
        pointer-events: auto;
    }

    th.th-head .th-action.remove {
        color: #b71c1c;
        margin-left: 6px;
    }

    th.th-head .th-action:hover {
        background: rgba(0,0,0,.06);
        border-radius: 6px;
        cursor: pointer;
    }

/* === Resizer Grip (single source of truth) === */
.__col_grip {
    width: var(--grip-w) !important;
    right: 0 !important;
}

/* === DRAGGING & RESIZING STATES === */
thead th.sortable-drag .th-inner,
thead th.dragging .th-inner {
    cursor: grabbing;
}

thead th.resizing .th-inner,
thead th.resizing .th-inner > span {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    color: inherit !important;
}

/* === Toggle Group Fix === */
.toggle-group-fix {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

    .toggle-group-fix .mud-toggle-item,
    .toggle-group-fix .mud-button-root {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .toggle-group-fix .editable-tag {
        white-space: nowrap;
    }

    .toggle-group-fix .mud-toggle-item:not(:last-child) .mud-button-root,
    .toggle-group-fix .mud-toggle-item:not(:last-child) {
        border-right: 0 !important;
    }

    .toggle-group-fix .mud-toggle-item .mud-button-root {
        box-shadow: none;
        background-clip: padding-box;
    }

    .toggle-group-fix .mud-toggle-item {
        vertical-align: middle;
    }

/* === Shared print/preview mode (non-interactive, identical layout) === */
.print-mode .th-action,
.print-mode .__col_grip,
.print-mode .col-grip {
    display: none !important;
}

/* Tight, no-gutter tables in print/preview */
.print-mode .table {
    border-collapse: collapse !important;
    border-spacing: 0 !important;
}

    .print-mode .table tbody td {
        text-align: center;
    }

.print-mode thead th {
    cursor: default;
    /* no grab cursor in preview/print */
}



/* Borders + tight padding for printing */
.print-mode th,
.print-mode td {
    border: 1px solid #444;
    padding: 0 1px !important; /* 1px left/right inner space */
    margin: 0 !important;
}

/* Remove stripes */
@media print {
    .table.table-striped tbody tr:nth-of-type(odd) {
        background: transparent !important;
    }
}

.print-mode .table.table-striped tbody tr:nth-of-type(odd) {
    background: transparent;
}

/* Keep header layout identical to planning */
.print-mode th.th-head .th-inner {
    display: flex;
    flex-flow: row wrap;
    align-items: center;
    gap: 4px 8px;
    padding-right: var(--grip-w, 14px);
    white-space: normal;
    box-sizing: border-box;
}

/* A4 landscape page for real printing */
@page {
    size: A4 landscape;
    margin: 4mm;
}

/* Preview frame that mimics A4 landscape on screen */
.print-preview-paper {
    width: 287mm; /* A4 297mm minus 2*5mm inner padding */
    height: 200mm; /* A4 210mm minus 2*5mm */
    margin: 0 auto;
    background: white;
    box-shadow: 0 2px 12px rgba(0,0,0,.15);
    overflow: hidden;
    position: relative;
    padding: 5mm; /* visual padding to mirror page margin feel */
}

/* We scale the inner content to fit exactly the width we want */
.print-content {
    transform-origin: top left;
}

/* Hide all app chrome on real print */
@media print {
    .no-print, .no-print * {
        display: none !important;
    }

    .print-preview-paper {
        width: auto;
        height: auto;
        box-shadow: none;
        padding: 0;
        margin: 0;
    }
}

/* Treat the table as a fixed 1600px canvas so relative widths match planning */
.print-content .table {
    width: 1600px; /* same baseline used in code-behind */
    table-layout: fixed;
}

/* Preview already sets transform via JS; just make sure origin is consistent */
.print-content {
    transform-origin: top left;
}

/* Scale at print time so the 1600px canvas fits the printable width */
@media print {
    .print-content {
        /* --print-scale is set right before printing in JS */
        transform: scale(var(--print-scale, 1));
        transform-origin: top left;
        width: 1600px; /* keep the canvas width the same before scaling */
    }
}

/* --- Force wrapping in preview/print so cells don't auto-grow --- */

/* Scope to preview/print only */
.print-mode .table th,
.print-mode .table td {
    white-space: normal !important; /* allow wrapping */
    overflow-wrap: anywhere !important; /* break long tokens */
    word-break: break-word !important; /* extra safety */
}

/* Header layout: allow the inner flex to wrap the label + alias, etc. */
.print-mode th.th-head .th-inner {
    display: flex;
    flex-flow: row wrap; /* can go to next line when tight */
    align-items: center;
    gap: 4px 8px;
    white-space: normal !important;
}

    /* The header label span itself must be wrappable */
    .print-mode th.th-head .th-inner > span {
        flex: 1 1 auto;
        min-width: 0;
        white-space: normal !important;
        overflow-wrap: anywhere !important;
        word-break: break-word !important;
    }

/* Data text wrapper in cells */
.print-mode .cell-text {
    display: inline-block; /* enables wrapping reliably inside TD */
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
}

/* Keep the 1600px baseline canvas, still allow wrap within columns */
.print-content .table {
    width: 1600px; /* baseline width (matches planning) */
    table-layout: fixed; /* widths come from header/calc; wrap within */
}

/* Optional: prevent insanely tall rows on single very long tokens */
.print-mode .table td {
    line-height: 1.2;
}

/* Ensure headers & cells wrap in preview/print */
.print-mode th,
.print-mode td,
.print-mode .cell-text,
.print-mode .th-inner > span {
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* --- DRAG BUBBLE / CHIP LOOK FOR HEADERS --- */
th.th-head {
    position: relative;
}

/* cursor & base state while waiting to drag */
thead th.th-head .th-inner {
    display: flex;
    align-items: center;
    gap: 0px;
    padding-right: var(--grip-w, 14px);
    box-sizing: border-box;
    user-select: none;
    cursor: grab;
}

/* When actually dragging (cover all class names our JS or Sortable may add) */
thead th.th-head.drag-chosen .th-inner,
thead th.th-head.drag-ghost .th-inner,
thead th.th-head.dragging .th-inner,
thead th.th-head.sortable-chosen .th-inner,
thead th.th-head.sortable-ghost .th-inner,
thead th.th-head.sortable-drag .th-inner {
    /* bubble chip visuals */
    padding: 6px calc(10px + var(--grip-w, 14px)) 6px 10px;
    border-radius: 9999px;
    background: var(--chip-bg, #eef4ff);
    border: 1px solid var(--chip-border, #c9d8ff);
    color: var(--chip-text, #0b3a82);
    box-shadow: 0 8px 24px rgba(0,0,0,.18);
    transform: translateZ(0);
    z-index: 1000; /* float above neighbors while dragging */
    cursor: grabbing;
}

/* Ghost clone styling (the element Sortable drags around) */
.drag-ghost,
thead th.th-head.sortable-ghost {
    opacity: .96;
    background: #fff;
    border-radius: 12px;
    outline: 2px solid #3b82f6;
    box-shadow: 0 12px 28px rgba(0,0,0,.22);
}

/* Chosen (original) header subtle highlight */
.drag-chosen,
thead th.th-head.sortable-chosen {
    background: #f5f7ff;
    box-shadow: 0 2px 10px rgba(0,0,0,.08);
    border-radius: 10px;
}

/* While dragging, keep the resizer/grip from interfering */
.drag-ghost .__col_grip,
thead th.th-head.sortable-ghost .__col_grip {
    display: none !important;
}

/* When resizing we keep things neutral (no bubble) */
thead th.th-head.resizing .th-inner,
thead th.th-head.resizing .th-inner > span {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    color: inherit !important;
}

/* Make sure the ghost has similar internal spacing as the bubble */
.drag-ghost .th-inner {
    padding: 6px calc(10px + var(--grip-w, 14px)) 6px 10px !important;
}

/* Nice blue placement underline while Sortable is figuring out position */
thead tr::after {
    content: "";
    position: absolute;
    height: 3px;
    left: 0;
    right: 0;
    bottom: -2px;
    background: transparent;
    transition: background .15s;
}

thead tr.sortable-placing::after {
    background: #3b82f6;
}

/* (The weird ${baseline} block from JS was ignored; left untouched functionally) */

.tile-view-card {
    min-width: 0;
    padding: 18px 8px;
    border-radius: 18px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    transition: box-shadow 0.2s, transform 0.15s;
}

    .tile-view-card:hover {
        box-shadow: 0 6px 24px rgba(0,0,0,0.16);
        transform: translateY(-4px) scale(1.03);
        background: #f5f7fa;
    }

.tile-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 24px;
}

@media (max-width: 1200px) {
    .tile-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 900px) {
    .tile-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .tile-grid {
        grid-template-columns: 1fr;
    }
}

.alt-table-container {
    width: 100%;
    max-width: 100vw;
    min-width: 0;
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
}

/* === Daily Planning view buttons: per-button borders + row spacing === */
.toggle-group-fix .mud-toggle-item {
    border: 1px solid rgba(0,0,0,0.18) !important;
    border-radius: 4px;
    box-shadow: none !important;
    margin: 2px 4px 2px 0; /* gap between buttons and between rows */
}

/* === Daily Planning: header container behavior === */
.toggle-group-fix {
    width: 100%;
    max-width: 100%;
    margin: 0;
}

.view-toolbar {
    display: flex;
    align-items: center;
    width: 100%;
}

.view-toolbar-left {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
}

.view-toolbar-right {
    margin-left: auto; /* pushes to the far right */
    display: flex;
    align-items: center;
}

/* Container that keeps selector + toolbar aligned to the same width, 
   left-aligned with max 1800px */
.view-header-container {
    max-width: 1800px;
    width: 100%;
    margin-left: 0;
    margin-right: auto;
    box-sizing: border-box;
}
