/* =============================================
   WESTAY SRC — LAYOUT SYSTEM
   App shell, grid, content zones, page patterns.
   ============================================= */


/* ===================
   APP SHELL
   Three-panel floating architecture.
   Topbar + Sidebar + Content Area.
   =================== */

.app-shell {
    margin-left: calc(var(--src-sidebar-width) + var(--src-floating-gap) * 2);
    padding: var(--src-floating-gap);
    min-height: 100vh;
}

.app-content {
    display: flex;
    flex-direction: column;
    gap: var(--src-floating-gap);
    min-height: calc(100vh - var(--src-floating-gap) * 2);
}


/* ===================
   FULL-VIEWPORT APP PAGES — body.app-viewport
   The root owns the viewport; every layer below inherits its height from its
   parent via flex distribution. No viewport arithmetic anywhere in the chain:
   a number may style the component that owns it; no component computes its
   geometry from another component's number (Martin's rule, 2026-07-20 —
   replaces the calc(100vh - topbar - gaps*N) approach, which silently broke
   whenever an ancestor's real size diverged from the mirrored constants).
   Opt-in per page via $layout->appViewport. 100dvh tracks the dynamic mobile
   viewport (URL bar collapse) where 100vh does not.
   =================== */
body.app-viewport {
    height: 100dvh;
    overflow: hidden;
}
body.app-viewport .app-shell {
    height: 100%;
    min-height: 0;
    box-sizing: border-box;
}
body.app-viewport .app-content {
    height: 100%;
    min-height: 0;
}
body.app-viewport .topbar {
    flex-shrink: 0; /* the bar keeps its natural height; content flexes below */
}
body.app-viewport .content-area {
    min-height: 0; /* completes the chain — .content-area is already flex: 1 */
}
@media (max-width: 900px) {
    /* Client pages collapse to single-column document flow below 900px —
       release the viewport lock so the page scrolls natively again. */
    body.app-viewport,
    body.app-viewport .app-shell,
    body.app-viewport .app-content {
        height: auto;
        overflow: visible;
    }
}

/* ===================
   CONTENT AREA
   Glass panel for main content.
   =================== */

.content-area {
    flex: 1;
    padding: var(--src-space-8);
    width: 100%;
    /* Warm frosted — every central panel carries the same warm surface
       (was per-module overrides in travel/leadgen/roster; owned here now) */
    background: var(--src-surface-glass-warm);
    /* Blur is affordable here because the only thing beneath is the FIXED
       backdrop (base.css) — a static texture, not moving content.
       DESIGN.md specs blur(24px) on the content container; it was `none`
       while the page behind was a flat gradient and blur had no effect. */
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: var(--src-radius-structural);
    border: 1px solid var(--src-border-warm);
    box-shadow:
        0 8px 24px rgba(2, 36, 60, 0.12),
        0 2px 4px rgba(2, 36, 60, 0.15),
        inset 0 2px 0 rgba(255, 255, 255, 1);
    position: relative;
    transition: margin-right var(--src-transition-panel);
}

.content-area.panel-open {
    margin-right: calc(var(--src-panel-width) + var(--src-floating-gap));
}

/* Content is fluid by default — no page-level width cap. Layouts fill the
   viewport and adapt to every screen size. `.content-area--fluid` is retired
   (fluid is now the default) and kept as a no-op so any legacy template still
   carrying the class is harmless. Long-form text readability is constrained at
   the TEXT BLOCK via `.prose`, never at the page/content container. */
.content-area--fluid {
    /* no-op: fluid is the default */
}

/* Readability layer: cap long-form prose to a comfortable line length on the
   text element ONLY (~72ch). Apply to multi-paragraph reading content; tables,
   grids, cards, dashboards and forms stay full-width. */
.prose {
    max-width: 72ch;
}


/* ===================
   PAGE HEADER
   =================== */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--src-space-4);
    padding-bottom: var(--src-space-4);
    border-bottom: 1px solid var(--src-divider);
    margin-bottom: var(--src-space-3);
}

.page-header-left {
    flex: 1;
    min-width: 0;
}

.page-title {
    font-family: var(--src-font-body);
    font-size: 22px;
    font-weight: var(--src-weight-medium);
    color: var(--src-text-primary);
    line-height: var(--src-leading-tight);
    letter-spacing: -0.01em;
    margin-bottom: var(--src-space-1);
}

