html, body { height: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: #f5f5f5; color: #111111; }

/* ============================================================================
   Shared mobile-first foundation (mirrors the public app): spacing/radius
   tokens, fluid typography, touch targets, media safety, and width utilities.
   Additive only — does not alter the monochrome admin button theme below.
   ============================================================================ */
:root {
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.12);

    --touch-target: 44px;
}

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overflow-wrap: break-word; }

h1, .h1 { font-size: clamp(1.5rem, 1.2rem + 1.6vw, 2rem); }
h2, .h2 { font-size: clamp(1.3rem, 1.1rem + 1.1vw, 1.6rem); }
h3, .h3 { font-size: clamp(1.15rem, 1.05rem + 0.6vw, 1.35rem); }

img, svg, video { max-width: 100%; height: auto; }

@media (hover: none) and (pointer: coarse) {
    .btn:not(.btn-sm):not(.btn-close):not(.btn-link),
    .form-control,
    .form-select {
        min-height: var(--touch-target);
    }

    .form-check-input {
        width: 1.25rem;
        height: 1.25rem;
    }
}

.max-w-sm, .max-w-md, .max-w-lg { width: 100%; }

@media (min-width: 576px) {
    .max-w-sm { max-width: 300px; }
    .max-w-md { max-width: 500px; }
    .max-w-lg { max-width: 600px; }
}

.card {
    border: 1px solid #e2e2e2;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card-body {
    padding: clamp(1rem, 0.7rem + 1.2vw, 1.75rem);
}

.alert {
    border-radius: var(--radius);
}

.alert > .bi:first-child,
.alert h5 > .bi:first-child {
    margin-right: 0.5rem;
}

.form-control,
.form-select {
    border-radius: var(--radius-sm);
}

.form-label {
    font-weight: 500;
}

/* ── Buttons: active = black, disabled = gray, never blue ── */
/* Redefine Bootstrap's button CSS variables so no blue is ever painted,
   including the split-second :active background and :focus ring. */
.btn-primary,
.btn-success,
.btn-info,
.btn-secondary,
.btn-outline-primary,
.btn-outline-secondary,
.btn-outline-success,
.btn-outline-info {
    --bs-btn-color: #fff;
    --bs-btn-bg: #111111;
    --bs-btn-border-color: #111111;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #000000;
    --bs-btn-hover-border-color: #000000;
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: #000000;
    --bs-btn-active-border-color: #000000;
    --bs-btn-focus-shadow-rgb: 17, 17, 17;
    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: #adadad;
    --bs-btn-disabled-border-color: #adadad;
}

.btn-primary,
.btn-success,
.btn-info,
.btn-secondary {
    color: #fff;
    background-color: #111111;
    border-color: #111111;
}

    .btn-primary:hover, .btn-primary:focus, .btn-primary:active, .btn-primary:focus-visible,
    .btn-primary:not(:disabled):not(.disabled):active,
    .btn-success:hover, .btn-success:focus, .btn-success:active, .btn-success:focus-visible,
    .btn-success:not(:disabled):not(.disabled):active,
    .btn-info:hover, .btn-info:focus, .btn-info:active, .btn-info:focus-visible,
    .btn-info:not(:disabled):not(.disabled):active,
    .btn-secondary:hover, .btn-secondary:focus, .btn-secondary:active, .btn-secondary:focus-visible,
    .btn-secondary:not(:disabled):not(.disabled):active {
        color: #fff;
        background-color: #000000;
        border-color: #000000;
        box-shadow: none;
    }

.btn-outline-primary,
.btn-outline-secondary,
.btn-outline-success,
.btn-outline-info {
    color: #111111;
    border-color: #111111;
    background-color: transparent;
}

    .btn-outline-primary:hover, .btn-outline-primary:active, .btn-outline-primary:focus-visible,
    .btn-outline-primary:not(:disabled):not(.disabled):active,
    .btn-outline-secondary:hover, .btn-outline-secondary:active, .btn-outline-secondary:focus-visible,
    .btn-outline-secondary:not(:disabled):not(.disabled):active,
    .btn-outline-success:hover, .btn-outline-success:active, .btn-outline-success:focus-visible,
    .btn-outline-success:not(:disabled):not(.disabled):active,
    .btn-outline-info:hover, .btn-outline-info:active, .btn-outline-info:focus-visible,
    .btn-outline-info:not(:disabled):not(.disabled):active {
        color: #fff;
        background-color: #111111;
        border-color: #111111;
        box-shadow: none;
    }

a, .btn-link {
    color: #111111;
}

    a:hover, .btn-link:hover {
        color: #000000;
    }

/* Inactive / disabled buttons are always gray, regardless of variant */
.btn-primary:disabled, .btn-primary.disabled,
.btn-success:disabled, .btn-success.disabled,
.btn-info:disabled, .btn-info.disabled,
.btn-secondary:disabled, .btn-secondary.disabled,
.btn-outline-primary:disabled, .btn-outline-primary.disabled,
.btn-outline-secondary:disabled, .btn-outline-secondary.disabled,
.btn-outline-success:disabled, .btn-outline-success.disabled,
.btn-outline-info:disabled, .btn-outline-info.disabled,
.btn:disabled, .btn.disabled {
    color: #ffffff;
    background-color: #adadad;
    border-color: #adadad;
    opacity: 1;
    cursor: not-allowed;
}

