/* ============================================
   Shell Navigation - Bottom Bar & Sidebar
   Gestor de Despesas v3.0
   ============================================ */

/* Shell Layout */
.shell-page {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 769px) {
    .shell-page {
        padding-bottom: 0;
        padding-left: 260px;
        transition: padding-left 0.3s ease;
    }

    .shell-page.shell-collapsed {
        padding-left: 72px;
    }
}

/* ============================================
   Bottom Tab Bar (Mobile)
   ============================================ */
.shell-bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(72px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 900;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

@media (min-width: 769px) {
    .shell-bottom-bar {
        display: none;
    }
}

.shell-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 12px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-tertiary);
    text-decoration: none;
    transition: color var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
    position: relative;
    min-width: 56px;
}

.shell-tab svg {
    width: 22px;
    height: 22px;
    transition: transform var(--transition-fast);
}

.shell-tab-label {
    font-size: 0.625rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.shell-tab.active {
    color: var(--primary);
}

.shell-tab.active svg {
    transform: scale(1.1);
}

.shell-tab:active svg {
    transform: scale(0.9);
}

/* FAB Button (center tab) */
.shell-fab {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--gradient-primary, linear-gradient(135deg, #3b82f6, #6366f1));
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    margin-top: -20px;
    -webkit-tap-highlight-color: transparent;
}

.shell-fab svg {
    width: 24px;
    height: 24px;
    color: white;
    transition: transform var(--transition-fast);
}

.shell-fab:active {
    transform: scale(0.92);
}

.shell-fab.expanded svg {
    transform: rotate(45deg);
}

/* FAB Expanded Options */
.shell-fab-options {
    position: absolute;
    bottom: calc(100% + 16px);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal), transform var(--transition-normal);
    transform: translateX(-50%) translateY(10px);
}

.shell-fab-options.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.shell-fab-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full, 9999px);
    box-shadow: var(--elevation-3, 0 8px 24px rgba(0,0,0,0.12));
    white-space: nowrap;
    cursor: pointer;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
    min-height: 48px;
}

.shell-fab-option svg {
    width: 22px;
    height: 22px;
}

.shell-fab-option.despesa { color: var(--danger); }
.shell-fab-option.receita { color: var(--success); }
.shell-fab-option.transferencia { color: var(--primary); }

.shell-fab-option:active {
    transform: scale(0.95);
}

/* FAB Overlay */
.shell-fab-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 899;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

.shell-fab-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Badge */
.shell-badge {
    position: absolute;
    top: 2px;
    right: 6px;
    min-width: 16px;
    height: 16px;
    background: var(--danger);
    color: white;
    font-size: 0.5625rem;
    font-weight: 700;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}

.shell-badge-dot {
    position: absolute;
    top: 6px;
    right: 10px;
    width: 8px;
    height: 8px;
    background: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--card-bg);
}

/* ============================================
   Sidebar (Desktop)
   ============================================ */
.shell-sidebar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    background: var(--card-bg);
    border-right: 1px solid var(--border-color);
    z-index: 900;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width var(--transition-normal);
}

@media (min-width: 769px) {
    .shell-sidebar {
        display: flex;
    }
}

.shell-sidebar.collapsed {
    width: 72px;
}

/* Sidebar Header */
.shell-sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.shell-sidebar-logo {
    width: 36px;
    height: 36px;
    background: var(--gradient-primary, linear-gradient(135deg, #3b82f6, #6366f1));
    border-radius: var(--radius-md, 0.75rem);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.shell-sidebar-logo svg {
    width: 20px;
    height: 20px;
    color: white;
}

.shell-sidebar-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
}

.shell-sidebar.collapsed .shell-sidebar-title {
    display: none;
}

.shell-sidebar-collapse {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-tertiary);
    padding: 6px;
    border-radius: var(--radius-sm, 0.375rem);
    transition: all var(--transition-fast);
}

.shell-sidebar-collapse:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.shell-sidebar.collapsed .shell-sidebar-header {
    flex-direction: column;
    align-items: center;
    padding: 16px 8px 12px;
    gap: 8px;
}

.shell-sidebar.collapsed .shell-sidebar-logo {
    cursor: pointer;
}

.shell-sidebar.collapsed .shell-sidebar-collapse {
    margin-left: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.shell-sidebar.collapsed .shell-sidebar-collapse svg {
    transform: rotate(180deg);
}

/* Sidebar Navigation */
.shell-sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.shell-nav-section {
    margin-top: 16px;
}

.shell-nav-section:first-child {
    margin-top: 0;
}

.shell-nav-section-title {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    padding: 4px 12px 8px;
    white-space: nowrap;
    overflow: hidden;
}

.shell-sidebar.collapsed .shell-nav-section-title {
    font-size: 0;
    padding: 4px 0;
    border-top: 1px solid var(--border-color);
}

.shell-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md, 0.75rem);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    white-space: nowrap;
    overflow: hidden;
    position: relative;
}

