/**
 * Portal application styles — SecurityLayer.
 * Restyles existing BEM classes (.sidebar, .portal__main, .card, .stat-box, .data-table)
 * with the new design tokens, plus new sl-* helpers (sl-stat-card, sl-tab, sl-page-*)
 * for richer composition.
 */

/* ============================================================
   PORTAL LAYOUT
   ============================================================ */
.portal {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sl-sidebar-width);
    flex-shrink: 0;
    background: var(--sl-sidebar-bg);
    background-image:
        radial-gradient(ellipse 80% 40% at 0% 0%, rgba(220, 44, 76, 0.10), transparent 60%),
        radial-gradient(ellipse 80% 50% at 100% 100%, rgba(46, 58, 102, 0.18), transparent 60%);
    color: rgba(255,255,255,0.78);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 50;
    display: flex;
    flex-direction: column;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 1px solid rgba(255,255,255,0.04);
}

.sidebar__logo {
    padding: 1.05rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 58px;
    flex-shrink: 0;
}
.sidebar__logo a {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    text-decoration: none;
}
.sidebar__logo-mark {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    display: block;
}
.sidebar__logo-text {
    font-family: var(--sl-font-display);
    font-size: 1.15rem;
    font-weight: 400;
    color: #fff;
    letter-spacing: -0.01em;
    line-height: 1;
}

.sidebar__nav {
    flex: 1;
    padding: 0.85rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
}

.sidebar__section {
    margin-top: 1.25rem;
}
.sidebar__section:first-child { margin-top: 0; }

.sidebar__section-title {
    font-size: 0.64rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(255,255,255,0.32);
    padding: 0.4rem 0.7rem 0.3rem;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.75rem;
    border-radius: 7px;
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s, transform 0.05s;
    margin-bottom: 1px;
    position: relative;
}
.sidebar__link:hover {
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.95);
}
.sidebar__link:active { transform: translateX(1px); }

.sidebar__link--active {
    background: rgba(255,255,255,0.10);
    color: #fff;
}
.sidebar__link--active::before {
    content: "";
    position: absolute;
    left: -0.75rem;
    top: 0.45rem; bottom: 0.45rem;
    width: 3px;
    background: var(--sl-color-accent);
    border-radius: 0 3px 3px 0;
}

.sidebar__link-icon {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: 0.78;
}
.sidebar__link-icon svg { width: 16px; height: 16px; display: block; }
.sidebar__link:hover .sidebar__link-icon { opacity: 1; }
.sidebar__link--active .sidebar__link-icon { opacity: 1; }

.sidebar__footer {
    padding: 0.75rem;
    border-top: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}

.sidebar__user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.55rem;
    border-radius: 7px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.78rem;
    transition: background 0.15s;
}
.sidebar__user:hover { background: rgba(255,255,255,0.06); }

.sidebar__user-avatar {
    width: 30px; height: 30px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--sl-color-accent), var(--sl-color-accent-light));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.78rem;
    color: #fff;
    flex-shrink: 0;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    box-shadow: 0 2px 6px rgba(220, 44, 76, 0.25);
}

.sidebar__user-info { min-width: 0; flex: 1; }
.sidebar__user-name {
    font-weight: 600;
    color: rgba(255,255,255,0.92);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
    font-size: 0.82rem;
}
.sidebar__user-email {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.42);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Main / topbar ── */
.portal__main {
    margin-left: var(--sl-sidebar-width);
    flex: 1;
    min-width: 0;
    background: var(--sl-color-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.portal__header {
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--sl-color-border-subtle);
    padding: 0 clamp(1.25rem, 3vw, 2rem);
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 40;
}

.portal__header h1 {
    font-family: var(--sl-font-display);
    font-size: 1.2rem;
    font-weight: 400;
    letter-spacing: -0.01em;
    margin: 0;
    color: var(--sl-color-text);
}

.portal__header-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.portal__content {
    padding: clamp(1.25rem, 3vw, 2rem);
    max-width: 88rem;
    width: 100%;
    margin: 0 auto;
    flex: 1;
}

/* ============================================================
   PAGE HEADER (within content)
   ============================================================ */
.sl-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.sl-page-header__left { flex: 1; min-width: 0; }

.sl-page-eyebrow {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--sl-color-accent);
    margin: 0 0 0.5rem;
}

.sl-page-title {
    font-family: var(--sl-font-display);
    font-size: 1.85rem;
    font-weight: 400;
    letter-spacing: -0.015em;
    color: var(--sl-color-text);
    margin: 0;
    line-height: 1.15;
}

.sl-page-subtitle {
    margin: 0.4rem 0 0;
    color: var(--sl-color-text-muted);
    font-size: 0.92rem;
    max-width: 56rem;
}

/* ============================================================
   CARDS  (legacy + new)
   ============================================================ */
