/* =================================================================
   WF Portal — Page-specific styles (Global)
   -----------------------------------------------------------------
   Consolidated from scoped .razor.css files into global CSS to
   avoid Blazor CSS-isolation issues with child components.
   ================================================================= */

/* =================================================================
   Layout — Main & Footer
   ================================================================= */

/* wf-main is the universal viewport boundary.
   Content pages scroll inside it (overflow: auto).
   App pages fill it exactly via flex: 1 + min-height: 0. */
.wf-main {
    display: flex;
    flex-direction: column;
    padding: var(--theme-page-padding);
    flex: 1;
    min-height: 0;
    overflow: auto;
    background-color: var(--theme-background-subtle);
}

/* Blazor's @key wrapper — pass flex chain to page content */
.wf-main > div:first-child {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* ── Stat Cards ────────────────────────────────────────────────── */

.wf-stat-card {
    flex: 1;
    min-width: 6rem;
    text-align: center;
    padding: 0.6rem 0.5rem;
    border: 1px solid var(--theme-border);
    border-radius: var(--theme-radius);
    background: var(--theme-background);
}
.wf-stat-value { font-size: 1.4rem; font-weight: 700; }
.wf-stat-label { font-size: 0.68rem; color: var(--theme-text-muted); text-transform: uppercase; letter-spacing: 0.04em; }

/* ── Tabs (simple underline) ────────────────────────────────────── */

.wf-tabs {
    display: flex;
    gap: 0;
    list-style: none;
    padding: 0;
    margin: 0;
    border-bottom: 1px solid var(--theme-border);
}
.wf-tabs li {
    padding: 0.5rem 1rem;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--theme-text-muted);
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}
.wf-tabs li:hover { color: var(--theme-text); }
.wf-tabs li.active { color: var(--theme-primary); border-bottom-color: var(--theme-primary); }

/* =================================================================
   Dashboard
   ================================================================= */

.wf-dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: 1rem;
}

.wf-widget-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.75rem;
    font-size: var(--theme-font-size-xs);
    font-weight: 500;
    color: var(--theme-primary);
    text-decoration: none;
}
.wf-widget-link:hover {
    color: var(--theme-primary-hover);
}

/* -- Quick access cards ------------------------------------------ */
.wf-quick-card {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 1rem;
    background-color: var(--theme-background-raised);
    border: 1px solid var(--theme-border);
    border-radius: var(--theme-radius);
    text-decoration: none;
    color: var(--theme-text);
    transition: border-color 150ms ease, box-shadow 150ms ease, transform 100ms ease;
}
.wf-quick-card:hover {
    border-color: var(--theme-border-subtle);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .35);
    transform: translateY(-1px);
    color: var(--theme-text);
    text-decoration: none;
}
.wf-quick-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 0.5rem;
    font-size: 1.25rem;
    flex-shrink: 0;
}
.wf-quick-title {
    font-weight: 600;
    font-size: var(--theme-font-size-sm);
    color: var(--theme-text-emphasis);
}
.wf-quick-desc {
    font-size: var(--theme-font-size-xs);
    color: var(--theme-text-secondary);
    margin-top: 0.125rem;
}

/* -- News feed --------------------------------------------------- */
.wf-news-feed {
    display: flex;
    flex-direction: column;
}
.wf-news-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 0;
    border-bottom: 1px solid var(--theme-border);
}
.wf-news-item:last-child {
    border-bottom: none;
}
.wf-news-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 0.4rem;
}
.wf-news-headline {
    font-size: var(--theme-font-size-sm);
    font-weight: 500;
    color: var(--theme-text-emphasis);
}
.wf-news-date {
    font-size: var(--theme-font-size-xs);
    color: var(--theme-text-muted);
    margin-top: 0.125rem;
}

/* =================================================================
   Entity Builder — Palette + Canvas
   ================================================================= */

.wf-palette {
    background-color: var(--theme-background-subtle);
    border-right: 1px solid var(--theme-border);
    width: 220px;
    min-width: 220px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.wf-palette-header {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--theme-border);
}

