/* =============================================
   Layout v2 — Mobile-first
   Bottom nav em mobile, sidebar em desktop
   ============================================= */

/* --- Loading screen --- */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    height: 100dvh;
    gap: var(--space-4);
    color: var(--text-muted);
}

.loading-spinner {
    width: 36px;
    height: 36px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* ==========================================
   Auth pages (Login / Setup / Recuperar)
   ========================================== */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: var(--space-4);
    background:
        radial-gradient(ellipse at 20% 50%, rgba(201, 168, 76, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(201, 168, 76, 0.03) 0%, transparent 50%),
        var(--bg-primary);
}

.auth-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-2xl);
    padding: var(--space-8);
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-xl);
    position: relative;
    overflow: hidden;
}

.auth-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0.6;
}

.auth-card .logo {
    text-align: center;
    margin-bottom: var(--space-8);
}

.auth-card .logo h1 {
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
    color: var(--accent);
    letter-spacing: 2px;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}

.beta-badge {
    display: inline-block;
    font-size: var(--text-xs);
    font-weight: var(--font-bold);
    letter-spacing: 1.5px;
    color: var(--bg-primary);
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    padding: 2px 10px;
    border-radius: var(--radius-full);
    vertical-align: middle;
    line-height: 1.6;
    box-shadow: var(--shadow-glow-sm);
    animation: betaPulse 2s ease-in-out infinite;
}

@keyframes betaPulse {
    0%, 100% { box-shadow: var(--shadow-glow-sm); }
    50% { box-shadow: var(--shadow-glow), 0 0 30px var(--accent-glow); }
}

.auth-card .logo p {
    color: var(--text-muted);
    font-size: var(--text-sm);
    margin-top: var(--space-1);
    letter-spacing: 0.5px;
}

/* ==========================================
   Main app layout
   ========================================== */
.app-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

/* --- Header --- */
.header {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-4);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    flex-shrink: 0;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    background: rgba(19, 22, 31, 0.85);
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;
}

.header-brand {
    font-size: var(--text-sm);
    font-weight: var(--font-bold);
    color: var(--accent);
    letter-spacing: 1px;
    text-transform: uppercase;
    white-space: nowrap;
}

.header-title {
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-divider {
    width: 1px;
    height: 20px;
    background: var(--border-color);
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}

.header-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    position: relative;
    font-size: var(--text-lg);
}

.header-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.header-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--accent-light);
    border: 1.5px solid var(--accent-subtle);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-bold);
    font-size: var(--text-xs);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.header-avatar:hover {
    box-shadow: var(--shadow-glow-sm);
}

/* --- Bottom Navigation (mobile) --- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: var(--z-nav);
    padding-bottom: env(safe-area-inset-bottom, 0);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    background: rgba(19, 22, 31, 0.92);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--space-1) var(--space-3);
    color: var(--text-muted);
    font-size: 20px;
    transition: color var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
    position: relative;
}

.bottom-nav-item span {
    font-size: var(--text-xs);
}

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

.bottom-nav-item.active::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 2px;
    background: var(--accent);
    border-radius: var(--radius-full);
}

/* --- Sidebar (desktop only) --- */
.sidebar {
    display: none;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: var(--z-sticky);
}

.sidebar-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.sidebar-logo {
    font-size: var(--text-sm);
    font-weight: var(--font-bold);
    color: var(--accent);
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-3) var(--space-3);
}

.sidebar-section-title {
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: var(--space-4) var(--space-3) var(--space-2);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: var(--text-sm);
    transition: all var(--transition-fast);
    margin-bottom: 1px;
}

.sidebar-link:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.sidebar-link.active {
    background: var(--accent-light);
    color: var(--accent);
}

.sidebar-link .icon {
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    font-size: var(--text-base);
}

.sidebar-link .count {
    margin-left: auto;
    font-size: var(--text-xs);
    color: var(--text-muted);
    background: var(--bg-primary);
    padding: 1px 7px;
    border-radius: var(--radius-full);
}

.sidebar-footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border-color);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.sidebar-user .avatar {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-full);
    background: var(--accent-light);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--font-bold);
    font-size: var(--text-xs);
    flex-shrink: 0;
}

.sidebar-user .info {
    flex: 1;
    min-width: 0;
}

.sidebar-user .info .name {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user .info .role {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

/* --- Main content --- */
.main-content {
    flex: 1;
    min-height: 0;
    padding-bottom: calc(var(--bottom-nav-height) + var(--space-4));
}

/* --- Page content --- */
.page-content {
    padding: var(--space-4);
    max-width: var(--content-max);
    margin: 0 auto;
}

/* --- Page header (título + ações) --- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
    flex-wrap: wrap;
}

.page-header h2 {
    font-size: var(--text-xl);
    font-weight: var(--font-bold);
}

.page-header .actions {
    display: flex;
    gap: var(--space-2);
}

/* --- Cards grid --- */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--space-4);
}

/* --- Overlay (mobile sidebar fallback) --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: calc(var(--z-sticky) - 1);
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    display: block;
}

/* --- Stat cards (relatórios, resumo) --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-6);
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    text-align: center;
}

.stat-card .stat-value {
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
    color: var(--accent);
}

.stat-card .stat-label {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: var(--space-1);
}

/* --- Section divider --- */
.section-title {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--border-color);
}