.card,
.sl-card {
    background: var(--sl-color-surface);
    border: 1px solid var(--sl-color-border-subtle);
    border-radius: var(--sl-radius-lg);
    box-shadow: var(--sl-shadow-sm);
    overflow: hidden;
}

.card__header,
.sl-card-header {
    padding: 0.95rem 1.25rem;
    border-bottom: 1px solid var(--sl-color-border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: linear-gradient(180deg, rgba(245, 246, 250, 0.5), rgba(245, 246, 250, 0));
}

.card__title,
.sl-card-title {
    font-family: var(--sl-font-display);
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: -0.005em;
    color: var(--sl-color-text);
    margin: 0;
}

.card__body,
.sl-card-body { padding: 1.25rem; }

/* ============================================================
   STATS  (dashboard + scan show)
   ============================================================ */
.stats-row,
.sl-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    gap: 0.85rem;
    margin-bottom: 1.5rem;
}

.stat-box,
.sl-stat-card {
    background: var(--sl-color-surface);
    border: 1px solid var(--sl-color-border-subtle);
    border-radius: var(--sl-radius-lg);
    padding: 1.1rem 1.25rem;
    box-shadow: var(--sl-shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    position: relative;
    overflow: hidden;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.stat-box:hover,
.sl-stat-card:hover {
    border-color: var(--sl-color-border);
    box-shadow: var(--sl-shadow);
    transform: translateY(-1px);
}

.stat-box__label,
.sl-stat-card__label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sl-color-text-muted);
    order: -1;
}

.stat-box__value,
.sl-stat-card__value {
    font-family: var(--sl-font-display);
    font-size: 2rem;
    font-weight: 400;
    line-height: 1.05;
    color: var(--sl-color-text);
    letter-spacing: -0.02em;
}

.stat-box--critical { border-left: 3px solid var(--sl-color-critical); }
.stat-box--critical .stat-box__value { color: var(--sl-color-critical); }
.stat-box--high { border-left: 3px solid var(--sl-color-high); }
.stat-box--high .stat-box__value { color: var(--sl-color-high); }
.stat-box--medium { border-left: 3px solid var(--sl-color-medium); }
.stat-box--medium .stat-box__value { color: var(--sl-color-medium); }
.stat-box--ok { border-left: 3px solid var(--sl-color-success); }
.stat-box--ok .stat-box__value { color: var(--sl-color-success); }
.stat-box--accent { border-left: 3px solid var(--sl-color-accent); }
.stat-box--accent .stat-box__value { color: var(--sl-color-accent); }

.stat-box__trend {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--sl-color-text-muted);
}

/* ============================================================
   DATA TABLE
   ============================================================ */
.data-table,
table.sl-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--sl-color-surface);
    font-size: 0.9rem;
}

.data-table thead,
table.sl-table thead {
    background: var(--sl-color-bg-warm);
    border-bottom: 1px solid var(--sl-color-border);
}

.data-table th,
table.sl-table th {
    padding: 0.65rem 1.1rem;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sl-color-text-muted);
    white-space: nowrap;
}

.data-table td,
table.sl-table td {
    padding: 0.75rem 1.1rem;
    border-bottom: 1px solid var(--sl-color-border-subtle);
    color: var(--sl-color-text);
    vertical-align: middle;
}

.data-table tr:last-child td,
table.sl-table tr:last-child td { border-bottom: none; }

.data-table tbody tr,
table.sl-table tbody tr {
    transition: background 0.1s;
}
.data-table tbody tr:hover,
table.sl-table tbody tr:hover {
    background: var(--sl-color-bg);
}

.data-table a,
table.sl-table a {
    color: var(--sl-color-primary);
    text-decoration: none;
    font-weight: 600;
}
.data-table a:hover,
table.sl-table a:hover { color: var(--sl-color-accent); }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state,
.sl-empty {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--sl-color-text-muted);
}

.empty-state__icon,
.sl-empty-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 1rem;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(220, 44, 76, 0.08), rgba(46, 58, 102, 0.06));
    color: var(--sl-color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
}

.empty-state h3,
.sl-empty h3,
.sl-empty-title {
    font-family: var(--sl-font-display);
    font-size: 1.15rem;
    font-weight: 400;
    color: var(--sl-color-text);
    margin: 0 0 0.45rem;
}

.empty-state p {
    font-size: 0.92rem;
    margin: 0 0 1.4rem;
    max-width: 32rem;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.55;
}

/* ============================================================
   AUTH PAGES
   ============================================================ */
.sl-auth-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background:
        radial-gradient(ellipse 60% 50% at 0% 0%, rgba(46, 58, 102, 0.12), transparent 60%),
        radial-gradient(ellipse 50% 40% at 100% 100%, rgba(220, 44, 76, 0.08), transparent 55%),
        var(--sl-color-bg);
    position: relative;
    overflow: hidden;
}