.wf-palette-section {
    padding: 0.75rem 0.75rem 0.25rem;
    font-size: var(--theme-font-size-xs);
    font-weight: 600;
    color: var(--theme-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.wf-palette-item {
    padding: 0.35rem 0.75rem;
    font-size: var(--theme-font-size-sm);
    color: var(--theme-text);
    cursor: grab;
    user-select: none;
    border-radius: var(--theme-radius-button);
    transition: background-color 120ms ease;
}
.wf-palette-item:hover {
    background-color: var(--theme-background-hover);
    color: var(--theme-text-emphasis);
}

.wf-palette-group-header {
    display: flex;
    align-items: center;
    padding: 0.35rem 0.75rem;
    font-size: var(--theme-font-size-sm);
    font-weight: 600;
    color: var(--theme-text-muted);
    cursor: pointer;
    user-select: none;
    border-radius: var(--theme-radius-button);
    transition: background-color 120ms ease;
}
.wf-palette-group-header:hover {
    background-color: var(--theme-background-hover);
    color: var(--theme-text-emphasis);
}
.wf-palette-group-header.expanded {
    color: var(--theme-text);
}

/* Group drop-target highlight */
.wf-palette-group.drop-active {
    outline: 2px dashed var(--theme-primary);
    outline-offset: -2px;
    background-color: var(--theme-primary-muted);
    border-radius: var(--theme-radius-button);
}

/* Remove button on group property items (visible on hover) */
.wf-remove-btn {
    opacity: 0;
    transition: opacity 120ms ease;
    line-height: 1;
    color: var(--theme-text-muted);
}
.wf-palette-item:hover .wf-remove-btn {
    opacity: 0.6;
}
.wf-remove-btn:hover {
    opacity: 1 !important;
    color: var(--theme-danger) !important;
}

.wf-drop-zone {
    border: 2px dashed var(--theme-border-subtle);
    border-radius: var(--theme-radius-button);
    padding: 0.5rem;
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--theme-text-muted);
    font-size: var(--theme-font-size-sm);
    transition: all 150ms ease;
}
.wf-drop-zone.active {
    border-color: var(--theme-primary);
    background-color: var(--theme-primary-muted);
    color: var(--theme-primary);
}

/* =================================================================
   Responsive — Tablet
   ================================================================= */

@media (max-width: 991.98px) {
    .wf-dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* =================================================================
   Responsive — Mobile
   ================================================================= */

@media (max-width: 767.98px) {
    .wf-dashboard-grid {
        grid-template-columns: 1fr;
    }
    .wf-quick-card {
        padding: 0.75rem;
    }
    .wf-palette {
        width: 100%;
        min-width: unset;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--theme-border);
    }
    /* Stack entity builder vertically on mobile */
    .wf-builder-layout {
        flex-direction: column !important;
        height: auto !important;
    }
}

/* =================================================================
   Content Page — scrollable wrapper for non-app pages
   Forces the page content to size to its natural height so wf-main
   scrolls it, rather than clamping to viewport like app pages.
   ================================================================= */

.wf-content-page {
    flex: 0 0 auto;
}

/* =================================================================
   Sticky Save Bar — Theme Editor
   ================================================================= */

.wf-sticky-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    padding: 0.75rem 2rem;
    background-color: var(--theme-background-raised);
    border-top: 1px solid var(--theme-border);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, .15);
    z-index: 1040;
}

/* =================================================================
   Admin Tabs — used on All Users, Tenant Users, etc.
   ================================================================= */
.wf-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--theme-border);
    margin-bottom: 0;
    padding: 0;
    list-style: none;
}

.wf-tab {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--theme-text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: color 120ms, border-color 120ms;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.wf-tab:hover {
    color: var(--theme-text);
}

.wf-tab.active {
    color: var(--theme-primary);
    border-bottom-color: var(--theme-primary);
}

.wf-tab .wf-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 10px;
    background: var(--theme-card-bg);
    border: 1px solid var(--theme-border);
    color: var(--theme-text-muted);
}

.wf-tab.active .wf-tab-count {
    background: var(--theme-primary);
    border-color: var(--theme-primary);
    color: #fff;
}

/* =================================================================
   Admin Tree View — collapsible tenant → user hierarchy
   ================================================================= */
.wf-tree-node {
    border: 1px solid var(--theme-border);
    border-radius: var(--theme-radius, 6px);
    margin-bottom: 0.5rem;
    overflow: hidden;
}

.wf-tree-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    background: var(--theme-card-bg);
    cursor: pointer;
    user-select: none;
    transition: background 120ms;
}

.wf-tree-header:hover {
    background: var(--theme-hover);
}

.wf-tree-chevron {
    font-size: 0.75rem;
    color: var(--theme-text-muted);
    transition: transform 120ms;
    flex-shrink: 0;
}

.wf-tree-chevron.expanded {
    transform: rotate(90deg);
}

.wf-tree-title {
    font-weight: 600;
    font-size: 0.875rem;
    flex: 1;
    min-width: 0;
}

.wf-tree-badge {
    font-size: 0.7rem;
}

.wf-tree-body {
    border-top: 1px solid var(--theme-border);
}

.wf-tree-body .table {
    margin-bottom: 0;
}

.wf-tree-body .table th {
    font-size: 0.75rem;
}

.wf-tree-body .table td {
    font-size: 0.8125rem;
}

/* ── Advanced Theme Editor ─────────────────────────────────── */

.cursor-pointer { cursor: pointer; }

