@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
    /* Color Palette - Light Mode */
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --secondary: #94a3b8;
    --success: #10b981;
    --success-light: #d1fae5;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --info: #0ea5e9;
    --dark: #0f172a;
    --dark-lighter: #1e293b;
    --light: #f8fafc;
    --white: #ffffff;

    /* Grays - Refined */
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* Glassmorphism Refined */
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.4);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.08);
    --glass-blur: blur(12px);

    /* Layout */
    --sidebar-width: 280px;
    --header-height: 72px;
    --bottom-nav-height: 75px;
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 28px;
    --radius-xl: 40px;

    /* Shadows Refined */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 12px 24px -6px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.18);
    --shadow-primary: 0 12px 20px -5px rgba(99, 102, 241, 0.35);
}

@media (prefers-color-scheme: dark) {
    :root {
        --light: #0f172a;
        --gray-50: #020617;
        --gray-100: #0f172a;
        --gray-200: #1e293b;
        --gray-300: #334155;
        --gray-400: #64748b;
        --gray-800: #f1f5f9;
        --gray-900: #f8fafc;
        --white: #1e293b;
        --dark: #f8fafc;
        --dark-lighter: #0f172a;

        /* Glassmorphism Dark Refined */
        --glass-bg: rgba(15, 23, 42, 0.7);
        --glass-border: rgba(255, 255, 255, 0.08);
        --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    }
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
    height: 100%;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--gray-800);
    background-color: var(--gray-50);
    height: 100%;
    overflow-x: hidden;
}

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

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 20px;
    border: 3px solid var(--gray-100);
    transition: all 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-light);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--gray-300) var(--gray-100);
}


/* App Container */
.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--dark);
    font-weight: 800;
    letter-spacing: -0.04em;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--dark-lighter);
    color: var(--white);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 2100;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 10px 0 40px rgba(0, 0, 0, 0.1);
    border-right: 1px solid rgba(255, 255, 255, 0.03);
}

.sidebar-header {
    padding: 3rem 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.sidebar-header h2 {
    color: var(--primary-light);
    font-size: 1.85rem;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 4px 10px rgba(99, 102, 241, 0.2));
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1.1rem 1.5rem;
    color: var(--gray-400);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 0.95rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0;
    background: var(--primary-gradient);
    opacity: 0.1;
    transition: width 0.3s ease;
    z-index: -1;
}

.nav-item:hover {
    color: var(--primary-light);
    transform: translateX(6px);
}

.nav-item:hover::before {
    width: 100%;
}

.nav-item.active {
    background: var(--primary-gradient);
    color: var(--white);
    box-shadow: var(--shadow-primary);
}

.nav-item .icon {
    font-size: 1.4rem;
    transition: transform 0.3s ease;
}

.nav-item:hover .icon {
    transform: scale(1.2) rotate(5deg);
}

.sidebar-footer {
    padding: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(0, 0, 0, 0.1);
}

.user-info p {
    font-weight: 800;
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.user-info small {
    color: var(--gray-400);
    font-weight: 500;
}

.btn-logout {
    margin-top: 1.5rem;
    width: 100%;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
    font-weight: 700;
}

.btn-logout:hover {
    background: var(--danger);
    color: var(--white);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 3rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 3rem;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.header h1 {
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--dark) 0%, var(--gray-600) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* Cards & Glassmorphism */
.card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 2.25rem;
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.05), var(--glass-shadow);
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

.card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.05), transparent);
    pointer-events: none;
}

.card:hover {
    transform: translateY(-8px) scale(1.01);
    box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.15), var(--shadow-lg);
    border-color: var(--primary-light);
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 2rem;
}

.charts-grid .card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.charts-grid canvas {
    max-height: 400px;
    width: 100% !important;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.card-header h3 {
    font-size: 1.25rem;
    color: var(--gray-500);
    font-weight: 700;
}

.card-value {
    font-size: 2.75rem;
    font-weight: 900;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

/* Indicators */
.card-income .card-value {
    color: var(--success);
}

.card-expense .card-value {
    color: var(--danger);
}

.card-balance.positive .card-value {
    color: var(--success);
}

.card-balance.negative .card-value {
    color: var(--danger);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1.1rem 2.25rem;
    border-radius: var(--radius-md);
    font-weight: 800;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: none;
    gap: 0.8rem;
    text-decoration: none;
    outline: none;
    user-select: none;
}

.btn-primary {
    background: var(--primary-gradient);
    color: var(--white);
    box-shadow: var(--shadow-primary);
    position: relative;
    z-index: 1;
}

.btn-primary::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent);
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.btn-primary:hover {
    transform: scale(1.05) translateY(-3px);
    box-shadow: 0 18px 35px rgba(99, 102, 241, 0.45);
}

.btn-primary:hover::after {
    opacity: 1;
}

.btn-primary:active {
    transform: scale(0.94) translateY(2px);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}

.btn-small {
    padding: 0.6rem 1.25rem;
    font-size: 0.875rem;
}

/* Tables */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    background: var(--white);
    box-shadow: var(--shadow);
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table th {
    background: var(--gray-50);
    padding: 1.25rem 1.5rem;
    text-align: left;
    font-size: 0.8rem;
    text-transform: uppercase;
    font-weight: 800;
    color: var(--gray-500);
    letter-spacing: 0.1em;
}

.table td {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--gray-100);
    font-size: 1rem;
    font-weight: 600;
}

.table tr {
    transition: all 0.2s ease;
}

.table tr:hover td {
    background: rgba(99, 102, 241, 0.04);
}

.table tr:hover {
    transform: scale(1.002) translateX(4px);
}