.page-subtitle {
    font-size: var(--src-text-sm);
    color: var(--src-text-tertiary);
}

/* Header-zone actions are a FLEET — the same track-and-pill grammar as
   .page-tabs. The grey track is what gives a pill its lift: a lone action
   gets it from a one-pill track; multiple actions share one track, never
   separate floating buttons. Navy emphasis belongs to a page's in-content
   key action, never to the chrome. */
.page-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 4px;
    background: var(--src-gray-50);
    border: 1px solid var(--src-border-subtle);
    border-radius: var(--src-radius-secondary);
    flex-shrink: 0;
}

.page-header-actions .btn {
    background: var(--src-surface-solid);
    color: var(--src-text-heading);
    border: 1px solid var(--src-border-subtle);
    border-radius: calc(var(--src-radius-secondary) - 2px);
    box-shadow: var(--src-shadow-1);
    padding: 8px 14px;
    min-height: 0;
    gap: 6px;
    font-size: var(--src-text-sm);
    font-weight: var(--src-weight-semibold);
}

.page-header-actions .btn:hover {
    background: var(--src-surface-solid);
    color: var(--src-text-heading);
    border-color: var(--src-border-medium);
}


/* ===================
   PAGE TABS
   Pill-track tab strip — the single intra-module navigation component.
   Renders inside .page-header, opposite the title, above the divider.
   All pages share this; no module invents its own tab design.
   =================== */

.page-tabs {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 4px;
    background: var(--src-gray-50);
    border: 1px solid var(--src-border-subtle);
    border-radius: var(--src-radius-secondary);
    flex-shrink: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--src-gray-300) transparent;
}

.page-tabs::-webkit-scrollbar {
    height: 4px;
}

.page-tabs::-webkit-scrollbar-track {
    background: transparent;
}

.page-tabs::-webkit-scrollbar-thumb {
    background-color: var(--src-gray-300);
    border-radius: var(--src-radius-pill);
}

.page-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: var(--src-text-sm);
    font-weight: var(--src-weight-medium);
    color: var(--src-text-secondary);
    text-decoration: none;
    border-radius: calc(var(--src-radius-secondary) - 2px);
    white-space: nowrap;
    cursor: pointer;
    transition: all var(--src-transition-state);
    border: 1px solid transparent;
    line-height: var(--src-leading-tight);
}

.page-tab:hover {
    color: var(--src-text-primary);
    background: var(--src-surface-solid);
}

.page-tab--active {
    color: var(--src-text-heading);
    background: var(--src-surface-solid);
    font-weight: var(--src-weight-semibold);
    border-color: var(--src-border-subtle);
    box-shadow: var(--src-shadow-1);
}

.page-tab--active:hover {
    background: var(--src-surface-solid);
}

.page-tab i {
    font-size: 13px;
    flex-shrink: 0;
}

.page-tab--soon {
    color: var(--src-text-tertiary);
}

.page-tab--soon:hover {
    color: var(--src-text-secondary);
}

.page-tab-badge {
    font-size: 0.5rem;
    font-weight: var(--src-weight-bold);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 1px 5px;
    border-radius: var(--src-radius-pill);
    background: var(--src-gray-100);
    color: var(--src-text-tertiary);
    line-height: 1.4;
    flex-shrink: 0;
}

/* A tab may carry a COUNT of what it holds — the population is the tab's own
   fact, so it renders on the tab, not as a subtitle the eye has to pair up.
   Tabular figures so the numbers do not jitter between views. Distinct from
   .page-tab-badge, which carries a WORD ("Soon") and shouts in uppercase. */
.page-tab-count {
    font-size: var(--src-text-xs);
    font-weight: var(--src-weight-semibold);
    padding: 1px 7px;
    border-radius: var(--src-radius-pill);
    background: var(--src-gray-100);
    color: var(--src-text-secondary);
    font-variant-numeric: tabular-nums;
    line-height: 1.5;
    flex-shrink: 0;
}

.page-tab--active .page-tab-count {
    background: var(--src-sandstone-tint);
    color: var(--src-sandstone-text);
}

.page-tab:focus-visible {
    outline: 2px solid var(--src-primary);
    outline-offset: 2px;
}

/* Header zone wrap — below 960px the tab strip drops to a full-width
   scroll row under the title, still above the divider. */
