/* ─── FinanceFlow: Custom Styles ─────────────────────────── */

/* ─── CSS Custom Properties ─────────────────────────────── */
:root {
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.3);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.06);
    --gradient-primary: linear-gradient(135deg, #8B5CF6 0%, #06B6D4 100%);
    --gradient-income: linear-gradient(135deg, #10B981 0%, #06B6D4 100%);
    --gradient-expense: linear-gradient(135deg, #F43F5E 0%, #F97316 100%);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dark {
    --glass-bg: rgba(255, 255, 255, 0.04);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* ─── Base resets ────────────────────────────────────────── */
[x-cloak] {
    display: none !important;
}

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

html {
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* ─── Custom scrollbar ───────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.3);
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 92, 246, 0.5);
}

.dark ::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.2);
}

/* ─── Glassmorphism cards ────────────────────────────────── */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 1rem;
    transition: var(--transition-smooth);
}

.glass-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1);
}

.dark .glass-card:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

/* ─── Gradient cards ─────────────────────────────────────── */
.card-balance {
    background: var(--gradient-primary);
    color: white;
    position: relative;
    overflow: hidden;
}

.card-balance::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -30%;
    width: 200px;
    height: 200px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

.card-balance::after {
    content: '';
    position: absolute;
    bottom: -40%;
    left: -20%;
    width: 150px;
    height: 150px;
    background: rgba(255, 255, 255, 0.07);
    border-radius: 50%;
}

.card-income {
    border-left: 4px solid #10B981;
}

.card-expense {
    border-left: 4px solid #F43F5E;
}

/* ─── Animations ─────────────────────────────────────────── */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(100%);
    }

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

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: 0 0 20px rgba(139, 92, 246, 0.3);
    }

    50% {
        box-shadow: 0 0 40px rgba(139, 92, 246, 0.6);
    }
}

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

    100% {
        background-position: 200% 0;
    }
}

@keyframes countUp {
    from {
        opacity: 0.3;
    }

    to {
        opacity: 1;
    }
}

.anim-fade-in-up {
    animation: fadeInUp 0.5s ease-out both;
}

.anim-fade-in {
    animation: fadeIn 0.4s ease-out both;
}

.anim-scale-in {
    animation: scaleIn 0.3s ease-out both;
}

.anim-slide-up {
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.anim-delay-1 {
    animation-delay: 0.05s;
}

.anim-delay-2 {
    animation-delay: 0.1s;
}

.anim-delay-3 {
    animation-delay: 0.15s;
}

.anim-delay-4 {
    animation-delay: 0.2s;
}

.anim-delay-5 {
    animation-delay: 0.25s;
}

/* ─── Skeleton loading ───────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 37%, #e2e8f0 63%);
    background-size: 400% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 0.5rem;
}

.dark .skeleton {
    background: linear-gradient(90deg, #1e293b 25%, #334155 37%, #1e293b 63%);
    background-size: 400% 100%;
}

/* ─── Modal ──────────────────────────────────────────────── */
.modal-backdrop {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: opacity 0.3s ease;
}

.modal-content {
    animation: scaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@media (max-width: 640px) {
    .modal-content {
        animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
        border-radius: 1.5rem 1.5rem 0 0;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* ─── FAB (Floating Action Button) ───────────────────────── */
.fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
    transition: var(--transition-smooth);
    z-index: 40;
    border: none;
}

.fab:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 6px 30px rgba(139, 92, 246, 0.6);
}

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

/* ─── Transaction items ──────────────────────────────────── */
.tx-item {
    transition: var(--transition-smooth);
    position: relative;
}

.tx-item:hover {
    background: rgba(139, 92, 246, 0.04);
}

.dark .tx-item:hover {
    background: rgba(139, 92, 246, 0.08);
}

.tx-item::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 4rem;
    right: 1rem;
    height: 1px;
    background: rgba(0, 0, 0, 0.05);
}

.dark .tx-item::after {
    background: rgba(255, 255, 255, 0.05);
}

/* ─── Period toggle buttons ──────────────────────────────── */
.period-btn {
    padding: 0.375rem 0.875rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    transition: var(--transition-smooth);
    cursor: pointer;
    border: none;
    background: transparent;
}

.period-btn.active {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 2px 12px rgba(139, 92, 246, 0.4);
}

/* ─── Type toggle ────────────────────────────────────────── */
.type-toggle {
    display: flex;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 0.75rem;
    padding: 4px;
    gap: 4px;
}

.dark .type-toggle {
    background: rgba(255, 255, 255, 0.06);
}

.type-toggle button {
    flex: 1;
    padding: 0.5rem 1rem;
    border-radius: 0.625rem;
    font-weight: 500;
    font-size: 0.875rem;
    transition: var(--transition-smooth);
    cursor: pointer;
    border: none;
    background: transparent;
}

.type-toggle button.active-income {
    background: #10B981;
    color: white;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}

.type-toggle button.active-expense {
    background: #F43F5E;
    color: white;
    box-shadow: 0 2px 8px rgba(244, 63, 94, 0.4);
}

/* ─── Form input styles ──────────────────────────────────── */
.form-input {
    transition: var(--transition-smooth);
    border: 1.5px solid rgba(0, 0, 0, 0.08);
}

.dark .form-input {
    border-color: rgba(255, 255, 255, 0.1);
}

.form-input:focus {
    border-color: #8B5CF6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
    outline: none;
}

/* ─── Toast notifications ────────────────────────────────── */
.toast {
    animation: slideUp 0.3s ease-out, fadeIn 0.3s ease-out;
}

.toast-exit {
    animation: fadeIn 0.3s ease-out reverse;
}

/* ─── Dark mode toggle ───────────────────────────────────── */
.theme-toggle {
    width: 48px;
    height: 26px;
    border-radius: 13px;
    background: #e2e8f0;
    position: relative;
    cursor: pointer;
    transition: var(--transition-smooth);
    border: none;
    padding: 0;
}

.dark .theme-toggle {
    background: #4c1d95;
}

.theme-toggle::after {
    content: '☀️';
    font-size: 14px;
    position: absolute;
    left: 3px;
    top: 2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.dark .theme-toggle::after {
    content: '🌙';
    transform: translateX(22px);
}

/* ─── Filter/tag chips ───────────────────────────────────── */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    background: rgba(139, 92, 246, 0.1);
    color: #8B5CF6;
    transition: var(--transition-smooth);
}

.dark .chip {
    background: rgba(139, 92, 246, 0.2);
}

.chip:hover {
    background: rgba(139, 92, 246, 0.2);
}

/* ─── Number formatting ──────────────────────────────────── */
.amount-income {
    color: #10B981;
}

.amount-expense {
    color: #F43F5E;
}

/* ─── Charts container ───────────────────────────────────── */
.chart-container {
    position: relative;
    height: 280px;
    width: 100%;
}

@media (max-width: 640px) {
    .chart-container {
        height: 220px;
    }
}

/* ─── Empty state ────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
    animation: pulse-glow 2s infinite;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    background: rgba(139, 92, 246, 0.1);
}

/* ─── Responsive grid for summary cards ──────────────────── */
.summary-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 640px) {
    .summary-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 1024px) {
    .summary-grid {
        grid-template-columns: 2fr 1fr 1fr;
    }
}

