/* PEB Policy Dashboard — Policy management and violation tracking styles */

.peb-policy {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.25rem;
    min-height: 60vh;
}

.peb-policy__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.peb-policy__header h2 { margin: 0; font-size: 1.35rem; }
.peb-policy__subtitle { display: block; font-size: 0.78rem; opacity: 0.6; margin-top: 0.2rem; }
.peb-policy__header-actions { display: flex; gap: 0.5rem; align-items: center; }

.peb-policy__error {
    padding: 0.6rem 1rem;
    background: rgba(233, 116, 81, 0.12);
    border-left: 3px solid var(--red-500);
    border-radius: 4px;
    font-size: 0.85rem;
    color: #fca5a5;
}

/* Stats */
.peb-policy__stat--violations .aios-stat-value { color: var(--red-400); }
.peb-policy__stat--denials .aios-stat-value    { color: var(--orange-400); }

/* Tabs */
.peb-policy__tab-content { min-height: 400px; }

/* Policies tab */
.peb-policy__filter-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.peb-policy__policy-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 0.75rem;
}

.peb-policy__policy-card {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    padding: 0.85rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    transition: border-color 0.15s;
}

.peb-policy__policy-card:hover { border-color: rgba(255,255,255,0.16); }
.peb-policy__policy-card--builtin { border-left: 3px solid rgba(168, 85, 247, 0.5); }
.peb-policy__policy-card--custom  { border-left: 3px solid rgba(59, 130, 246, 0.5); }

.peb-policy__policy-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; }

.peb-policy__policy-name { font-weight: 600; font-size: 0.9rem; }

.peb-policy__policy-badges { display: flex; align-items: center; gap: 0.3rem; flex-wrap: wrap; }

.peb-policy__policy-desc { font-size: 0.8rem; opacity: 0.6; margin: 0; }

.peb-policy__policy-id { font-family: monospace; font-size: 0.72rem; opacity: 0.4; }

.peb-policy__del-btn { align-self: flex-end; }

/* Severity badges */
.peb-policy__sev-badge {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 0.1rem 0.4rem;
    border-radius: 9999px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.peb-policy__sev-badge--info { background: rgba(148,163,184,0.15); color: var(--slate-400); }
.peb-policy__sev-badge--low  { background: rgba(74,222,128,0.12);  color: #4ade80; }
.peb-policy__sev-badge--med  { background: rgba(251,191,36,0.12);  color: var(--yellow-400); }
.peb-policy__sev-badge--high { background: rgba(251,146,60,0.15);  color: var(--orange-400); }
.peb-policy__sev-badge--crit { background: rgba(233,116,81,0.15);   color: var(--red-400); }

.peb-policy__cat-badge {
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    background: rgba(255,255,255,0.08);
    color: inherit;
    opacity: 0.75;
}

.peb-policy__builtin-tag {
    font-size: 0.68rem;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    background: rgba(168,85,247,0.15);
    color: var(--violet-400);
}

.peb-policy__enabled-tag--on  { font-size: 0.68rem; padding: 0.1rem 0.4rem; border-radius: 4px; background: rgba(74,222,128,0.1);  color: #4ade80; }
.peb-policy__enabled-tag--off { font-size: 0.68rem; padding: 0.1rem 0.4rem; border-radius: 4px; background: rgba(148,163,184,0.1); color: var(--slate-400); }

/* Violations tab */
.peb-policy__violations { display: flex; flex-direction: column; gap: 0.5rem; }
.peb-policy__resolved-header { margin-top: 1.25rem; opacity: 0.6; font-size: 0.85rem; }

.peb-policy__viol-list { display: flex; flex-direction: column; gap: 0.4rem; }
.peb-policy__viol-list--resolved { opacity: 0.55; }

.peb-policy__viol-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.75rem;
    border-radius: 6px;
    background: rgba(255,255,255,0.04);
    border: 1px solid transparent;
}

.peb-policy__viol-row--open     { border-color: rgba(233,116,81,0.2); }
.peb-policy__viol-row--resolved { background: rgba(255,255,255,0.02); }

.peb-policy__viol-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex: 1;
    min-width: 0;
}

.peb-policy__viol-policy { font-weight: 600; font-size: 0.85rem; }
.peb-policy__viol-reason { font-size: 0.8rem; opacity: 0.7; }
.peb-policy__viol-meta   { font-size: 0.73rem; opacity: 0.5; font-family: monospace; }

/* Decisions tab */
.peb-policy__decision-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.83rem;
}

.peb-policy__decision-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    opacity: 0.6;
    font-weight: 600;
    white-space: nowrap;
}

.peb-policy__decision-table td {
    padding: 0.45rem 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.peb-policy__dec-badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.12rem 0.45rem;
    border-radius: 9999px;
    text-transform: uppercase;
}

.peb-policy__dec-badge--allow { background: rgba(74,222,128,0.12);  color: #4ade80; }
.peb-policy__dec-badge--deny  { background: rgba(233,116,81,0.15);   color: var(--red-400); }
.peb-policy__dec-badge--warn  { background: rgba(251,191,36,0.12);  color: var(--yellow-400); }

/* Evaluate tab */
.peb-policy__evaluate { display: flex; flex-direction: column; gap: 1rem; }
.peb-policy__evaluate h4 { margin: 0; font-size: 1rem; }

.peb-policy__eval-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 8px;
    padding: 1rem;
}

.peb-policy__eval-form > button { grid-column: 1 / -1; }

.peb-policy__eval-result {
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    overflow: hidden;
}

.peb-policy__eval-overall {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.peb-policy__eval-overall--allow { background: rgba(74,222,128,0.1);  border-bottom: 1px solid rgba(74,222,128,0.2); }
.peb-policy__eval-overall--deny  { background: rgba(233,116,81,0.1);   border-bottom: 1px solid rgba(233,116,81,0.2); }
.peb-policy__eval-overall--warn  { background: rgba(251,191,36,0.08); border-bottom: 1px solid rgba(251,191,36,0.2); }

.peb-policy__eval-details { padding: 0.5rem; display: flex; flex-direction: column; gap: 0.3rem; max-height: 360px; overflow-y: auto; }

.peb-policy__eval-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    font-size: 0.82rem;
    background: rgba(255,255,255,0.03);
}

.peb-policy__eval-row--deny { background: rgba(233,116,81,0.05); }
.peb-policy__eval-row--warn { background: rgba(251,191,36,0.05); }

.peb-policy__eval-pol-name { font-weight: 600; flex: 1; min-width: 0; }
.peb-policy__eval-reason   { opacity: 0.65; font-size: 0.78rem; }

/* Create modal */
.peb-policy__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;
}

.peb-policy__modal {
    background: var(--color-bg-panel, #2c2c2c);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 12px;
    width: 100%;
    max-width: 540px;
    display: flex;
    flex-direction: column;
    gap: 0;
    box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}

.peb-policy__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);
}

.peb-policy__modal-header h3 { margin: 0; font-size: 1rem; }

.peb-policy__modal-body { padding: 1.25rem; display: flex; flex-direction: column; gap: 0.75rem; }

.peb-policy__modal-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

.peb-policy__modal-enabled { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; cursor: pointer; }

.peb-policy__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);
}

/* Form validation states */
.peb-policy__field--error input,
.peb-policy__field--error select,
.peb-policy__field--error textarea { border-color: var(--red-500); }
.peb-policy__field-error { color: var(--red-400); font-size: 0.75rem; margin-top: 0.2rem; }
.peb-policy__field--success input { border-color: var(--color-success); }
