/* Reusable components: buttons, status indicators, panels, KPIs, inputs, output panes, badges, toasts. */

.button {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    color: #ffffff;
    background:
        linear-gradient(
            135deg,
            var(--blue-strong),
            #4f46e5
        );
    border: 1px solid rgba(147, 197, 253, 0.24);
    border-radius: 11px;
    box-shadow:
        0 8px 24px rgba(37, 99, 235, 0.20);
    cursor: pointer;
    font-weight: 650;
    transition:
        transform 150ms ease,
        border-color 150ms ease,
        filter 150ms ease;
}

.button:hover:not(:disabled) {
    border-color: rgba(147, 197, 253, 0.48);
    filter: brightness(1.08);
    transform: translateY(-1px);
}

.button:active:not(:disabled) {
    transform: translateY(0);
}

.button-secondary {
    color: var(--text-secondary);
    background: rgba(30, 47, 73, 0.82);
    border-color: var(--border);
    box-shadow: none;
}

.button-danger {
    color: #fecdd3;
    background: rgba(159, 18, 57, 0.20);
    border-color: rgba(251, 113, 133, 0.23);
    box-shadow: none;
}

.button-small {
    min-height: 36px;
    padding: 7px 12px;
    font-size: 0.84rem;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--muted);
    font-size: 0.77rem;
    font-weight: 650;
}

.status-indicator::before {
    width: 8px;
    height: 8px;
    content: "";
    background: var(--muted);
    border-radius: 50%;
}

.status-indicator.online {
    color: #a7f3d0;
}

.status-indicator.online::before {
    background: var(--green);
    box-shadow:
        0 0 12px rgba(52, 211, 153, 0.62);
}

.status-indicator.warning {
    color: #fde68a;
}

.status-indicator.warning::before {
    background: var(--yellow);
}

.status-indicator.offline {
    color: #fecdd3;
}

.status-indicator.offline::before {
    background: var(--red);
}

.kpi {
    position: relative;
    min-height: 146px;
    overflow: hidden;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-medium);
    box-shadow:
        0 12px 30px rgba(0, 0, 0, 0.14);
    transition:
        transform 160ms ease,
        border-color 160ms ease;
}

.kpi:hover {
    border-color: var(--border-strong);
    transform: translateY(-2px);
}

.kpi::after {
    position: absolute;
    right: -34px;
    bottom: -52px;
    width: 110px;
    height: 110px;
    content: "";
    background: var(--accent, var(--blue));
    border-radius: 50%;
    filter: blur(48px);
    opacity: 0.24;
}

.kpi-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.kpi-label {
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 750;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.kpi-icon {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    color: var(--accent, var(--blue));
    background: color-mix(
        in srgb,
        var(--accent, var(--blue)) 13%,
        transparent
    );
    border: 1px solid color-mix(
        in srgb,
        var(--accent, var(--blue)) 21%,
        transparent
    );
    border-radius: 10px;
}

.kpi-icon svg {
    width: 18px;
    height: 18px;
}

.kpi-value {
    position: relative;
    z-index: 1;
    margin: 14px 0 3px;
    overflow: hidden;
    font-size: clamp(1.55rem, 3.5vw, 2.15rem);
    font-weight: 760;
    letter-spacing: -0.04em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kpi-description {
    position: relative;
    z-index: 1;
    color: var(--muted);
    font-size: 0.79rem;
}

.panel {
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-large);
    box-shadow:
        0 14px 40px rgba(0, 0, 0, 0.15);
}

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}

.panel-title-group {
    min-width: 0;
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0;
    font-size: 1rem;
    font-weight: 720;
}

.panel-title svg {
    width: 19px;
    height: 19px;
    color: var(--blue);
}

.panel-subtitle {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 0.79rem;
}

.panel-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.panel-body {
    padding: 20px;
}

.field label {
    display: block;
    margin-bottom: 7px;
    color: var(--text-secondary);
    font-size: 0.77rem;
    font-weight: 650;
}

.input {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    color: var(--text);
    background: rgba(4, 10, 20, 0.72);
    border: 1px solid var(--border);
    border-radius: 10px;
    transition:
        border-color 150ms ease,
        background 150ms ease;
}

.input:hover {
    border-color: rgba(148, 163, 184, 0.30);
}

.input::placeholder {
    color: #64748b;
}

.message {
    margin-top: 11px;
    color: var(--muted);
    font-size: 0.78rem;
}

.message.error {
    color: #fecdd3;
}

.output-panel {
    margin-top: 16px;
    overflow: hidden;
    background: rgba(3, 8, 17, 0.74);
    border: 1px solid rgba(148, 163, 184, 0.13);
    border-radius: 12px;
}

.output-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 42px;
    padding: 9px 12px;
    color: var(--muted);
    background: rgba(15, 29, 51, 0.66);
    border-bottom: 1px solid var(--border);
    font-size: 0.75rem;
}

.output-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.output-status::before {
    width: 7px;
    height: 7px;
    content: "";
    background: var(--muted);
    border-radius: 50%;
}

.output-status.success::before {
    background: var(--green);
}

.output-status.warning::before {
    background: var(--yellow);
}

.output-status.error::before {
    background: var(--red);
}

.loading-line {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: #bfdbfe;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(96, 165, 250, 0.23);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 800ms linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.toast-region {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 1000;
    display: grid;
    width: min(390px, calc(100% - 36px));
    gap: 10px;
    pointer-events: none;
}

.toast {
    padding: 13px 15px;
    color: var(--text-secondary);
    background: rgba(15, 29, 51, 0.97);
    border: 1px solid var(--border);
    border-left: 3px solid var(--blue);
    border-radius: 12px;
    box-shadow: var(--shadow);
    font-size: 0.82rem;
    opacity: 0;
    transform: translateY(8px);
    animation: toast-in 180ms ease forwards;
}

.toast.error {
    border-left-color: var(--red);
}

.toast.success {
    border-left-color: var(--green);
}

@keyframes toast-in {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* KPI accent variants (replace inline style="--accent: ..." so CSP can drop 'unsafe-inline'). */
.kpi--blue {
    --accent: var(--blue);
}

.kpi--red {
    --accent: var(--red);
}

.kpi--green {
    --accent: var(--green);
}

.kpi--purple {
    --accent: var(--purple);
}

.kpi--cyan {
    --accent: var(--cyan);
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 25px;
    padding: 3px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 750;
    white-space: nowrap;
}

.badge-high,
.badge-detected {
    color: #fecdd3;
    background: rgba(159, 18, 57, 0.22);
    border-color: rgba(251, 113, 133, 0.28);
}

.badge-medium {
    color: #fde68a;
    background: rgba(161, 98, 7, 0.18);
    border-color: rgba(251, 191, 36, 0.24);
}

.badge-low,
.badge-clear {
    color: #a7f3d0;
    background: rgba(6, 95, 70, 0.20);
    border-color: rgba(52, 211, 153, 0.24);
}

.badge-unknown {
    color: var(--text-secondary);
    background: rgba(71, 85, 105, 0.20);
}

@media (max-width: 560px) {
    .panel-header {
        align-items: stretch;
        flex-direction: column;
    }

    .panel-actions {
        justify-content: flex-start;
    }

    .panel-actions .button {
        flex: 1;
    }
}
