/* ===============================================================
   Enterprise Shared Components — Reusable ent-* patterns
   Used across AIOS, PEB, and all enterprise modules
   =============================================================== */

/* ── Skeleton Loading ──────────────────────────────────────────── */
@keyframes ent-shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
.ent-skeleton {
    background: linear-gradient(90deg,
        rgba(255,255,255,0.04) 25%,
        rgba(255,255,255,0.08) 50%,
        rgba(255,255,255,0.04) 75%
    );
    background-size: 200% 100%;
    animation: ent-shimmer 1.5s ease-in-out infinite;
    border-radius: 6px;
}
.ent-skeleton--text { height: 14px; width: 60%; margin-bottom: 8px; }
.ent-skeleton--card { height: 120px; }
.ent-skeleton--row  { height: 40px; margin-bottom: 4px; }

/* ── Empty State ───────────────────────────────────────────────── */
.ent-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    text-align: center;
    min-height: 200px;
}
.ent-empty-state__icon {
    font-size: 2.5rem;
    opacity: 0.3;
    margin-bottom: 1rem;
}
.ent-empty-state__title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary, var(--slate-200));
    margin-bottom: 0.5rem;
}
.ent-empty-state__desc {
    font-size: 0.85rem;
    color: var(--text-secondary, var(--slate-400));
    max-width: 320px;
}

/* ── Error Banner ──────────────────────────────────────────────── */
.ent-error-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    background: rgba(233, 116, 81, 0.1);
    border-left: 3px solid var(--red-500);
    border-radius: 0 6px 6px 0;
    font-size: 0.85rem;
    color: #fed7aa;
}
.ent-error-banner--warn {
    background: rgba(245, 158, 11, 0.1);
    border-left-color: var(--yellow-500);
    color: #fde68a;
}
.ent-error-banner__dismiss {
    margin-left: auto;
    background: none;
    border: none;
    color: inherit;
    opacity: 0.6;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0 4px;
}
.ent-error-banner__dismiss:hover { opacity: 1; }

/* ── Status Dot ────────────────────────────────────────────────── */
.ent-status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.ent-status-dot--green  { background: var(--color-success); }
.ent-status-dot--amber  { background: var(--yellow-500); }
.ent-status-dot--red    { background: var(--red-500); }
.ent-status-dot--grey   { background: var(--slate-500); }
.ent-status-dot--blue   { background: var(--blue-500); }

@keyframes ent-pulse {
    0%, 100% { box-shadow: 0 0 0 0 currentColor; }
    50% { box-shadow: 0 0 0 4px transparent; }
}
.ent-status-dot--pulse {
    animation: ent-pulse 2s ease-in-out infinite;
}

/* ── Card ──────────────────────────────────────────────────────── */
.ent-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 10px;
    padding: 1rem;
    transition: transform 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.ent-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.14);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
.ent-card--clickable { cursor: pointer; }
.ent-card--selected {
    border-color: var(--accent-primary, var(--ld-400));
    box-shadow: 0 0 0 1px var(--accent-primary, var(--ld-400));
}

.ent-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}
.ent-card-header__title {
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text-primary, var(--slate-200));
}
.ent-card-header__actions {
    display: flex;
    gap: 0.35rem;
    align-items: center;
}

/* ── KPI Row ───────────────────────────────────────────────────── */
.ent-kpi-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.ent-kpi-item {
    flex: 1;
    min-width: 120px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 0.85rem 1rem;
    text-align: center;
}
.ent-kpi-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary, var(--slate-200));
}
.ent-kpi-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary, var(--slate-400));
    margin-top: 0.3rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.ent-kpi-trend {
    font-size: 0.72rem;
    font-weight: 600;
    margin-top: 0.2rem;
}
.ent-kpi-trend--up   { color: var(--color-success); }
.ent-kpi-trend--down { color: var(--red-500); }
.ent-kpi-trend--flat { color: var(--slate-500); }

/* ── Tab Bar ───────────────────────────────────────────────────── */
.ent-tab-bar {
    display: flex;
    gap: 2px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 1.25rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.ent-tab {
    background: none;
    border: none;
    color: var(--text-secondary, var(--slate-400));
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}
.ent-tab:hover { color: var(--text-primary, var(--slate-200)); }
.ent-tab--active {
    color: var(--accent-primary, var(--ld-400));
    border-bottom-color: var(--accent-primary, var(--ld-400));
    font-weight: 600;
}
.ent-tab-content { min-height: 200px; }

/* ── Table ─────────────────────────────────────────────────────── */
.ent-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
}
.ent-table thead { position: sticky; top: 0; z-index: 1; }
.ent-table th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-secondary, var(--slate-400));
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    background: var(--bg-primary, #202020);
}
.ent-table td {
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    vertical-align: middle;
}
.ent-table tbody tr { transition: background 0.1s; }
.ent-table tbody tr:hover { background: rgba(255, 255, 255, 0.03); }
.ent-table tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.015); }
.ent-table tbody tr:nth-child(even):hover { background: rgba(255, 255, 255, 0.04); }
.ent-table--clickable tbody tr { cursor: pointer; }
.ent-table td.ent-mono { font-family: 'JetBrains Mono', monospace; font-size: 0.8rem; }

/* ── Badge ─────────────────────────────────────────────────────── */
.ent-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.12rem 0.5rem;
    border-radius: 9999px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}
.ent-badge--critical { background: rgba(233, 116, 81, 0.15); color: var(--red-400); }
.ent-badge--warning  { background: rgba(245, 158, 11, 0.12); color: var(--yellow-400); }
.ent-badge--info     { background: rgba(59, 130, 246, 0.15); color: var(--blue-400); }
.ent-badge--success  { background: rgba(16, 185, 129, 0.12); color: var(--emerald-400); }
.ent-badge--neutral  { background: rgba(148, 163, 184, 0.12); color: var(--slate-400); }
.ent-badge--purple   { background: rgba(168, 85, 247, 0.15); color: var(--violet-400); }