.sl-auth-wrap::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(15, 22, 38, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(15, 22, 38, 0.025) 1px, transparent 1px);
    background-size: 32px 32px;
    pointer-events: none;
    mask: radial-gradient(ellipse at center, black 30%, transparent 75%);
    -webkit-mask: radial-gradient(ellipse at center, black 30%, transparent 75%);
}

.sl-auth-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    margin-bottom: 1.5rem;
    text-decoration: none;
    position: relative;
    z-index: 1;
}
.sl-auth-logo__mark { height: 36px; width: 36px; display: block; }
.sl-auth-logo__text {
    font-family: var(--sl-font-display);
    font-weight: 400;
    font-size: 1.4rem;
    color: var(--sl-color-text);
    letter-spacing: -0.01em;
    line-height: 1;
}

.sl-auth-card {
    background: var(--sl-color-surface);
    border: 1px solid var(--sl-color-border-subtle);
    border-radius: 18px;
    box-shadow: var(--sl-shadow-lg);
    padding: 2.25rem 2.25rem 2rem;
    width: 100%;
    max-width: 27rem;
    position: relative;
    z-index: 1;
}

.sl-auth-card__title {
    font-family: var(--sl-font-display);
    font-size: 1.55rem;
    font-weight: 400;
    letter-spacing: -0.015em;
    margin: 0 0 0.4rem;
    text-align: center;
    color: var(--sl-color-text);
}

.sl-auth-card__subtitle {
    text-align: center;
    font-size: 0.92rem;
    color: var(--sl-color-text-muted);
    margin: 0 0 1.75rem;
}

.sl-auth-card__footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--sl-color-border-subtle);
    font-size: 0.9rem;
    color: var(--sl-color-text-muted);
}
.sl-auth-card__footer a {
    color: var(--sl-color-primary);
    text-decoration: none;
    font-weight: 600;
}
.sl-auth-card__footer a:hover {
    color: var(--sl-color-accent);
    text-decoration: underline;
    text-underline-offset: 0.18em;
}

.sl-auth-trust {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.78rem;
    color: var(--sl-color-text-light);
    position: relative;
    z-index: 1;
}

/* ============================================================
   FORM HELPERS  (legacy)
   ============================================================ */
.form-group {
    margin-bottom: 1.25rem;
}
.form-group label {
    display: block;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--sl-color-text);
    margin-bottom: 0.35rem;
}
.form-control {
    width: 100%;
    padding: 0.55rem 0.8rem;
    border: 1px solid var(--sl-color-border);
    border-radius: var(--sl-radius-sm);
    font: inherit;
    font-size: 0.92rem;
    color: var(--sl-color-text);
    background: var(--sl-color-surface);
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}
.form-control:focus {
    outline: none;
    border-color: var(--sl-color-primary-light);
    box-shadow: 0 0 0 3px rgba(46, 58, 102, 0.14);
}
select.form-control { appearance: auto; }
.form-help {
    font-size: 0.82rem;
    color: var(--sl-color-text-muted);
    margin-top: 0.3rem;
}

/* ============================================================
   FILTER BAR / TABS
   ============================================================ */
.sl-tab-bar {
    display: flex;
    gap: 0.35rem;
    border-bottom: 1px solid var(--sl-color-border-subtle);
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}
.sl-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 0.95rem;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--sl-color-text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
}
.sl-tab:hover { color: var(--sl-color-text); }
.sl-tab--active {
    color: var(--sl-color-primary);
    border-bottom-color: var(--sl-color-accent);
}

/* ============================================================
   SEVERITY DOT (for ticket-style rows)
   ============================================================ */
.sl-sev-dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    margin-right: 0.4rem;
    flex-shrink: 0;
}
.sl-sev-dot--critical { background: var(--sl-color-critical); box-shadow: 0 0 0 3px rgba(185,28,28,0.15); }
.sl-sev-dot--high     { background: var(--sl-color-high); }
.sl-sev-dot--medium   { background: var(--sl-color-medium); }
.sl-sev-dot--low      { background: var(--sl-color-low); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 760px) {
    .sidebar {
        width: 64px;
    }
    .sidebar__logo { padding: 1.05rem 0; justify-content: center; }
    .sidebar__logo a span,
    .sidebar__section-title { display: none; }
    .sidebar__link { justify-content: center; padding: 0.55rem; }
    .sidebar__link span:not(.sidebar__link-icon) { display: none; }
    .sidebar__user-info { display: none; }
    .portal__main { margin-left: 64px; }
    .portal__content { padding: 1.25rem 1rem; }
    .sl-page-title { font-size: 1.45rem; }
}

@media (max-width: 520px) {
    .stats-row,
    .sl-stat-grid { grid-template-columns: 1fr 1fr; }
    .stat-box__value,
    .sl-stat-card__value { font-size: 1.55rem; }
}
