/* ==========================================================================
   CoCoConnect Global Styles
   
   GUIDELINES:
   - Use MudBlazor components and utility classes when possible
   - Use these custom styles for app-specific needs
   - All custom classes use 'coco-' prefix
   - Colors are coordinated with CoCoTheme.cs
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Custom Properties (Brand Colors)
   These coordinate with CoCoTheme.cs MudBlazor theme configuration
   -------------------------------------------------------------------------- */
:root {
    /* CoCoConnect Brand Colors — forest green */
    --coco-primary: #007A45;
    --coco-primary-dark: #006138;
    --coco-primary-light: #E6F4EC;

    /* Primary color RGB values for rgba() usage */
    --coco-primary-rgb: 0, 122, 69;

    /* Text Colors */
    --coco-text-primary: #17212B;
    --coco-text-secondary: #556272;
    --coco-text-muted: #adb5bd;
    
    /* UI Colors */
    --coco-border-color: #dee2e6;
    --coco-bg-subtle: #f8f9fa;
    
    /* Standard colors */
    --coco-white: #fff;
    --coco-black: #000;
    
    /* Semantic Colors (matching MudBlazor theme) */
    --coco-info: #0dcaf0;
    --coco-success: #198754;
    --coco-warning: #ffc107;
    --coco-error: #dc3545;
    
    /* Skeleton/Grid colors */
    --coco-skeleton-bg: #fff;
    --coco-skeleton-header-bg: #f5f5f5;
    --coco-skeleton-alt-bg: #fafafa;
    --coco-skeleton-border: #e0e0e0;
    --coco-skeleton-border-light: #e8e8e8;
    --coco-skeleton-border-medium: #ddd;
    
    /* Border radius */
    --coco-border-radius: 0.375rem;
}

/* --------------------------------------------------------------------------
   Base Typography
   MudBlazor provides typography, this is fallback
   -------------------------------------------------------------------------- */
html, body {
    font-family: Inter, system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

/* --------------------------------------------------------------------------
   Content Area Styles
   -------------------------------------------------------------------------- */

/* Main Content Area - provides spacing for fixed app bar */
.coco-main-content {
    padding-top: 80px;      /* 64px app bar + 16px breathing room */
    padding-left: 16px;
    padding-right: 16px;
    padding-bottom: 16px;
}

/* Page Titles */
.coco-page-title {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--coco-text-primary);
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--coco-primary);
}

/* Section Headings */
.coco-section-title {
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--coco-text-primary);
    margin-top: 1.5rem;
    margin-bottom: 1rem;
}

/* Lead/Intro Text */
.coco-lead {
    font-size: 1.1rem;
    color: var(--coco-text-secondary);
    margin-bottom: 1.5rem;
}

/* --------------------------------------------------------------------------
   Status Indicators
   Consistent status colors across the app
   -------------------------------------------------------------------------- */
.coco-status-new { color: var(--coco-info); }
.coco-status-pending { color: var(--coco-warning); }
.coco-status-processing { color: var(--coco-primary); }
.coco-status-shipped { color: #0d6efd; }
.coco-status-completed { color: var(--coco-success); }
.coco-status-cancelled { color: var(--coco-error); }
.coco-status-problem { color: var(--coco-error); }

/* --------------------------------------------------------------------------
   Fulfillment Run Stepper (MudTimeline compact overrides)
   -------------------------------------------------------------------------- */
.coco-run-stepper.mud-timeline-horizontal {
    padding: 0;
}

.coco-run-stepper.mud-timeline-horizontal::before {
    top: 12px;
}

.coco-run-stepper.mud-timeline-horizontal .mud-timeline-item {
    padding: 0 4px;
}

.coco-run-stepper.mud-timeline-horizontal .mud-timeline-item .mud-timeline-item-divider {
    min-height: 24px;
}

.coco-run-stepper.mud-timeline-horizontal .mud-timeline-item .mud-timeline-item-content {
    padding-top: 2px;
    max-height: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Utility Classes
   -------------------------------------------------------------------------- */
.coco-text-primary { color: var(--coco-primary) !important; }
.coco-text-accent { color: var(--coco-accent) !important; }
.coco-bg-primary { background-color: var(--coco-primary) !important; }
.coco-bg-subtle { background-color: var(--coco-bg-subtle) !important; }
.coco-border-primary { border-color: var(--coco-primary) !important; }

/* --------------------------------------------------------------------------
   Focus Styles (for non-MudBlazor elements)
   -------------------------------------------------------------------------- */
h1:focus {
    outline: none;
}

/* --------------------------------------------------------------------------
   Blazor 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: var(--coco-white);
}

.blazor-error-boundary::after {
    content: "An error has occurred."
}

/* --------------------------------------------------------------------------
   Blazor Error UI (connection lost indicator)
   -------------------------------------------------------------------------- */
#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    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;
}

/* Clickable Card styles moved to CoCoPlatform.Web.Components/wwwroot/coco-layout.css */

/* Description subtitle on stage cards */
.coco-stage-description {
    color: var(--coco-text-muted);
    line-height: 1.3;
    margin-bottom: 0.25rem;
}

/* Row-style anchor for Products dashboard inventory-health list.
   Mirrors the current MudStack row layout, adds anchor semantics + hover feedback. */
.coco-product-health-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-decoration: none;
    color: inherit;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.15s ease;
}

