/* ----------------------------------------------------------
   PlayWell - Common Radzen/UI Styles
   Shared across dashboards, dialogs, and components.
   Prefix: pw-
   ---------------------------------------------------------- */

:root {
    /* Bottom padding on .pw-page. */
    --pw-page-padding-bottom: 20px;
}

/* - Blazor reconnect modal ----------------- */

#components-reconnect-modal { display: none; position: fixed; inset: 0; z-index: 10000; background: rgba(0,0,0,0.5); align-items: center; justify-content: center; }
#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected { display: flex; }
#components-reconnect-modal .reconnect-reconnecting { display: none; }
#components-reconnect-modal .reconnect-failed { display: none; }
#components-reconnect-modal.components-reconnect-show .reconnect-reconnecting { display: block; }
#components-reconnect-modal.components-reconnect-failed .reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected .reconnect-failed { display: block; }

/* - Bootstrap reboot overrides ------------- */

.rz-switch label {
    margin-bottom: 0;
}

.pw-info-item label,
.pw-split-menu-item {
    margin-bottom: 0;
}

/* - Copy cell (hover-reveal copy button in data grids) - */

.copy-cell {
    display: flex;
    align-items: center;
    gap: 4px;
    position: relative;
}

.copy-cell .rz-button.rz-button-icon-only {
    width: 22px;
    height: 22px;
    min-width: 22px;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    color: #94a3b8;
    opacity: 0;
    transition: opacity 0.15s;
}

.copy-cell:hover .rz-button.rz-button-icon-only {
    opacity: 1;
}

.copy-cell .rz-button.rz-button-icon-only:hover {
    color: #0284c7;
    background: #f0f9ff;
}

/* - Dialog header -------------------- */

.pw-dialog-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--rz-primary);
}

.pw-dialog-image {
    width: 80px;
    height: 80px;
    object-fit: contain;
}

.pw-dialog-title {
    flex: 1;
}

.pw-dialog-title h3 {
    margin: 0 0 0.25rem 0;
}

.pw-dialog-title p {
    margin: 0.25rem 0;
    color: #666;
}

/* - Info bar (summary strip below dialog header) ---- */

.pw-info-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: #f8f9fa;
    border-radius: 4px;
    margin-bottom: 0.75rem;
    border: 1px solid #dee2e6;
}

.pw-info-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pw-info-label {
    font-size: 0.8rem;
    color: #555;
    font-weight: 600;
}

.pw-info-value {
    font-size: 0.85rem;
    font-weight: 500;
}

.pw-info-divider {
    width: 1px;
    height: 1.5rem;
    background: #dee2e6;
}

/* - Sections ----------------------- */

.pw-section {
    margin-bottom: 1rem;
}

.pw-section h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.25rem;
}

.pw-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--rz-primary);
    margin-bottom: 0.5rem;
}

.pw-section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid #dee2e6;
}

.pw-section-header .pw-section-title {
    margin-bottom: 0;
}

/* - Grid layouts --------------------- */

.pw-grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: start;
}

.pw-grid-3col {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    align-items: start;
}

.pw-field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

/* - Field (label + value pair) -------------- */

.pw-field {
    display: flex;
    flex-direction: column;
}

.pw-field-label {
    font-size: 0.75rem;
    color: #888;
    font-weight: 600;
    text-transform: uppercase;
}

.pw-field-value {
    font-size: 0.9rem;
    font-weight: 500;
}

/* - Card ------------------------- */

.pw-card {
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 12px 16px;
    background: #f8f9fa;
}

/* - Badges ------------------------ */

.pw-badge-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.pw-badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.85em;
}

/* - Status badges -------------------- */

.pw-status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.8rem;
}

.pw-status-positive {
    background: #e8f5e9;
    color: #2e7d32;
}

.pw-status-negative {
    background: #fde8e8;
    color: #c62828;
}

.pw-status-neutral {
    background: #f5f5f5;
    color: #757575;
}

/* - Health badges -------------------- */

.pw-health-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
}