@media (max-width: 960px) {
    .page-header {
        flex-wrap: wrap;
    }

    .page-header-left {
        order: 1;
        width: 100%;
    }

    .page-tabs {
        order: 2;
        width: 100%;
        flex-shrink: 1;
    }

    .page-header-actions {
        order: 3;
    }
}


/* ===================
   TOOLBAR
   =================== */

.toolbar {
    display: flex;
    align-items: center;
    gap: var(--src-space-3);
    margin-bottom: var(--src-space-4);
    flex-wrap: wrap;
}

.toolbar .form-input,
.toolbar .form-select {
    width: auto;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: var(--src-space-3);
    flex: 1;
    min-width: 0;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: var(--src-space-3);
    flex-shrink: 0;
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background-color: var(--src-border);
}

.filter-chips {
    display: flex;
    align-items: center;
    gap: var(--src-space-2);
    flex-wrap: wrap;
}


/* ===================
   SECTION
   =================== */

.section {
    margin-bottom: var(--src-space-8);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--src-space-4);
    margin-bottom: var(--src-space-4);
}

.section-title {
    font-size: var(--src-text-lg);
    font-weight: var(--src-weight-semibold);
}

/* Sub-section scale. Modules used to declare this themselves — .reservations-section-title,
   .reservations-dashboard-section-title, .leadgen-section-title, .roster-page .module-section-title
   — four spellings of one heading. The flex box lives HERE and not on .section-title because the
   base has text-only consumers that gain nothing from it. */
.section-title--sub {
    font-size: var(--src-text-base);
    color: var(--src-text-heading);
    margin: 0 0 var(--src-space-4);
    display: flex;
    align-items: center;
    gap: var(--src-space-2);
}

.section-title--sub > .bi {
    color: var(--src-text-tertiary);
    font-size: 15px;
    flex-shrink: 0;
}

/* The item-count pill that rides inside a section title. */
.section-count {
    display: inline-flex;
    align-items: center;
    padding: 1px 8px;
    background: var(--src-primary-tint);
    color: var(--src-text-secondary);
    border-radius: var(--src-radius-pill);
    font-size: var(--src-text-xs);
    font-weight: var(--src-weight-bold);
    letter-spacing: 0.02em;
    margin-left: var(--src-space-2);
}


/* ===================
   GRID SYSTEM
   =================== */

.grid {
    display: grid;
    gap: var(--src-grid-gutter);
}

.grid-12 { grid-template-columns: repeat(12, 1fr); }
.grid-6  { grid-template-columns: repeat(6, 1fr); }
.grid-4  { grid-template-columns: repeat(4, 1fr); }
.grid-3  { grid-template-columns: repeat(3, 1fr); }
.grid-2  { grid-template-columns: repeat(2, 1fr); }
.grid-1  { grid-template-columns: 1fr; }

.col-span-1  { grid-column: span 1; }
.col-span-2  { grid-column: span 2; }
.col-span-3  { grid-column: span 3; }
.col-span-4  { grid-column: span 4; }
.col-span-5  { grid-column: span 5; }
.col-span-6  { grid-column: span 6; }
.col-span-7  { grid-column: span 7; }
.col-span-8  { grid-column: span 8; }
.col-span-9  { grid-column: span 9; }
.col-span-10 { grid-column: span 10; }
.col-span-11 { grid-column: span 11; }
.col-span-12 { grid-column: span 12; }

@media (max-width: 1024px) {
    .grid-4,
    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .grid-6,
    .grid-4,
    .grid-3,
    .grid-2 {
        grid-template-columns: 1fr;
    }

    .content-area {
        padding: var(--src-space-4);
    }
}


/* ===================
   FLEX HELPERS
   =================== */

.flex-row { display: flex; flex-direction: row; }
.flex-col { display: flex; flex-direction: column; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-start { display: flex; align-items: center; justify-content: flex-start; }
.flex-end { display: flex; align-items: center; justify-content: flex-end; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; min-width: 0; }


/* ===================
   SPLIT VIEW
   =================== */

.split-view {
    display: flex;
    gap: var(--src-space-5);
}

.split-main {
    flex: 1;
    min-width: 0;
}

.split-aside {
    width: 320px;
    flex-shrink: 0;
}


/* ===================
   PRINT
   =================== */

@media print {
    .topbar,
    .sidebar,
    .page-tabs,
    .toolbar,
    .page-header-actions,
    .pagination {
        display: none !important;
    }

    .app-content {
        margin-left: 0 !important;
    }

    .app-shell {
        padding-top: 0;
    }
}