.coco-product-health-row:hover {
    background: var(--coco-bg-subtle);
    text-decoration: none;
}

/* Queue group section labels on dashboard */
.coco-queue-group-label {
    color: var(--coco-text-muted);
    letter-spacing: 0.08em;
    margin-bottom: 0.5rem;
    padding-left: 0.25rem;
}

/* --------------------------------------------------------------------------
   Sales Orders Workspace - Split Panel Layout
   -------------------------------------------------------------------------- */
.coco-workspace-splitter {
    border: 1px solid var(--coco-border-color);
    border-radius: var(--coco-border-radius);
}

.coco-workspace-splitter .e-pane {
    overflow: hidden;
}

.coco-workspace-grid-pane {
    height: 100%;
    padding: 0;
}

.coco-workspace-grid-pane .e-grid {
    border: none;
    border-radius: 0;
}

.coco-workspace-detail-pane {
    height: 100%;
    padding: 1rem;
    overflow-y: auto;
    background-color: var(--coco-bg-subtle);
}

.coco-workspace-empty-detail {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--coco-text-muted);
}

.coco-workspace-empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Detail panel tab adjustments for side panel */
.coco-workspace-detail-pane .e-tab {
    background: transparent;
}

.coco-workspace-detail-pane .e-tab .e-content {
    padding: 0.75rem 0;
}

/* --------------------------------------------------------------------------
   Utility: Pre-wrap for code/EDI content
   -------------------------------------------------------------------------- */
.coco-pre-wrap {
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* --------------------------------------------------------------------------
   Account Module Styles
   -------------------------------------------------------------------------- */
.coco-account-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background-color: var(--coco-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--coco-white);
    font-size: 1.75rem;
}

/* --------------------------------------------------------------------------
   Search Box with Icon
   -------------------------------------------------------------------------- */
.coco-search-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.coco-search-icon {
    position: absolute;
    left: 10px;
    z-index: 1;
    color: var(--coco-text-muted);
    font-size: 14px;
    pointer-events: none;
}

.coco-search-wrapper .e-textbox.coco-search-input {
    padding-left: 32px;
}

.coco-search-wrapper .e-input-group.e-control-wrapper {
    padding-left: 0;
}

.coco-search-wrapper .e-input-group.e-control-wrapper input.e-input {
    padding-left: 32px;
}

/* --------------------------------------------------------------------------
   Action Bar Styles
   -------------------------------------------------------------------------- */
.coco-action-bar {
    background-color: var(--coco-bg-subtle);
}

/* --------------------------------------------------------------------------
   Data Grid Row Selection
   -------------------------------------------------------------------------- */
.coco-row-selected {
    background-color: rgba(var(--coco-primary-rgb), 0.12) !important;
}

/* Muted row for removed/canceled orders in fulfillment-run grids. */
.coco-row-muted {
    opacity: 0.55;
    font-style: italic;
}

/* Prevent the divider between grid and detail pane from growing in the flex layout. */
.coco-products-divider {
    flex: 0 0 auto;
}

/* MudSplitPanel divider background — match page background */
.coco-split-divider {
    background-color: #f5f6f8;
}

/* First panel (grid): border so edge is visible above the divider */
.coco-split-first-panel {
    border: 1px solid #D7DCE2;
}

/* Second panel (detail): border + brand-tinted top edge anchoring it to the grid */
.coco-split-second-panel {
    border: 1px solid #D7DCE2;
    border-top: 2px solid var(--coco-primary);
}


/* --------------------------------------------------------------------------
   Vertical Splitter
   -------------------------------------------------------------------------- */
