/* ── Design tokens ─────────────────────────────────────────── */
:root {
    --z-bg: #f4f6f9;
    --z-surface: #ffffff;
    --z-border: #dee2e6;
    --z-text: #1e293b;
    --z-text-muted: #64748b;
    --z-primary: #2563eb;
    --z-primary-hover: #1d4ed8;
    --z-radius: 0.5rem;
    --z-shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --z-shadow: 0 4px 6px rgba(0,0,0,.06), 0 2px 4px rgba(0,0,0,.04);
}

/* ── Base ──────────────────────────────────────────────────── */
html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--z-bg);
    color: var(--z-text);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--z-text);
}

h1:focus { outline: none; }

/* ── Links & buttons ───────────────────────────────────────── */
a, .btn-link {
    color: var(--z-primary);
}

.btn-primary {
    color: #fff;
    background-color: var(--z-primary);
    border-color: var(--z-primary);
}

.btn-primary:hover, .btn-primary:active {
    background-color: var(--z-primary-hover);
    border-color: var(--z-primary-hover);
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus,
.form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.2rem rgba(37,99,235,.25);
}

/* ── Content area ──────────────────────────────────────────── */
.content {
    padding-top: 1rem;
}

/* ── Page header ───────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.page-header h1 {
    margin: 0;
    font-size: 1.5rem;
}

/* ── Card panel (replaces alert-primary) ───────────────────── */
.z-card {
    background: var(--z-surface);
    border: 1px solid var(--z-border);
    border-radius: var(--z-radius);
    box-shadow: var(--z-shadow-sm);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

/* ── ManualStamp layout ────────────────────────────────────── */
.manualstamp-wrapper {
    min-width: 0;
}

.manualstamp-form {
    max-width: 550px;
    flex: 0 0 auto;
    min-width: 0;
    width: 100%;
}

.daily-summary-side-panel {
    flex: 0 0 auto;
    min-width: 0;
}

.daily-summary-card {
    min-width: 260px;
}

/* ── Statistics grid ───────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.stat-card {
    background: var(--z-surface);
    border: 1px solid var(--z-border);
    border-radius: var(--z-radius);
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.stat-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--z-text-muted);
}

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

/* ── Quick-select table ────────────────────────────────────── */
.quick-select-container {
    height: calc(100vh - 530px);
    min-height: 150px;
    overflow-y: auto;
}

.quick-select-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 0.875rem;
}

.quick-select-table th,
.quick-select-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--z-border);
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.quick-select-table tbody tr {
    cursor: pointer;
    transition: background 0.15s;
}

.quick-select-table tbody tr:hover {
    background: #f1f5f9;
}

.quick-select-table .MyHighlightClass {
    background: rgba(37,99,235,.08);
}

/* ── Report sections ───────────────────────────────────────── */
.report-day-header {
    font-weight: 600;
    padding: 0.5rem 0;
    border-bottom: 2px solid var(--z-border);
    margin-bottom: 0.25rem;
}

.report-day-summary {
    font-size: 0.85rem;
    color: var(--z-text-muted);
    padding-bottom: 0.5rem;
}

.report-table {
    table-layout: fixed;
}

/* Work report: Time | Project | Task | Ticket | Comment */
.report-table-work col:nth-child(1) { width: 10%; }
.report-table-work col:nth-child(2) { width: 15%; }
.report-table-work col:nth-child(3) { width: 15%; }
.report-table-work col:nth-child(4) { width: 25%; }
.report-table-work col:nth-child(5) { width: 35%; }

/* Daily / Monthly report: Decimal | Duration | Project | Task */
.report-table-summary col:nth-child(1) { width: 10%; }
.report-table-summary col:nth-child(2) { width: 15%; }
.report-table-summary col:nth-child(3) { width: 35%; }
.report-table-summary col:nth-child(4) { width: 40%; }

/* ── Validation ────────────────────────────────────────────── */
.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

