@import url('https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css');

html, body {
    font-family: 'Segoe UI', Helvetica, Arial, sans-serif;
}

/* ─── App shell — stacked (top bar + main) ──────────────────────────── */
.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ─── Top bar (NavMenu.razor) ─────────────────────────────────────────
   Slim header strip. Logo + brand on the left, auth/nav on the right.
   Replaces the old left sidebar. */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.6rem 1.5rem;
    background: #fff;
    border-bottom: 1px solid #dee2e6;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: #1f2d3d;
    font-weight: 600;
}
.topbar-brand:hover { color: #344b66; }
.topbar-logo {
    height: 34px;
    width: auto;
}
.topbar-brand-text {
    font-size: 1.05rem;
}
.topbar-nav {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}
.topbar-link {
    color: #495057;
    text-decoration: none;
    font-size: 0.95rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}
.topbar-link:hover { background: #f0f3f6; color: #1f2d3d; }
.topbar-link.active { color: #0d6efd; font-weight: 600; }
.topbar-user {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: #6c757d;
    font-size: 0.9rem;
}
.topbar-signout { margin: 0; }   /* the wrapping <form> shouldn't add space */

/* Hide the brand-text label on very narrow screens; the logo + button stay. */
@media (max-width: 520px) {
    .topbar-brand-text { display: none; }
}

/* Hide the up/down spin buttons on number inputs that opt in via .no-spinner.
   Apply to fields where the spinner is just visual noise (e.g. Width, Drop). */
.no-spinner::-webkit-outer-spin-button,
.no-spinner::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.no-spinner { -moz-appearance: textfield; appearance: textfield; }

/* Compact bordered fieldset used on the Roller tab for sub-sections (Motorisation,
   Blackout Details). Tightens padding, label spacing, and legend size so the
   group boxes stay short — Bootstrap defaults make them taller than we need.
   Extra left padding gives the first control room from the fieldset border. */
.compact-fieldset {
    padding: 0.25rem 0.5rem 0.4rem 1rem;
    margin-top: 0.5rem;
}
.compact-fieldset > legend {
    margin-bottom: 0.25rem;
    /* Match the surrounding `.form-label.small` text size, but bold so it still
       reads as a section header. */
    font-size: 0.875rem;
    font-weight: 700;
    padding: 0 0.4rem;
}
.compact-fieldset .form-label { margin-bottom: 0.15rem; }
.compact-fieldset .alert { padding: 0.25rem 0.5rem; }

/* Apply to a Bootstrap row when its labels should hug their controls more
   tightly than the Bootstrap default 0.5rem .form-label margin-bottom. Same
   value used inside compact-fieldset, so spacing stays consistent across
   sub-sections of the form. */
.tight-row .form-label { margin-bottom: 0.15rem; }

/* Opt-in compaction for forms heavy on short-text dropdowns / numbers, where
   the Bootstrap-grid column already gives plenty of width and the input
   itself only needs ~50% of that. Caps the visual width of inputs and selects
   to half their column. Multi-line text areas (e.g. Comments) opt out so
   they keep their normal width. Used on the Curtain Track tab. */
.compact-form-controls .form-control:not(textarea),
.compact-form-controls .form-select {
    max-width: 50%;
}

/* Roller-form labels are bold so the field names read clearly against the
   compressed control sizing. Covers the field labels inside the compact
   fieldsets, the labels inside the tight rows (Qty / Bracket rows), the
   form-check-label text next to checkboxes, and any standalone labels
   tagged with .roller-label (currently just the Comments row). */
.compact-fieldset .form-label,
.compact-fieldset .form-check-label,
.tight-row .form-label,
.roller-label {
    font-weight: 700;
}

/* Pale-yellow input highlight used to draw attention to an editable field
   while editing an existing record (e.g. the Roller Room/Location box).
   Keeps focus state legible: focus ring is unaffected, only the resting
   background colour changes. */
.input-edit-highlight,
.input-edit-highlight:focus {
    background-color: #fff8b0;
}

/* Curtain Track diagram editor modal. The project doesn't load bootstrap.bundle.js
   so we hand-roll the modal (backdrop + centred panel) here in pure CSS. Driven
   purely by Blazor's conditional rendering — the .diagram-modal element is added
   to the DOM only while the editor is open, no aria/tab-trap niceties needed
   for this internal tool. */
.diagram-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040;
}
.diagram-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 0.4rem;
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.3);
    z-index: 1041;
    padding: 1rem;
}
/* Wrapper that fabric.js inserts around the original <canvas> on init —
   we border this rather than the inner canvases (fabric stacks two of
   them: a lower static canvas + an upper canvas for selection events). */
