/* ═══════════════════════════════════════════════════════════════════════════════
 * Einblick Nexus PWA — Shared Components
 * ═══════════════════════════════════════════════════════════════════════════════
 * Reusable component styles: buttons, cards, badges, auth, overlays, toasts.
 * Used by both watch and mobile layouts.
 * ═══════════════════════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════════════════════
 * AUTH SCREEN
 * ═══════════════════════════════════════════════════════════════════════════════ */

.auth-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--sp-4);
    gap: var(--sp-4);
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.auth-logo-icon {
    font-size: var(--fs-3xl);
    color: var(--accent-green);
    filter: drop-shadow(var(--shadow-glow-green));
}

.auth-logo-text {
    font-size: var(--fs-xl);
    font-weight: var(--fw-bold);
    letter-spacing: 0.15em;
    color: var(--text-primary);
}

.auth-subtitle {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* ── Auth Form (Password + TOTP) ── */

.auth-form {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    width: 100%;
    max-width: 320px;
}

.auth-input-group {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
}

.auth-label {
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.auth-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.auth-input {
    width: 100%;
    padding: var(--sp-3);
    background: var(--bg-elevated);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    outline: none;
    transition: border-color var(--duration-fast) var(--ease-out),
                box-shadow var(--duration-fast) var(--ease-out);
    -webkit-appearance: none;
    appearance: none;
}

.auth-input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(41, 121, 255, 0.15);
}

.auth-input::placeholder {
    color: var(--text-tertiary);
}

/* Password visibility toggle */
.auth-toggle-pw {
    position: absolute;
    right: var(--sp-2);
    background: none;
    border: none;
    padding: var(--sp-1);
    font-size: var(--fs-md);
    cursor: pointer;
    color: var(--text-tertiary);
    line-height: 1;
}

/* TOTP monospace centered input */
.auth-input--totp {
    font-family: var(--font-mono);
    font-size: var(--fs-xl);
    font-weight: var(--fw-bold);
    text-align: center;
    letter-spacing: 0.3em;
    padding: var(--sp-3) var(--sp-4);
}

/* Submit button with loading spinner */
.auth-submit {
    margin-top: var(--sp-2);
    position: relative;
    min-height: var(--touch-comfortable);
}

.auth-submit__spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
}

/* Back button (TOTP → password) */
.auth-back {
    min-height: auto;
    padding: var(--sp-2);
    font-size: var(--fs-sm);
}

.auth-error {
    font-size: var(--fs-sm);
    color: var(--accent-red);
    min-height: 1.5em;
    text-align: center;
}

.auth-error.shake {
    animation: shake 0.4s ease-out;
}

.auth-attempts {
    font-size: var(--fs-xs);
    color: var(--text-tertiary);
    min-height: 1.2em;
    text-align: center;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%      { transform: translateX(-6px); }
    40%      { transform: translateX(6px); }
    60%      { transform: translateX(-4px); }
    80%      { transform: translateX(4px); }
}

/* ═══════════════════════════════════════════════════════════════════════════════
 * TOP BAR
 * ═══════════════════════════════════════════════════════════════════════════════ */

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-3) var(--sp-4);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    min-height: 48px;
    z-index: var(--z-nav);
    flex-shrink: 0;
}

.top-bar__left {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.top-bar__right {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
}

.top-bar__logo {
    font-size: var(--fs-md);
    color: var(--accent-green);
}

.top-bar__title {
    font-size: var(--fs-sm);
    font-weight: var(--fw-bold);
    letter-spacing: 0.12em;
    color: var(--text-primary);
}

.top-bar__logout {
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: var(--fs-md);
    cursor: pointer;
    padding: var(--sp-1);
    border-radius: var(--radius-sm);
    transition: color var(--duration-fast) var(--ease-out);
    line-height: 1;
}

.top-bar__logout:hover,
.top-bar__logout:active {
    color: var(--accent-red);
}

/* ═══════════════════════════════════════════════════════════════════════════════
 * BADGES
 * ═══════════════════════════════════════════════════════════════════════════════ */

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-xs);
    font-weight: var(--fw-semibold);
    border-radius: var(--radius-full);
    line-height: 1;
}

.badge--offline {
    color: var(--accent-red);
    font-size: var(--fs-sm);
}

.badge--online {
    color: var(--accent-green);
    font-size: var(--fs-sm);
}

.badge--connecting {
    color: var(--accent-yellow);
    font-size: var(--fs-sm);
    animation: pulse-yellow 2s infinite;
}

/* ═══════════════════════════════════════════════════════════════════════════════
 * VIEW CONTAINER
 * ═══════════════════════════════════════════════════════════════════════════════ */

.view-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--sp-4);
    -webkit-overflow-scrolling: touch;
}

/* ═══════════════════════════════════════════════════════════════════════════════
 * BOTTOM NAV
 * ═══════════════════════════════════════════════════════════════════════════════ */

.bottom-nav {
    display: flex;
    align-items: center;
    justify-content: space-around;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    padding: var(--sp-1) 0;
    padding-bottom: env(safe-area-inset-bottom, 4px);
    min-height: 56px;
    flex-shrink: 0;
    z-index: var(--z-nav);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    text-decoration: none;
    color: var(--text-tertiary);
    font-size: var(--fs-xs);
    padding: var(--sp-1) var(--sp-2);
    border-radius: var(--radius-sm);
    transition: color var(--duration-fast) var(--ease-out);
    position: relative;
    min-width: 48px;
}

