/* =============================================================================
   SiM Hub · Base
   Reset, tipografia e estilos globais.
   ============================================================================= */

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    /* Reserva SEMPRE o espaço da barra de rolagem, mesmo quando a página não tem
       scroll. Sem isso, ao navegar de uma página sem scroll para uma com scroll a
       barra "rouba" largura e o conteúdo (header incluso) pula pro lado. */
    scrollbar-gutter: stable;
}
html, body {
    height: 100%;
}

body {
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-main);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background var(--transition-base), color var(--transition-base);
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-main);
    letter-spacing: -0.01em;
}

h1 { font-size: 2.25rem; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 1.75rem; font-weight: 700; }
h3 { font-size: 1.25rem; font-weight: 700; }
h4 { font-size: 1.05rem; font-weight: 600; }

p {
    color: var(--text-sub);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-hover);
}

code, pre {
    font-family: var(--font-mono);
    font-size: 0.9em;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input, textarea, select {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    background: none;
    border: none;
    outline: none;
}

img {
    max-width: 100%;
    display: block;
}

/* ---------- Scrollbar custom ---------- */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: var(--radius-pill);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ---------- Helpers ---------- */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.label-uppercase {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 700;
    font-size: 0.7rem;
    color: var(--text-sub);
}

.mono {
    font-family: var(--font-mono);
}

/* ---------- Animação de entrada da view ---------- */
@keyframes viewEnter {
    from {
        opacity: 0;
        transform: translateY(6px) scale(0.995);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.view {
    animation: viewEnter 380ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Respeita prefer-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .view {
        animation: none;
    }
    .skeleton {
        animation: none;
        background: var(--bg-elev-2);
    }
}

/* ---------- Foco acessível ---------- */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* =============================================================================
   SPLASH SCREEN — fade out depois que o app inicializa
   ============================================================================= */
.splash {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 280ms ease-out, visibility 0s linear 280ms;
}

.splash::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 30% 40%, rgba(52, 211, 153, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 70% 60%, rgba(167, 139, 250, 0.06) 0%, transparent 50%);
    pointer-events: none;
}

.splash.splash-hidden {
    opacity: 0;
    visibility: hidden;
}

.splash-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
    animation: splashRise 480ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes splashRise {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.splash-logo {
    width: 56px;
    height: 56px;
    color: var(--primary);
    filter: drop-shadow(0 0 16px rgba(52, 211, 153, 0.35));
    animation: splashPulse 2s ease-in-out infinite;
}

@keyframes splashPulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.06); }
}

.splash-wordmark {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 2rem;
    letter-spacing: -0.02em;
    line-height: 1;
}

.splash-sim {
    color: var(--text-main);
}

.splash-hub {
    color: var(--primary);
}

.splash-dots {
    display: flex;
    gap: 6px;
    margin-top: var(--space-2);
}

.splash-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
    opacity: 0.3;
    animation: splashDot 1.2s ease-in-out infinite;
}

.splash-dots span:nth-child(2) { animation-delay: 0.15s; }
.splash-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes splashDot {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50%      { opacity: 1;   transform: scale(1.3); }
}

/* =============================================================================
   ERROR SCREEN (404 / erro genérico)
   ============================================================================= */
.error-screen {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
    overflow: hidden;
    z-index: 50;
}

.error-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    pointer-events: none;
}

.error-blob-1 {
    width: 360px;
    height: 360px;
    background: radial-gradient(circle, rgba(248, 113, 113, 0.15) 0%, transparent 70%);
    top: -100px;
    left: -100px;
}

.error-blob-2 {
    width: 320px;
    height: 320px;
    background: radial-gradient(circle, rgba(167, 139, 250, 0.10) 0%, transparent 70%);
    bottom: -80px;
    right: -80px;
}

.error-card {
    position: relative;
    z-index: 1;
    max-width: 480px;
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-8) var(--space-6);
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: errorRise 480ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes errorRise {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.error-icon-wrap {
    width: 84px;
    height: 84px;
    margin: 0 auto var(--space-4);
    color: var(--blocked, #f87171);
    background: rgba(248, 113, 113, 0.08);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
}

.error-icon-wrap svg {
    width: 100%;
    height: 100%;
}

.error-code {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 3rem;
    color: var(--blocked, #f87171);
    line-height: 1;
    letter-spacing: -0.04em;
    margin-bottom: var(--space-2);
}

.error-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.35rem;
    color: var(--text-main);
    margin-bottom: var(--space-3);
    letter-spacing: -0.01em;
}

.error-message {
    color: var(--text-sub);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: var(--space-6);
}

.error-actions {
    display: flex;
    justify-content: center;
    margin-bottom: var(--space-6);
}

.error-foot {
    padding-top: var(--space-4);
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.78rem;
}

.error-foot-label {
    color: var(--text-muted);
    font-weight: 600;
}

.error-foot-info {
    color: var(--text-sub);
}

/* =============================================================================
   SKELETON LOADING (shimmer effect)
   ============================================================================= */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-elev-1) 0%,
        var(--bg-elev-2) 40%,
        var(--bg-elev-2) 60%,
        var(--bg-elev-1) 100%
    );
    background-size: 200% 100%;
    border-radius: var(--radius-sm);
    animation: skeletonShimmer 1.4s ease-in-out infinite;
}

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

.skeleton-line {
    height: 12px;
    border-radius: 4px;
    margin-bottom: 6px;
}

.skeleton-block {
    width: 100%;
    border-radius: var(--radius-md);
}

.skeleton-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    flex-shrink: 0;
}

.skeleton-tag {
    width: 60px;
    height: 22px;
    border-radius: var(--radius-pill);
}

/* Sidebar skeleton */
.skeleton-sidebar {
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    height: 100%;
}

.skeleton-sidebar-top {
    display: flex;
    gap: var(--space-3);
    align-items: flex-start;
}

.skeleton-sidebar-top-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.skeleton-sidebar-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.skeleton-sidebar-card {
    padding: var(--space-3);
    background: var(--bg-elev-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.skeleton-sidebar-loading-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--primary-soft);
    border: 1px solid var(--primary-border);
    border-radius: var(--radius-md);
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 500;
    margin-top: auto;
}

.skeleton-sidebar-loading-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid var(--primary-soft);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 800ms linear infinite;
    flex-shrink: 0;
}

/* Workspace skeleton */
.skeleton-workspace {
    padding: var(--space-6);
}

.skeleton-workspace-row {
    display: flex;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}

.skeleton-workspace-row .skeleton-line {
    height: 14px;
    margin-bottom: 0;
}