.diagram-modal .canvas-container {
    border: 2px solid #6c757d;
    border-radius: 0.25rem;
    background:
        linear-gradient(45deg, #f0f0f0 25%, transparent 25%, transparent 75%, #f0f0f0 75%) 0 0 / 16px 16px,
        linear-gradient(45deg, #f0f0f0 25%, transparent 25%, transparent 75%, #f0f0f0 75%) 8px 8px / 16px 16px,
        #ffffff;
    display: inline-block;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.04);
}
/* Crosshair only when a shape tool is active — the JS sets / clears
   .defaultCursor on the fabric canvas which already drives this, but
   the underlying CSS keeps the default arrow sensible during Select mode. */
.diagram-modal canvas {
    display: block;
}
.diagram-toolbar {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}
.diagram-toolbar .btn.active {
    background-color: #0d6efd;
    color: #fff;
    border-color: #0d6efd;
}
.diagram-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

/* Page-level Bootstrap nav-tabs — readable on the white card background.
   Inactive tabs are mid-grey, hover slightly darker, active tab is dark on white. */
.nav-tabs .nav-link {
    color: #495057;
}
.nav-tabs .nav-link:hover {
    color: #212529;
    border-color: #e9ecef #e9ecef #dee2e6;
}
.nav-tabs .nav-link.active {
    color: #0d6efd;
    font-weight: 600;
    background-color: #fff;
    border-color: #dee2e6 #dee2e6 #fff;
}

.app-main {
    flex: 1;
    padding: 1.5rem 2rem;
    background: #f6f8fa;
}

/* ─── Landing page (Home.razor) ────────────────────────────────────────
   Used only on the root "/" route. Section block layout, no Bootstrap grid
   dependencies — pure flex + CSS grid so it stays readable on any width. */
.twt-hero {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 2rem 1.5rem;
    margin: -1.5rem -2rem 2rem;      /* bleed to the edges of main's padding */
    background: linear-gradient(135deg, #1f2d3d 0%, #344b66 100%);
    color: #fff;
    border-bottom: 4px solid #c9a86a;
}
.twt-hero-brand {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex: 1 1 auto;
    min-width: 0;
}
.twt-hero-brand .twt-logo {
    max-height: 80px;
    max-width: 180px;
    background: #fff;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.twt-hero-text h1 {
    margin: 0 0 0.25rem 0;
    font-size: 1.75rem;
    font-weight: 600;
    line-height: 1.2;
}
.twt-hero-text .twt-tagline {
    margin: 0;
    color: #cfd8e3;
    font-size: 1rem;
}
.twt-hero-cta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.4rem;
}
.twt-hero-cta .twt-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: #c9a86a;
    border-color: #c9a86a;
    color: #1f2d3d;
    font-weight: 600;
    padding: 0.6rem 1.4rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.twt-hero-cta .twt-cta:hover {
    background: #b69256;
    border-color: #b69256;
    color: #1f2d3d;
}
.twt-hero-cta .twt-signed-in {
    color: #cfd8e3 !important;     /* text-muted is too dark on the navy background */
    margin: 0;
}

.twt-section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1f2d3d;
    margin: 0 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e6e8eb;
}

.twt-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
}
.twt-product-card {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    display: flex;
    flex-direction: column;
}
.twt-product-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.08);
}
.twt-product-card > img {
    display: block;
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: #f0f3f6;       /* visible if the image fails to load */
}
.twt-product-body {
    padding: 0.85rem 1rem 1.1rem;
}
.twt-product-body h3 {
    margin: 0 0 0.35rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: #1f2d3d;
}
.twt-product-body p {
    margin: 0;
    font-size: 0.875rem;
    color: #4a5568;
    line-height: 1.4;
}

.twt-footer {
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px solid #e6e8eb;
    text-align: center;
}

#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;
}