/* ─── Responsive grid for charts ─────────────────────────── */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 768px) {
    .charts-grid {
        grid-template-columns: 1.5fr 1fr;
    }
}

/* ─── Ripple effect ──────────────────────────────────────── */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.ripple:active::before {
    width: 300px;
    height: 300px;
}

/* ─── Subtle background pattern ──────────────────────────── */
.bg-pattern {
    background-image: radial-gradient(circle at 25% 10%, rgba(139, 92, 246, 0.04) 0%, transparent 50%),
        radial-gradient(circle at 75% 80%, rgba(6, 182, 212, 0.04) 0%, transparent 50%);
}

.dark .bg-pattern {
    background-image: radial-gradient(circle at 25% 10%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 75% 80%, rgba(6, 182, 212, 0.06) 0%, transparent 50%);
}

/* ─── Offline indicator ──────────────────────────────────── */
.offline-bar {
    background: linear-gradient(90deg, #F59E0B, #F97316);
    color: white;
    text-align: center;
    padding: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
}

/* ─── Install prompt ─────────────────────────────────────── */
.install-prompt {
    background: var(--gradient-primary);
    color: white;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.875rem;
}

.install-prompt button {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    padding: 0.375rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    white-space: nowrap;
}

/* ─── Wallet cards ───────────────────────────────────────── */
.wallet-scroll {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.wallet-scroll::-webkit-scrollbar {
    display: none;
}

.wallet-card {
    flex-shrink: 0;
    width: 10.5rem;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.wallet-card:hover {
    transform: translateY(-3px) scale(1.02);
}

/* ─── Emoji picker grid ──────────────────────────────────── */
.emoji-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
    gap: 4px;
    max-height: 140px;
    overflow-y: auto;
}

.emoji-grid button {
    width: 36px;
    height: 36px;
    border-radius: 0.5rem;
    border: 2px solid transparent;
    background: transparent;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.emoji-grid button:hover {
    background: rgba(139, 92, 246, 0.1);
}

.emoji-grid button.selected {
    border-color: #8B5CF6;
    background: rgba(139, 92, 246, 0.15);
}

/* ─── Color picker row ───────────────────────────────────── */
.color-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.color-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: var(--transition-smooth);
}

.color-dot:hover {
    transform: scale(1.2);
}

.color-dot.selected {
    border-color: white;
    box-shadow: 0 0 0 2px #8B5CF6;
}

/* ─── Category list item ─────────────────────────────────── */
.cat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    transition: var(--transition-smooth);
}

.cat-item:hover {
    background: rgba(139, 92, 246, 0.05);
}

.dark .cat-item:hover {
    background: rgba(139, 92, 246, 0.1);
}

/* ─── Insight Cards ─────────────────────────────────────── */
.insight-scroll {
    scrollbar-width: none;
}

.insight-scroll::-webkit-scrollbar {
    display: none;
}

.insight-card {
    border-left: 3px solid rgba(139, 92, 246, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.insight-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.15);
}

.dark .insight-card {
    border-left-color: rgba(139, 92, 246, 0.6);
}