/* ========================================
   FINCONTROL PRO - MOBILE STYLES
   Responsivo: Mobile < 768px | Tablet 768–1024px | Desktop > 1024px
   ======================================== */

/* ========================================
   PWA / BASE MOBILE
   ======================================== */
@media (max-width: 1024px) {
    .sidebar-toggle {
        display: flex !important;
    }

    .sidebar {
        transform: translateX(-100%);
        z-index: 200;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.7);
        backdrop-filter: blur(2px);
        z-index: 199;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 1.25rem;
        padding-bottom: 90px;
        /* espaço para bottom nav */
    }
}

/* ========================================
   TABLET (768px – 1024px)
   ======================================== */
@media (min-width: 768px) and (max-width: 1024px) {
    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .bottom-nav {
        display: none !important;
    }
}

/* ========================================
   MOBILE (< 768px)
   ======================================== */
@media (max-width: 767px) {

    /* Base */
    body {
        font-size: 14px;
    }

    .main-content {
        padding: 1rem;
        padding-bottom: 90px;
    }

    /* Header */
    .main-header {
        flex-wrap: wrap;
        gap: 0.75rem;
        margin-bottom: 1.25rem;
    }

    .page-title {
        font-size: 1.4rem;
    }

    .header-right {
        width: 100%;
        justify-content: space-between;
        gap: 0.5rem;
    }

    .exchange-rate {
        font-size: 0.75rem;
        padding: 0.4rem 0.75rem;
    }

    .btn-large {
        padding: 0.75rem 1.1rem;
        font-size: 0.9rem;
    }

    /* Summary Cards — 2 colunas no mobile */
    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
        margin-bottom: 1.25rem;
    }

    .card-value {
        font-size: 1.25rem;
    }

    .card-icon {
        width: 36px;
        height: 36px;
        margin-bottom: 0.5rem;
    }

    /* Dashboard Grid — coluna única */
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-bottom: 1.25rem;
    }

    .chart-container {
        height: 220px;
    }

    /* Upcoming items */
    .upcoming-item {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .upcoming-value {
        margin-right: 0;
        font-size: 0.9rem;
    }

    /* Modais → Bottom Sheet */
    .modal {
        align-items: flex-end;
    }

    .modal-content {
        max-width: 100%;
        width: 100%;
        border-radius: 20px 20px 0 0;
        max-height: 92vh;
        overflow-y: auto;
        animation: slideUp 0.3s ease forwards;
    }

    @keyframes slideUp {
        from {
            transform: translateY(100%);
            opacity: 0;
        }

        to {
            transform: translateY(0);
            opacity: 1;
        }
    }

    /* Forms */
    .form-row {
        flex-direction: column;
        gap: 0;
    }

    /* Tables → Lista de cards */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px;
    }

    /* Cards das páginas internas */
    .card {
        padding: 1rem;
    }

    .card-header {
        margin-bottom: 1rem;
    }

    /* Filtros */
    .filter-buttons {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        padding-bottom: 4px;
    }

    .filter-buttons .btn {
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Budget grid */
    .budget-grid,
    .categories-grid {
        grid-template-columns: 1fr;
    }

    /* Reports grid */
    .reports-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Stats grid */
    .stats-grid {
        grid-template-columns: 1fr;
    }

    /* Settings layout */
    .settings-layout {
        flex-direction: column;
    }

    .settings-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding-bottom: 1rem;
    }

    .settings-tabs {
        flex-direction: row;
        overflow-x: auto;
        gap: 0.25rem;
    }

    .settings-tab {
        white-space: nowrap;
        flex-shrink: 0;
    }
}

/* ========================================
   BOTTOM NAVIGATION BAR
   ======================================== */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 150;
    padding: 0 0.5rem;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    /* iOS notch */
}

.bottom-nav-items {
    display: flex;
    align-items: center;
    justify-content: space-around;
    height: 100%;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 0.5rem 0.75rem;
    border-radius: 12px;
    text-decoration: none;
    color: var(--text-muted);
    transition: all 0.2s ease;
    position: relative;
    min-width: 56px;
    border: none;
    background: transparent;
    cursor: pointer;
}

.bottom-nav-item i {
    width: 22px;
    height: 22px;
    transition: transform 0.2s ease;
}

.bottom-nav-item span {
    font-size: 0.65rem;
    font-weight: 500;
    font-family: var(--font-main);
}

.bottom-nav-item.active {
    color: var(--primary-color);
}

.bottom-nav-item.active i {
    transform: scale(1.15);
}

.bottom-nav-item.active::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 3px;
    background: var(--primary-color);
    border-radius: 0 0 4px 4px;
}

.bottom-nav-item:hover {
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.04);
}

/* FAB - Floating Action Button central */
.fab-nav {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), #a855f7);
    color: white !important;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
    margin-top: -16px;
    min-width: auto !important;
    padding: 0 !important;
}

.fab-nav i {
    width: 24px !important;
    height: 24px !important;
    margin: 0;
}

.fab-nav:hover {
    background: linear-gradient(135deg, var(--primary-dark), #9333ea) !important;
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.fab-nav::before {
    display: none !important;
}

@media (max-width: 1024px) {
    .bottom-nav {
        display: flex;
    }
}

/* SPINNING ICON (Loader) */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.spin {
    display: inline-block;
    animation: spin 1s linear infinite;
}

/* ========================================
   PULL-TO-REFRESH INDICATOR
   ======================================== */
.ptr-indicator {
    display: none;
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    font-size: 0.8rem;
    z-index: 300;
    gap: 0.5rem;
    align-items: center;
}

.ptr-indicator.visible {
    display: flex;
}