.shell-nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.shell-nav-item:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.shell-nav-item.active {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
    font-weight: 600;
}

[data-theme="dark"] .shell-nav-item.active {
    background: rgba(96, 165, 250, 0.15);
}

.shell-nav-item-label {
    flex: 1;
}

.shell-sidebar.collapsed .shell-nav-item-label {
    display: none;
}

.shell-sidebar.collapsed .shell-nav-item {
    justify-content: center;
    padding: 10px;
}

/* Sidebar Footer */
.shell-sidebar-footer {
    padding: 12px 10px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

/* ============================================
   Menu Sheet (Mobile slide-up)
   ============================================ */
.shell-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 950;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

.shell-menu-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.shell-menu-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border-radius: var(--radius-xl, 1.5rem) var(--radius-xl, 1.5rem) 0 0;
    z-index: 951;
    max-height: 70vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform var(--transition-normal);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.shell-menu-sheet.visible {
    transform: translateY(0);
}

.shell-menu-handle {
    width: 36px;
    height: 4px;
    background: var(--gray-300);
    border-radius: 2px;
    margin: 10px auto 8px;
}

.shell-menu-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 8px 16px 24px;
}

.shell-menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 8px;
    border-radius: var(--radius-lg, 1rem);
    text-decoration: none;
    color: var(--text-primary);
    transition: background var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.shell-menu-item:active {
    background: var(--hover-bg);
}

.shell-menu-item-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md, 0.75rem);
    display: flex;
    align-items: center;
    justify-content: center;
}

.shell-menu-item-icon svg {
    width: 22px;
    height: 22px;
    color: white;
}

.shell-menu-item-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    color: var(--text-secondary);
}

/* Menu item icon colors */
.shell-menu-item-icon.contas { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.shell-menu-item-icon.orcamentos { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.shell-menu-item-icon.metas { background: linear-gradient(135deg, #f59e0b, #d97706); }
.shell-menu-item-icon.categorias { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.shell-menu-item-icon.recorrentes { background: linear-gradient(135deg, #22c55e, #16a34a); }
.shell-menu-item-icon.faturas { background: linear-gradient(135deg, #ec4899, #db2777); }
.shell-menu-item-icon.familia { background: linear-gradient(135deg, #f97316, #ea580c); }
.shell-menu-item-icon.previsao { background: linear-gradient(135deg, #14b8a6, #0d9488); }
.shell-menu-item-icon.subscricoes { background: linear-gradient(135deg, #a855f7, #9333ea); }
.shell-menu-item-icon.relatorios { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.shell-menu-item-icon.config { background: linear-gradient(135deg, #64748b, #475569); }

/* ============================================
   Overrides: Hide old navigation elements
   ============================================ */
.shell-page .btn-add {
    display: none !important;
}

/* Period selector in header stays visible */
.shell-page header {
    margin-bottom: 1.5rem;
}

/* ============================================
   Sidebar Collapsed Tooltips (right-side)
   ============================================ */
.shell-sidebar.collapsed .shell-nav-item[data-tooltip] {
    overflow: visible;
}

.shell-sidebar:not(.collapsed) .shell-nav-item[data-tooltip]::before,
.shell-sidebar:not(.collapsed) .shell-nav-item[data-tooltip]::after {
    display: none;
}

.shell-sidebar.collapsed .shell-nav-item[data-tooltip]::before {
    left: calc(100% + 8px);
    bottom: auto;
    top: 50%;
    transform: translateY(-50%);
}

.shell-sidebar.collapsed .shell-nav-item[data-tooltip]:hover::before {
    transform: translateY(-50%);
}

.shell-sidebar.collapsed .shell-nav-item[data-tooltip]::after {
    left: calc(100% + 3px);
    bottom: auto;
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-right-color: var(--gray-900, #0f172a);
    border-top-color: transparent;
}

[data-theme="dark"] .shell-sidebar.collapsed .shell-nav-item[data-tooltip]::after {
    border-right-color: #f1f5f9;
}

/* ============================================
   Dark Mode Adjustments
   ============================================ */
[data-theme="dark"] .shell-bottom-bar {
    background: rgba(30, 41, 59, 0.95);
    border-top-color: rgba(51, 65, 85, 0.8);
}

[data-theme="dark"] .shell-sidebar {
    background: var(--card-bg);
    border-right-color: var(--border-color);
}

[data-theme="dark"] .shell-fab {
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
}

[data-theme="dark"] .shell-fab-option {
    background: var(--card-bg);
    border-color: var(--border-color);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .shell-menu-sheet {
    background: var(--card-bg);
}

[data-theme="dark"] .shell-menu-handle {
    background: var(--gray-200);
}

/* ============================================
   Animations
   ============================================ */
@keyframes shell-tab-bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.shell-tab.active svg {
    animation: shell-tab-bounce 0.3s ease;
}