.btn:focus, .btn:active:focus, .btn:focus-visible, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #111111;
}

.form-control:focus, .form-select:focus {
    border-color: #111111;
    box-shadow: 0 0 0 0.2rem rgba(17, 17, 17, 0.18);
}

.form-check-input:checked {
    background-color: #111111;
    border-color: #111111;
}

.page {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: #111111;
    color: #fff;
}
.sidebar .brand { border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar .brand .brand-logo { height: 32px; width: auto; display: block; filter: invert(1) brightness(2); }
.sidebar .nav-link { color: rgba(255,255,255,.75); padding: .55rem .85rem; border-radius: .375rem; margin: .15rem 0; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.10); color: #fff; }
.sidebar .nav-link.active { background: #ffffff; color: #111111; font-weight: 600; }

main { display: flex; flex-direction: column; min-width: 0; }
.topbar { background: #fff; }
.content { flex: 1; }

/* Mobile nav toggle (hamburger) — hidden on desktop, shown in the topbar on
   small screens by the media query below. */
.nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: var(--touch-target);
    height: var(--touch-target);
    border: 1px solid #e2e2e2;
    border-radius: var(--radius-sm);
    background: #fff;
    color: #111111;
    font-size: 1.25rem;
    line-height: 1;
}

/* Backdrop shown behind the off-canvas drawer on mobile. */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1040;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0,0,0,0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

/* ── Responsive: collapse the sidebar into an off-canvas drawer ── */
@media (max-width: 768px) {
    .page {
        grid-template-columns: 1fr;
    }

    /* Show the hamburger in the topbar. */
    .nav-toggle {
        display: inline-flex;
    }

    /* Turn the sidebar into a slide-in drawer instead of hiding it, so the
       navigation stays reachable on phones. */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 260px;
        max-width: 82vw;
        z-index: 1050;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        overflow-y: auto;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-backdrop.show {
        display: block;
    }
}

/* ============================================================================
   Responsive "stacked" tables — add class="table-stack" to a <table> and a
   data-label attribute to each <td>. On desktop the table looks normal; on
   phones each row becomes a self-contained card with the data-label shown
   beside each value, so wide tables stay readable without horizontal scroll.
   ============================================================================ */
@media (max-width: 767.98px) {
    .table-stack thead {
        /* Hide the header row; labels come from each cell's data-label. */
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .table-stack,
    .table-stack tbody,
    .table-stack tr,
    .table-stack td {
        display: block;
        width: 100%;
    }

    .table-stack tr {
        border: 1px solid #e2e2e2;
        border-radius: var(--radius);
        box-shadow: var(--shadow-sm);
        background: #fff;
        padding: 0.5rem 0.75rem;
        margin-bottom: 0.75rem;
    }

    /* Neutralize striping so cards read cleanly. */
    .table-stack.table-striped > tbody > tr:nth-of-type(odd) > * {
        --bs-table-bg-type: transparent;
    }

    .table-stack td {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 1rem;
        text-align: right;
        border: 0;
        border-bottom: 1px solid #f0f0f0;
        padding: 0.4rem 0;
    }

    .table-stack td:last-child {
        border-bottom: 0;
    }

    .table-stack td::before {
        content: attr(data-label);
        font-weight: 600;
        text-align: left;
        color: #555;
        white-space: nowrap;
    }

    /* Cells with no label (e.g. an actions column) go full-width. */
    .table-stack td[data-label=""]::before,
    .table-stack td:not([data-label])::before {
        content: "";
    }

    .table-stack td[data-label=""],
    .table-stack td:not([data-label]) {
        justify-content: flex-end;
    }
}

/* ============================================================================
   Bookings grid: lock column widths so changing action buttons (spinner shown
   while saving, or the label changing as the status advances) never reflow the
   other columns. table-layout:fixed applies on desktop only; below 768px the
   .table-stack rules switch cells to display:block, which ignores table-layout.
   ============================================================================ */
.bookings-table {
    table-layout: fixed;
}

    .bookings-table th,
    .bookings-table td {
        overflow-wrap: anywhere;
    }

    /* Keep the action button on one line inside its fixed-width column. */
    .bookings-table td:last-child .btn {
        white-space: nowrap;
    }

@media (min-width: 768px) {
    /* With Date/Time/Duration/Client/Phone/Service/Address/Status(+action) columns,
       scroll horizontally inside .table-responsive on smaller desktops instead of
       cramming every column. Mobile (<768px) uses the stacked-card layout. */
    .bookings-table {
        min-width: 900px;
    }

    /* Center the fixed-width Date/Time/Duration columns (headers + values);
       all remaining headings stay left-justified. */
    .bookings-table thead th {
        text-align: left;
    }

    .bookings-table th:nth-child(-n + 3),
    .bookings-table td:nth-child(-n + 3) {
        text-align: center;
    }
}
