/* ══════════════════════════════════════════════════════════════════════════════
   DYNAMIC ENGINE UI/UX V2 — INDUSTRIAL ENTERPRISE DESIGN SYSTEM (REFINED)
   ══════════════════════════════════════════════════════════════════════════════ */

:root {
    --de-navy: #002244;
    --de-dark-slate: #0f172a;
    --de-border: #e2e8f0;
    --de-border-subtle: #f1f5f9;
    --de-bg-light: #f8fafc;
    --de-accent-blue: #0284c7;
    --de-success: #059669;
    --de-warning: #d97706;
    --de-danger: #dc2626;
    --de-text-muted: #64748b;
    --de-text-dark: #0f172a;
}

/* ─── 1. Enterprise Record List Row (Non-clipping, High Visibility) ────────── */
.dynamic-record-list-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.25rem;
    padding: 1.15rem 1.4rem;
    background: #ffffff;
    border: 1px solid var(--de-border);
    border-radius: 14px;
    box-shadow: 0 2px 6px rgba(0, 34, 68, 0.04);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    position: relative;
    overflow: visible !important; /* CRITICAL: Never clip dropdown action menus */
    z-index: 1;
}

.dynamic-record-list-row:hover {
    border-color: #cbd5e1;
    box-shadow: 0 8px 22px rgba(0, 34, 68, 0.08);
}

.dynamic-record-list-row.is-selected {
    background: #f0f9ff;
    border-color: #bae6fd;
}

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

.record-primary-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--de-dark-slate);
    cursor: pointer;
    line-height: 1.4;
    transition: color 0.15s ease;
}

.record-primary-title:hover {
    color: var(--de-accent-blue);
}

.record-id-badge {
    background: #f1f5f9;
    color: #334155;
    font-size: 0.78rem;
    font-weight: 800;
    padding: 0.2rem 0.55rem;
    border-radius: 6px;
    font-family: monospace;
    border: 1px solid #e2e8f0;
}

/* ─── 2. Responsive Helper Fields (Label on Top, Value on Bottom) ──────────── */
.record-helpers-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 1.25rem 2rem;
    padding: 0.4rem 0;
}

.helper-field-item {
    display: flex;
    flex-direction: column;
    min-width: 110px;
}

.dynamic-field-label-value.is-stacked {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    text-align: right;
}

.dynamic-field-label-value.is-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.dynamic-field-label-value .field-label {
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--de-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    line-height: 1.2;
}

.dynamic-field-label-value .field-value {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--de-dark-slate);
    line-height: 1.35;
    word-break: break-word;
}

.record-line-meta {
    font-size: 0.8rem;
    color: #64748b;
}

.record-line-meta .meta-item {
    display: inline-flex;
    align-items: center;
    color: #64748b;
}

/* ─── 3. Dynamic Status Badges (Uniform Enterprise Palette) ───────────────── */
.dynamic-status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.28rem 0.8rem;
    border-radius: 9999px;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.01em;
}

.dynamic-status-badge.badge-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.dynamic-status-badge.badge-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.dynamic-status-badge.badge-info {
    background: #f0f9ff;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

.dynamic-status-badge.badge-danger {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.dynamic-status-badge.badge-neutral {
    background: #f8fafc;
    color: #475569;
    border: 1px solid #e2e8f0;
}

/* ─── 4. Consolidated Action Menu & Dropdown Stacking ─────────────────────── */
.dynamic-action-menu {
    position: relative;
    display: inline-block;
    z-index: 1;
}

.dynamic-action-menu.is-open {
    z-index: 1105;
}

/* Each record is its own stacking layer. Without this, a later record can
   paint above the open menu even when the menu itself has a high z-index. */
.dynamic-record-list-row {
    position: relative;
    z-index: 1;
    overflow: visible !important;
}

.dynamic-record-list-row:has(.dynamic-action-menu.is-open) {
    z-index: 2100 !important;
}

.dynamic-action-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: transparent;
    cursor: default;
}

.dynamic-action-menu-toggle {
    width: 34px;
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--de-border);
    background: #ffffff;
    color: #475569;
    transition: all 0.15s ease;
}

.dynamic-action-menu-toggle:hover,
.dynamic-action-menu.is-open .dynamic-action-menu-toggle {
    background: #f1f5f9;
    color: var(--de-dark-slate);
    border-color: #cbd5e1;
}

.dynamic-action-dropdown-list {
    position: absolute;
    top: calc(100% + 4px);
    inset-inline-end: 0;
    z-index: 1110 !important;
    min-width: 195px;
    border-radius: 12px;
    border: 1px solid var(--de-border);
    padding: 0.45rem;
    background: #ffffff;
    box-shadow: 0 12px 32px rgba(0, 34, 68, 0.14) !important;
}

.dynamic-action-dropdown-list.dropup-menu {
    top: auto;
    bottom: calc(100% + 4px);
}

.dynamic-action-dropdown-list .dropdown-item {
    border-radius: 8px;
    padding: 0.52rem 0.85rem;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--de-text-dark);
    transition: all 0.15s ease;
}

.dynamic-action-dropdown-list .dropdown-item:hover {
    background: #f8fafc;
    color: var(--de-accent-blue);
}

.dynamic-action-dropdown-list .dropdown-item.text-danger:hover {
    background: #fef2f2;
    color: var(--de-danger);
}

/* ─── 5. View Switcher ────────────────────────────────────────────────────── */
.dynamic-view-switcher {
    display: inline-flex;
    background: #f1f5f9;
    padding: 3px;
    border-radius: 10px;
    border: 1px solid var(--de-border);
}

.dynamic-view-switcher .btn {
    border: none;
    background: transparent;
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    color: #64748b;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.18s ease;
}

.dynamic-view-switcher .btn.is-active {
    background: #ffffff;
    color: var(--de-dark-slate);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    font-weight: 700;
}

/* ─── 6. State Displays ───────────────────────────────────────────────────── */
.dynamic-state-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3.5rem 1.5rem;
    background: #ffffff;
    border: 1px dashed var(--de-border);
    border-radius: 16px;
    margin: 1rem 0;
}

.dynamic-state-display .state-icon-wrapper {
    font-size: 2.2rem;
    margin-bottom: 1rem;
}

.dynamic-state-display .state-title {
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--de-dark-slate);
    margin-bottom: 0.35rem;
}

.dynamic-state-display .state-description {
    font-size: 0.9rem;
    color: var(--de-text-muted);
    max-width: 480px;
    margin-bottom: 0;
    line-height: 1.6;
}

/* ─── 7. Compact AI Floating Trigger & Stacking Safety ────────────────────── */
.sky-mascot-global-overlay {
    z-index: 1090 !important;
}

/* The assistant is opened from the top-bar trigger. Do not leave a floating
   avatar over operational records while it is closed. */
.sky-mascot-global-overlay.is-closed {
    display: none !important;
}

/* ─── Mobile Responsiveness ──────────────────────────────────────────────── */
@media (max-width: 768px) {
    .dynamic-record-list-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.85rem;
        padding: 1rem;
    }

    .record-helpers-grid {
        gap: 0.85rem 1.25rem;
    }

    .record-row-actions {
        display: flex;
        justify-content: flex-end;
        border-top: 1px solid #f1f5f9;
        padding-top: 0.6rem;
    }
}