/* ── Error boundary ────────────────────────────────────────── */
.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) 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;
}

/* ── Toast notification (fully opaque background) ──────────── */
.toast {
    --bs-toast-bg: #fff;
    opacity: 1 !important;
}

/* ── Responsive helpers ────────────────────────────────────── */
@media (max-width: 767.98px) {
    .page-header h1 {
        font-size: 1.25rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .z-card {
        padding: 1rem;
    }

    /* ── ManualStamp mobile ─────────────────────────────────── */
    .manualstamp-form {
        max-width: 100%;
        flex: 1 1 100%;
    }

    .daily-summary-side-panel {
        width: 100%;
        flex: 1 1 100%;
    }

    .daily-summary-card {
        min-width: 0;
        width: 100%;
    }

    /* ── Mobile card-list for quick-select ─────────────────── */
    .quick-select-table,
    .quick-select-table thead,
    .quick-select-table tbody,
    .quick-select-table tr,
    .quick-select-table td {
        display: block;
    }

    .quick-select-table thead {
        display: none;
    }

    .quick-select-table tbody tr {
        background: var(--z-surface);
        border: 1px solid var(--z-border);
        border-radius: var(--z-radius);
        padding: 0.75rem;
        margin-bottom: 0.5rem;
        box-shadow: var(--z-shadow-sm);
    }

    .quick-select-table td {
        padding: 0.15rem 0;
        border-bottom: none;
    }

    .quick-select-table td:first-child {
        font-weight: 600;
        font-size: 0.9rem;
    }

    .quick-select-table td:last-child {
        color: var(--z-text-muted);
        font-size: 0.8rem;
    }

    /* ── Mobile card-list for report tables ────────────────── */
    .report-card-list .table,
    .report-card-list .table thead,
    .report-card-list .table tbody,
    .report-card-list .table tr,
    .report-card-list .table td {
        display: block;
    }

    .report-card-list .table thead {
        display: none;
    }

    .report-card-list .table tbody tr {
        background: var(--z-surface);
        border: 1px solid var(--z-border);
        border-radius: var(--z-radius);
        padding: 0.625rem 0.75rem;
        margin-bottom: 0.5rem;
        box-shadow: var(--z-shadow-sm);
    }

    .report-card-list .table td {
        padding: 0.1rem 0;
        border-bottom: none;
    }

    .report-card-list .table td:first-child {
        font-weight: 600;
    }
}

/* ── Edit card list (mobile) ──────────────────────────────── */

/* ── Edit grid fill-to-viewport (desktop) ─────────────────── */
.edit-grid-fill {
    /* Normal block container — let BB Grid flow naturally */
}

/* Constrain only the scrollable table area; pagination sits below it in normal flow */
.edit-grid-fill .table-responsive {
    max-height: calc(100vh - 520px);
    min-height: 200px;
    overflow-y: auto;
}

/* Sticky column headers inside the scroll area */
.edit-grid-fill thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--z-surface);
}

/* Pagination row: stick to viewport bottom while page-scrolling */
.edit-grid-fill .table-responsive ~ * {
    position: sticky;
    bottom: 0;
    z-index: 2;
    background: var(--z-surface);
    border-top: 1px solid var(--z-border);
    padding-top: 0.25rem;
}

.edit-card-list {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.edit-card {
    background: var(--z-surface);
    border: 1px solid var(--z-border);
    border-radius: var(--z-radius);
    box-shadow: var(--z-shadow-sm);
    overflow: hidden;
}

.edit-card--deleted {
    opacity: 0.55;
    border-color: #dc3545;
}

.edit-card--new {
    border-color: #0dcaf0;
}

.edit-card--modified {
    border-color: #ffc107;
}

.edit-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: #f8f9fa;
    border-bottom: 1px solid var(--z-border);
}

.edit-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
}

.edit-card-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--z-text-muted);
    margin-bottom: 0.15rem;
}