.coco-splitter {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.coco-splitter-pane {
    overflow: auto;
    min-height: 0;
}

.coco-splitter-pane-top {
    flex-shrink: 0;
}

.coco-splitter-pane-bottom {
    flex: 1;
    min-height: 0;
}

.coco-splitter-divider {
    height: 8px;
    background-color: var(--mud-palette-lines-default);
    cursor: ns-resize;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s ease;
    user-select: none;
}

.coco-splitter-divider:hover,
.coco-splitter-divider.dragging {
    background-color: var(--coco-primary);
}

.coco-splitter-divider::after {
    content: '';
    width: 40px;
    height: 4px;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

.coco-splitter-divider:hover::after,
.coco-splitter-divider.dragging::after {
    background-color: rgba(255, 255, 255, 0.5);
}

/* Prevent text selection while dragging */
.coco-splitter.dragging {
    user-select: none;
}

.coco-splitter.dragging * {
    pointer-events: none;
}

/* --------------------------------------------------------------------------
   Sales Order Detail Tabs - Scrollable tab panels
   -------------------------------------------------------------------------- */
.coco-detail-tabs {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.coco-detail-tabs > .mud-tabs-header {
    flex-shrink: 0;
}

.coco-detail-tabs > .mud-tabs-panels {
    flex: 0 1 auto;
    min-height: 0;
    max-height: 100%;
    overflow-y: auto;
}

/* --------------------------------------------------------------------------
   Operations Dashboard — Health Bar
   -------------------------------------------------------------------------- */

.coco-health-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.coco-health-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: 8px;
    border: 1px solid var(--mud-palette-lines-default);
    border-left: 4px solid var(--coco-success);
    background: var(--mud-palette-surface);
    min-width: 170px;
    flex: 1 1 170px;
}

.coco-health-card-error {
    border-left-color: var(--coco-error);
    background: rgba(220, 53, 69, 0.04);
}

.coco-health-card-ok .mud-icon-root {
    color: var(--coco-success);
    opacity: 0.7;
}

.coco-health-card-error .mud-icon-root {
    color: var(--coco-error);
}

.coco-health-card-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.coco-health-card-label {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--mud-palette-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.coco-health-card-value {
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.2;
}

.coco-health-card-ok .coco-health-card-value {
    color: var(--coco-success);
}

/* Zero-state KPIs — inert gray, no alarm signal */
.coco-health-card-zero {
    border-left-color: var(--mud-palette-lines-default);
}

.coco-health-card-zero .mud-icon-root {
    color: var(--mud-palette-text-secondary);
    opacity: 0.5;
}

.coco-health-card-zero .coco-health-card-value {
    color: var(--mud-palette-text-secondary);
    font-weight: 500;
}

.coco-health-card-error .coco-health-card-value {
    color: var(--coco-error);
}

/* Warning-state KPIs — amber, issues that aren't critical */
.coco-health-card-warning {
    border-left-color: var(--mud-palette-warning);
    background: rgba(255, 152, 0, 0.04);
}

.coco-health-card-warning .mud-icon-root {
    color: var(--mud-palette-warning);
}

.coco-health-card-warning .coco-health-card-value {
    color: var(--mud-palette-warning);
}

/* All-clear strip — shown when no exceptions exist */
.coco-health-all-clear {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: 8px;
    border: 1px solid var(--mud-palette-lines-default);
    border-left: 4px solid var(--coco-success);
    background: rgba(40, 167, 69, 0.04);
}

.coco-health-all-clear .mud-icon-root {
    color: var(--coco-success);
}

/* --------------------------------------------------------------------------
   Operations Dashboard — Problems Zone
   -------------------------------------------------------------------------- */

.coco-problems-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.coco-problem-card {
    border-radius: 8px;
    border: 1px solid var(--mud-palette-lines-default);
    background: var(--mud-palette-surface);
    overflow: hidden;
}

.coco-problem-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--mud-palette-background);
}

.coco-problem-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-top: 1px solid var(--mud-palette-lines-default);
}

/* --------------------------------------------------------------------------
   Operations Dashboard — Order Pipeline
   -------------------------------------------------------------------------- */

.coco-pipeline-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Layout overrides applied on top of .coco-clickable-card (compact horizontal strip). */
.coco-pipeline-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 10px 16px;
    flex: 1 1 120px;
    text-align: center;
}

.coco-pipeline-stage-label {
    font-size: 0.6875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.coco-pipeline-stage-value {
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.2;
}

/* --------------------------------------------------------------------------
   Operations Dashboard — Operational Detail Sections
   -------------------------------------------------------------------------- */

.coco-ops-section {
    border-radius: 8px;
    border: 1px solid var(--mud-palette-lines-default);
    background: var(--mud-palette-surface);
    overflow: hidden;
}

.coco-ops-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--mud-palette-background);
}

.coco-ops-run-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-top: 1px solid var(--mud-palette-lines-default);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s ease;
}

.coco-ops-run-row:hover {
    background: var(--mud-palette-background);
}

.coco-ops-feed-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-top: 1px solid var(--mud-palette-lines-default);
}

/* --------------------------------------------------------------------------
   Order Detail — Header Stat Blocks (two-level: label over value)
   -------------------------------------------------------------------------- */

.coco-order-stat {
    display: inline-flex;
    flex-direction: column;
    line-height: 1.15;
    padding: 0 16px;
    border-left: 1px solid var(--mud-palette-lines-default);
}

.coco-order-stat:first-of-type {
    border-left: none;
    padding-left: 0;
}

.coco-order-stat-label {
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--mud-palette-text-secondary);
}

.coco-order-stat-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--mud-palette-text-primary);
    margin-top: 2px;
}

.coco-muted {
    color: var(--mud-palette-text-secondary);
}