/* ── Modal ─────────────────────────────────────────────────────── */
.ent-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    opacity: 0;
    animation: ent-fade-in 0.15s ease forwards;
}
@keyframes ent-fade-in {
    to { opacity: 1; }
}
.ent-modal {
    background: var(--color-bg-panel, #2c2c2c);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    width: 100%;
    max-width: 560px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    transform: translateY(8px);
    animation: ent-slide-up 0.2s ease forwards;
}
@keyframes ent-slide-up {
    to { transform: translateY(0); }
}
.ent-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.ent-modal__header h3 { margin: 0; font-size: 1.05rem; }
.ent-modal__close {
    background: none;
    border: none;
    color: var(--text-secondary, var(--slate-400));
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px;
}
.ent-modal__close:hover { color: var(--text-primary, var(--slate-200)); }
.ent-modal__body {
    padding: 1.25rem;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}
.ent-modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.ent-modal__row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

/* ── Form Group ────────────────────────────────────────────────── */
.ent-form-group { margin-bottom: 0.85rem; }
.ent-form-group label {
    display: block;
    font-size: 0.82rem;
    color: var(--text-secondary, var(--slate-400));
    margin-bottom: 0.3rem;
    font-weight: 500;
}
.ent-form-group input,
.ent-form-group select,
.ent-form-group textarea {
    width: 100%;
    padding: 0.55rem 0.75rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: var(--text-primary, var(--slate-200));
    font-size: 0.85rem;
    font-family: inherit;
    transition: border-color 0.15s;
}
.ent-form-group input:focus,
.ent-form-group select:focus,
.ent-form-group textarea:focus {
    outline: none;
    border-color: var(--accent-primary, var(--ld-400));
}
.ent-form-group__help {
    font-size: 0.75rem;
    color: var(--text-tertiary, var(--slate-500));
    margin-top: 0.25rem;
}

/* ── Loading Overlay ───────────────────────────────────────────── */
.ent-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 15, 26, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: inherit;
}
@keyframes ent-spin {
    to { transform: rotate(360deg); }
}
.ent-spinner {
    width: 28px;
    height: 28px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-primary, var(--ld-400));
    border-radius: 50%;
    animation: ent-spin 0.7s linear infinite;
}

/* ── Action Bar ────────────────────────────────────────────────── */
.ent-action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.ent-action-bar__left,
.ent-action-bar__right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ── Search Bar ────────────────────────────────────────────────── */
.ent-search-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.75rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    max-width: 300px;
    flex: 1;
}
.ent-search-bar input {
    background: transparent;
    border: none;
    color: var(--text-primary, var(--slate-200));
    font-size: 0.85rem;
    outline: none;
    width: 100%;
}
.ent-search-bar__icon { opacity: 0.4; font-size: 0.9rem; }

/* ── Progress / Meter Bar ──────────────────────────────────────── */
.ent-meter {
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
}
.ent-meter__fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
    background: var(--accent-primary, var(--ld-400));
}
.ent-meter__fill--green  { background: var(--color-success); }
.ent-meter__fill--amber  { background: var(--yellow-500); }
.ent-meter__fill--red    { background: var(--red-500); }
.ent-meter__fill--blue   { background: var(--blue-500); }

/* ── Detail Panel / Drawer ─────────────────────────────────────── */
.ent-detail-panel {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 1.25rem;
    margin-top: 1rem;
}
.ent-detail-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.ent-detail-panel__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}
.ent-detail-field {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}
.ent-detail-field__label {
    font-size: 0.72rem;
    color: var(--text-tertiary, var(--slate-500));
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.ent-detail-field__value {
    font-size: 0.88rem;
    color: var(--text-primary, var(--slate-200));
    font-weight: 500;
}

/* ── Success / Error Flash ─────────────────────────────────────── */
@keyframes ent-flash-success {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    70% { box-shadow: 0 0 0 6px transparent; }
    100% { box-shadow: none; }
}
@keyframes ent-flash-error {
    0% { box-shadow: 0 0 0 0 rgba(233, 116, 81, 0.4); }
    70% { box-shadow: 0 0 0 6px transparent; }
    100% { box-shadow: none; }
}
.ent-flash--success { animation: ent-flash-success 0.6s ease; }
.ent-flash--error   { animation: ent-flash-error 0.6s ease; }

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .ent-kpi-row { flex-direction: column; }
    .ent-kpi-item { min-width: unset; }
    .ent-modal { max-width: 100%; margin: 0.5rem; }
    .ent-modal__row { grid-template-columns: 1fr; }
    .ent-action-bar { flex-direction: column; align-items: stretch; }
    .ent-detail-panel__grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
    .ent-kpi-value { font-size: 1.4rem; }
    .ent-tab { padding: 0.5rem 0.65rem; font-size: 0.78rem; }
    .ent-table { font-size: 0.78rem; }
    .ent-table th, .ent-table td { padding: 0.4rem 0.5rem; }
}

/* ── Reduced Motion ────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .ent-skeleton { animation: none; }
    .ent-status-dot--pulse { animation: none; }
    .ent-card { transition: none; }
    .ent-modal-overlay { animation: none; opacity: 1; }
    .ent-modal { animation: none; transform: none; }
    .ent-spinner { animation-duration: 1.5s; }
    .ent-meter__fill { transition: none; }
    .ent-flash--success,
    .ent-flash--error { animation: none; }
}