.pw-health-Critical { background: #fee2e2; color: #dc2626; }
.pw-health-LowStock { background: #fef3c7; color: #d97706; }
.pw-health-Healthy { background: #dcfce7; color: #16a34a; }
.pw-health-Overstocked { background: #dbeafe; color: #2563eb; }
.pw-health-DeadStock { background: #f3f4f6; color: #6b7280; }
.pw-health-OutOfStock { background: #f3e5f5; color: #7b1fa2; }
.pw-health-NeverAnalyzed { background: #fefce8; color: #a16207; }

/* - Edit inputs --------------------- */

.pw-edit-input {
    width: 100%;
    padding: 4px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 0.9rem;
}

.pw-edit-input:focus {
    outline: none;
    border-color: #0284c7;
    box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.15);
}

.pw-edit-textarea {
    width: 100%;
    min-height: 60px;
    padding: 6px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 0.85rem;
    resize: vertical;
}

/* - Notes box ---------------------- */

.pw-notes {
    background: #fffde7;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    border: 1px solid #fff9c4;
    font-size: 0.85rem;
    white-space: pre-wrap;
    margin-top: 0.25rem;
}

/* - Tier pricing grid ------------------ */

.pw-tier-grid {
    display: grid;
    grid-template-columns: 50px 1fr 1fr;
    gap: 4px 8px;
    align-items: center;
}

.pw-tier-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: #555;
}

/* - Split button --------------------- */

@keyframes pw-split-menu-open {
    from { opacity: 0; transform: scaleY(0.85); }
    to   { opacity: 1; transform: scaleY(1); }
}

@keyframes pw-split-menu-close {
    from { opacity: 1; transform: scaleY(1); }
    to   { opacity: 0; transform: scaleY(0.85); }
}

.pw-split-btn-wrap {
    position: relative;
    display: inline-flex;
}

.pw-split-btn-row {
    display: contents;
}

.pw-split-btn-wrap .pw-split-main {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: 1px solid rgba(255,255,255,0.35);
}

.pw-split-btn-wrap .pw-split-arrow {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    padding: 0 0.35rem;
    min-width: unset;
}

.pw-split-btn-wrap .pw-split-arrow .rz-button-icon-only {
    margin: 0;
}

/* When open: square off both bottom corners so they flush into the menu */
.pw-split-btn-wrap--open .pw-split-main {
    border-bottom-left-radius: 0;
    border-bottom: 1px solid rgba(255,255,255,0.3);
}

.pw-split-btn-wrap--open .pw-split-arrow {
    border-bottom-right-radius: 0;
    border-bottom: none;
}

.pw-split-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--rz-primary);
    border: 1px solid var(--rz-primary);
    border-top: none;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.18);
    padding: 0.25rem 0;
    z-index: 1000;
    transform-origin: top center;
    animation: pw-split-menu-open 0.15s ease forwards;
    overflow: hidden;
}

.pw-split-menu-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    color: #fff;
    cursor: pointer;
    user-select: none;
    margin-bottom: 0;
}

.pw-split-menu-item:hover {
    background: rgba(255,255,255,0.15);
}

/* Checkbox inside the blue dropdown - white box, blue check so it's visible */
.pw-split-menu .rz-chkbox-box {
    background: #fff;
    border-color: rgba(255,255,255,0.6);
}

.pw-split-menu .rz-chkbox-box.rz-state-active,
.pw-split-menu .rz-chkbox-box:hover {
    border-color: #fff;
}

.pw-split-menu .rz-chkbox-box .rz-chkbox-icon {
    color: var(--rz-primary);
}

.pw-split-menu-overlay {
    position: fixed;
    inset: 0;
    z-index: 999;
}

/* - Fail banner --------------------- */

.pw-fail-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    margin-bottom: 0.75rem;
    font-size: 0.82rem;
    color: #991b1b;
    line-height: 1.4;
}

.pw-fail-banner .pw-fail-icon {
    font-size: 1.25rem;
    color: #dc2626;
    flex-shrink: 0;
}

.pw-section-failure {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.6rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 5px;
    font-size: 0.78rem;
    color: #991b1b;
    line-height: 1.3;
}

.pw-section-failure .pw-fail-icon {
    font-size: 0.95rem;
    color: #dc2626;
    flex-shrink: 0;
    line-height: 1;
}

.pw-fail-badge {
    padding: 1px 8px;
    border-radius: 10px;
    background: #fee2e2;
    color: #dc2626;
    font-weight: 600;
    font-size: 0.75rem;
    white-space: nowrap;
}

/* - Info tip ----------------------- */

.pw-info-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: help;
    margin-left: 4px;
    flex-shrink: 0;
    color: #64748b;
    font-size: 1rem;
    vertical-align: middle;
    transition: color 0.15s;
}

.pw-info-tip i {
    font-size: 1rem;
}

.pw-info-tip:hover {
    color: #0284c7;
}

/* - Profile pill (inline selector in data grids) ----- */
/* .pw-select-pill styles live in Shared/SelectPill.razor.css (CSS isolation).
   This rule must stay global because it targets a Radzen element outside the component root. */

.pw-select-pill-cell,
.pw-select-pill-cell .rz-cell-data {
    overflow: visible !important;
}

/* - Page layout --------------------- */

.pw-page {
    padding-bottom: var(--pw-page-padding-bottom);
}

/* - Status tabs --------------------- */

/* - Radzen DataGrid - rounded corners + stripe colour -- */

.rz-datatable {
    --rz-grid-stripe-background-color: #eef0f4;
}

.pw-page .rz-datatable {
    border-radius: 8px;
}

.pw-page .rz-datatable > .rz-datatable-header {
    border-radius: 8px 8px 0 0;
    overflow: hidden;
}

.pw-page .rz-datatable > .rz-datatable-footer {
    border-radius: 0 0 8px 8px;
    overflow: hidden;
}

/* - Split filter (text input + criterion selector in grid headers) - */
/* .pw-filter-split styles live in Shared/GridTextFilterInput.razor.css (CSS isolation).
   This rule must stay global because it targets a Radzen element outside the component root. */

.rz-cell-filter:has(.pw-filter-split) {
    padding: .25rem .5rem;
}

/* - Action cell (hover-reveal buttons, right-aligned) -- */

.pw-action-cell {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
}

.pw-action-cell .pw-action-buttons {
    display: flex;
    align-items: center;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s;
    margin-left: auto;
}

.pw-action-cell:hover .pw-action-buttons {
    opacity: 1;
}

.pw-action-cell .pw-action-buttons .rz-button {
    width: 26px;
    height: 26px;
    min-width: 26px;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    color: #475569;
}

.pw-action-cell .pw-action-buttons .rz-button:hover {
    color: #0284c7;
    background: #f0f9ff;
    border-radius: 4px;
}