.nav-item.active {
    color: var(--accent-green);
}

.nav-icon {
    font-size: var(--fs-md);
    line-height: 1;
}

.nav-label {
    font-weight: var(--fw-medium);
    letter-spacing: 0.02em;
}

.nav-badge {
    position: absolute;
    top: 0;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: var(--accent-red);
    color: var(--text-primary);
    font-size: 9px;
    font-weight: var(--fw-bold);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ═══════════════════════════════════════════════════════════════════════════════
 * DECISION CARD OVERLAY
 * ═══════════════════════════════════════════════════════════════════════════════ */

.decision-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: var(--z-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-4);
    animation: fade-in var(--duration-normal) var(--ease-out) both;
}

.decision-card {
    width: 100%;
    max-width: 360px;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: var(--sp-5);
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    box-shadow: var(--shadow-elevated);
    animation: slide-up var(--duration-slow) var(--ease-out) both;
}

.decision-card__severity {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--fs-sm);
    font-weight: var(--fw-bold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.decision-card__severity--critical { color: var(--accent-red); }
.decision-card__severity--high     { color: var(--accent-orange); }
.decision-card__severity--medium   { color: var(--accent-yellow); }

.decision-card__title {
    font-size: var(--fs-lg);
    font-weight: var(--fw-bold);
    line-height: var(--lh-tight);
}

.decision-card__detail {
    font-size: var(--fs-base);
    color: var(--text-secondary);
    line-height: var(--lh-normal);
}

.decision-card__agent {
    font-size: var(--fs-sm);
    color: var(--accent-purple);
    font-style: italic;
}

.decision-card__actions {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    margin-top: var(--sp-2);
}

/* ═══════════════════════════════════════════════════════════════════════════════
 * BUTTONS
 * ═══════════════════════════════════════════════════════════════════════════════ */

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    width: 100%;
    min-height: var(--touch-min);
    padding: var(--sp-3) var(--sp-4);
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: var(--fs-base);
    font-weight: var(--fw-semibold);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-out),
                transform var(--duration-fast) var(--ease-out),
                opacity var(--duration-fast) var(--ease-out);
    -webkit-appearance: none;
    appearance: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.4;
    pointer-events: none;
}

.btn--approve {
    background: var(--accent-green);
    color: var(--text-inverse);
}

.btn--approve:active { background: #00c964; }

.btn--info {
    background: var(--bg-elevated);
    color: var(--accent-blue);
}

.btn--info:active { background: var(--bg-hover); }

.btn--reject {
    background: var(--bg-elevated);
    color: var(--accent-red);
}

.btn--reject:active { background: var(--bg-hover); }

.btn--primary {
    background: var(--accent-blue);
    color: #fff;
}

.btn--ghost {
    background: transparent;
    color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════════════════════════════
 * TOAST NOTIFICATIONS
 * ═══════════════════════════════════════════════════════════════════════════════ */

.toast-container {
    position: fixed;
    top: var(--sp-4);
    left: var(--sp-4);
    right: var(--sp-4);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--accent-blue);
    box-shadow: var(--shadow-card);
    font-size: var(--fs-sm);
    color: var(--text-primary);
    pointer-events: auto;
    animation: fade-in var(--duration-normal) var(--ease-out) both;
}

.toast--success { border-left-color: var(--accent-green); }
.toast--warning { border-left-color: var(--accent-yellow); }
.toast--error   { border-left-color: var(--accent-red); }
.toast--info    { border-left-color: var(--accent-blue); }

.toast.removing {
    animation: fade-out var(--duration-normal) var(--ease-out) both;
}

.toast__icon {
    flex-shrink: 0;
    font-size: var(--fs-md);
}

.toast__message {
    flex: 1;
    line-height: var(--lh-tight);
}

/* ═══════════════════════════════════════════════════════════════════════════════
 * CARD (Generic reusable)
 * ═══════════════════════════════════════════════════════════════════════════════ */

.card {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: var(--sp-4);
    border: 1px solid var(--border-subtle);
}

.card--elevated {
    box-shadow: var(--shadow-card);
    border: none;
}

/* ═══════════════════════════════════════════════════════════════════════════════
 * METRIC (for dashboard)
 * ═══════════════════════════════════════════════════════════════════════════════ */

.metric {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.metric__label {
    font-size: var(--fs-xs);
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: var(--fw-medium);
}

.metric__value {
    font-size: var(--fs-xl);
    font-weight: var(--fw-bold);
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.metric__value--ok      { color: var(--accent-green); }
.metric__value--warning { color: var(--accent-yellow); }
.metric__value--danger  { color: var(--accent-red); }

/* ═══════════════════════════════════════════════════════════════════════════════
 * SKELETON LOADING
 * ═══════════════════════════════════════════════════════════════════════════════ */

.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-elevated) 25%,
        var(--bg-hover) 50%,
        var(--bg-elevated) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ═══════════════════════════════════════════════════════════════════════════════
 * SPINNER (inline thinking indicator)
 * ═══════════════════════════════════════════════════════════════════════════════ */

.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-medium);
    border-top-color: var(--accent-purple);
    border-radius: var(--radius-full);
    animation: spin 0.8s linear infinite;
}