/* Amount Styling */
.amount {
    white-space: nowrap;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.amount.income {
    color: var(--success);
}

.amount.expense {
    color: var(--danger);
}

/* Badges */
.badge {
    padding: 0.4rem 1rem;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-type.income {
    background: var(--success-light);
    color: var(--success);
}

.badge-type.expense {
    background: var(--danger-light);
    color: var(--danger);
}

/* Forms */
.form-group {
    margin-bottom: 2rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.75rem;
    font-weight: 800;
    color: var(--gray-700);
    font-size: 0.9rem;
}

input,
select,
textarea {
    width: 100%;
    padding: 1.15rem 1.4rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--white);
    color: var(--gray-900);
    box-shadow: var(--shadow-sm);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 5px rgba(99, 102, 241, 0.15);
    transform: translateY(-2px);
}

/* Mobile Components */
.hamburger-btn {
    display: none;
    position: fixed;
    top: 1.25rem;
    left: 1.25rem;
    z-index: 1100;
    background: var(--white);
    border: 1px solid var(--gray-200);
    width: 48px;
    height: 48px;
    border-radius: 14px;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.hamburger-icon {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 24px;
    height: 24px;
}

.hamburger-icon span {
    display: block;
    width: 22px;
    height: 2.5px;
    background: var(--primary);
    border-radius: 4px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.hamburger-btn.active .hamburger-icon span:nth-child(1) {
    transform: translateY(7.5px) rotate(45deg);
}

.hamburger-btn.active .hamburger-icon span:nth-child(2) {
    opacity: 0;
    transform: translateX(-10px);
}

.hamburger-btn.active .hamburger-icon span:nth-child(3) {
    transform: translateY(-7.5px) rotate(-45deg);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.4s;
}

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

.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--glass-bg);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-top: 1px solid var(--glass-border);
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.1);
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    color: var(--gray-400);
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 800;
    transition: all 0.3s;
    flex: 1;
    position: relative;
}

.mobile-nav-item.active {
    color: var(--primary);
    text-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
}

.mobile-nav-item.active::after {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 35px;
    height: 4px;
    background: var(--primary);
    border-radius: 0 0 100px 100px;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.6);
}

.mobile-nav-item .icon {
    font-size: 1.5rem;
    transition: transform 0.3s ease;
}

.mobile-nav-item.logout {
    color: var(--danger);
}

.mobile-nav-item.logout.active::after {
    background: var(--danger);
}

.mobile-nav-item:active .icon {
    transform: scale(0.8);
}

/* FAB */
.fab {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + 1.5rem);
    right: 1.5rem;
    width: 60px;
    height: 60px;
    border-radius: 18px;
    background: var(--primary-gradient);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    box-shadow: 0 10px 25px rgba(99, 102, 241, 0.4);
    z-index: 999;
    text-decoration: none;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.fab:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 15px 35px rgba(99, 102, 241, 0.5);
}

.fab:active {
    transform: scale(0.9);
}

/* Responsividade */
@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }

    .main-content {
        padding: 2rem;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        width: 300px;
        border-radius: 0 32px 32px 0;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .hamburger-btn {
        display: flex;
    }

    .main-content {
        padding: 6rem 1.5rem 8rem 1.5rem;
    }

    .header h1 {
        font-size: 2rem;
    }

    .mobile-nav {
        display: flex;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .charts-grid canvas {
        max-height: 300px;
    }

    .cards-grid {
        grid-template-columns: 1fr;
    }

    .card-value {
        font-size: 2.25rem;
    }

    .header-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .card {
        padding: 1.25rem;
    }

    .table th,
    .table td {
        padding: 1rem 0.75rem;
        font-size: 0.9rem;
    }

    .btn-primary.desktop-only {
        display: none;
    }
}

/* Auth Pages */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--dark-lighter);
    padding: 1.5rem;
}

.auth-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    padding: 3.5rem 2.5rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--glass-border);
    width: 100%;
    max-width: 440px;
}

.auth-card h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    text-align: center;
}

.subtitle {
    color: var(--gray-500);
    margin-bottom: 3rem;
    font-weight: 700;
    text-align: center;
}

/* Alerts */
.alert {
    padding: 1.25rem 1.5rem;
    border-radius: var(--radius-md);
    margin-bottom: 2rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 1rem;
    animation: slideDown 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes slideDown {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.main-content>* {
    animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.main-content>*:nth-child(1) {
    animation-delay: 0.1s;
}

.main-content>*:nth-child(2) {
    animation-delay: 0.2s;
}

.main-content>*:nth-child(3) {
    animation-delay: 0.3s;
}

.main-content>*:nth-child(4) {
    animation-delay: 0.4s;
}

/* Categories Page */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.category-card {
    background: var(--white);
    padding: 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    justify-content: center;
    transition: all 0.3s ease;
}

.category-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow);
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.category-header h4 {
    margin: 0;
    font-size: 1.1rem;
}

.category-actions {
    display: flex;
    gap: 0.5rem;
}

@media (max-width: 768px) {
    .categories-grid {
        grid-template-columns: 1fr;
    }
}

/* Bulk Actions Bar */
.bulk-actions-bar {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(150%);
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    padding: 15px 25px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
    opacity: 0;
}

.bulk-actions-bar.active {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.bulk-info {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary);
}

.bulk-btns {
    display: flex;
    gap: 10px;
}

/* Checkbox Customization */
.table input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
    border-radius: 4px;
}

tr.selected {
    background: rgba(99, 102, 241, 0.05) !important;
}

/* Mobile Adjustments for Bulk Bar */
@media (max-width: 768px) {
    .bulk-actions-bar {
        bottom: 110px;
        width: 90%;
        padding: 12px 20px;
        flex-direction: column;
        gap: 10px;
        border-radius: 20px;
    }


    .bulk-btns {
        width: 100%;
        justify-content: center;
    }
}