/* ===== CSS Variables & Theming ===== */
:root {
    --font: 'Plus Jakarta Sans', sans-serif;
}

[data-theme="dark"] {
    --bg-primary: #0a0a0f;
    --bg-secondary: rgba(255, 255, 255, 0.03);
    --bg-card: rgba(255, 255, 255, 0.05);
    --bg-card-hover: rgba(255, 255, 255, 0.08);
    --bg-input: rgba(255, 255, 255, 0.06);
    --border: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(139, 92, 246, 0.5);
    --text-primary: #f1f1f4;
    --text-secondary: #8b8b9e;
    --text-muted: #55556a;
    --accent: #8b5cf6;
    --accent-glow: rgba(139, 92, 246, 0.25);
    --income: #34d399;
    --income-bg: rgba(52, 211, 153, 0.1);
    --income-border: rgba(52, 211, 153, 0.2);
    --expense: #f87171;
    --expense-bg: rgba(248, 113, 113, 0.1);
    --expense-border: rgba(248, 113, 113, 0.2);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.5);
    --blob-1: rgba(139, 92, 246, 0.15);
    --blob-2: rgba(59, 130, 246, 0.1);
    --scrollbar-track: rgba(255, 255, 255, 0.02);
    --scrollbar-thumb: rgba(255, 255, 255, 0.08);
    --delete-bg: rgba(248, 113, 113, 0.15);
    --empty-icon: rgba(139, 92, 246, 0.15);
}

[data-theme="light"] {
    --bg-primary: #f0f0f5;
    --bg-secondary: rgba(0, 0, 0, 0.02);
    --bg-card: rgba(255, 255, 255, 0.7);
    --bg-card-hover: rgba(255, 255, 255, 0.9);
    --bg-input: rgba(0, 0, 0, 0.04);
    --border: rgba(0, 0, 0, 0.08);
    --border-focus: rgba(109, 40, 217, 0.4);
    --text-primary: #1a1a2e;
    --text-secondary: #6b6b80;
    --text-muted: #9b9bb0;
    --accent: #7c3aed;
    --accent-glow: rgba(124, 58, 237, 0.2);
    --income: #059669;
    --income-bg: rgba(5, 150, 105, 0.08);
    --income-border: rgba(5, 150, 105, 0.15);
    --expense: #dc2626;
    --expense-bg: rgba(220, 38, 38, 0.08);
    --expense-border: rgba(220, 38, 38, 0.15);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.12);
    --blob-1: rgba(139, 92, 246, 0.08);
    --blob-2: rgba(59, 130, 246, 0.06);
    --scrollbar-track: rgba(0, 0, 0, 0.02);
    --scrollbar-thumb: rgba(0, 0, 0, 0.1);
    --delete-bg: rgba(220, 38, 38, 0.1);
    --empty-icon: rgba(124, 58, 237, 0.1);
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background 0.5s ease, color 0.4s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}
::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}

/* ===== Ambient Background ===== */
.ambient-background {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.8;
    animation: blobFloat 20s ease-in-out infinite;
}

.blob-1 {
    width: 500px;
    height: 500px;
    background: var(--blob-1);
    top: -10%;
    right: -5%;
    animation-delay: 0s;
}

.blob-2 {
    width: 400px;
    height: 400px;
    background: var(--blob-2);
    bottom: -10%;
    left: -5%;
    animation-delay: -10s;
}

@keyframes blobFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(30px, -50px) scale(1.05); }
    50% { transform: translate(-20px, 20px) scale(0.95); }
    75% { transform: translate(40px, 30px) scale(1.02); }
}

/* ===== App Container ===== */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 520px;
    margin: 0 auto;
    padding: 24px 20px 60px;
    min-height: 100vh;
}

/* ===== Header ===== */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    animation: fadeSlideDown 0.6s ease-out;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.logo h2 {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--text-primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.theme-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.theme-btn:hover {
    background: var(--bg-card-hover);
    color: var(--accent);
    border-color: var(--accent-glow);
    transform: rotate(15deg);
}

/* ===== Dashboard ===== */
.dashboard {
    margin-bottom: 28px;
    animation: fadeSlideDown 0.7s ease-out;
}

.balance-card {
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 28px;
    text-align: center;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.balance-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), #6366f1, #06b6d4);
    border-radius: 20px 20px 0 0;
}

.balance-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.balance-card h3 {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 8px;
}

.balance-card h1 {
    font-size: 2.6rem;
    font-weight: 800;
    letter-spacing: -1.5px;
    transition: color 0.3s ease;
}

.balance-card h1.positive {
    color: var(--income);
}
.balance-card h1.negative {
    color: var(--expense);
}
.balance-card h1.zero {
    color: var(--text-muted);
}

/* ===== Summary Cards ===== */
.summary-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.summary-card {
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.summary-card.income {
    border-color: var(--income-border);
}
.summary-card.expense {
    border-color: var(--expense-border);
}

.icon-circle {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.summary-card.income .icon-circle {
    background: var(--income-bg);
    color: var(--income);
}

.summary-card.expense .icon-circle {
    background: var(--expense-bg);
    color: var(--expense);
}

.summary-text h4 {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.summary-text p {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.summary-card.income .summary-text p {
    color: var(--income);
}
.summary-card.expense .summary-text p {
    color: var(--expense);
}

/* ===== Main Content ===== */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ===== Add Transaction Form ===== */
.add-transaction {
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 24px;
    box-shadow: var(--shadow);
    animation: fadeSlideUp 0.6s ease-out;
    transition: all 0.3s ease;
}

.add-transaction:hover {
    box-shadow: var(--shadow-lg);
}

.add-transaction h3,
.history h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.add-transaction h3::before {
    content: '';
    width: 4px;
    height: 18px;
    background: linear-gradient(180deg, var(--accent), #6366f1);
    border-radius: 2px;
}

.history h3::before {
    content: '';
    width: 4px;
    height: 18px;
    background: linear-gradient(180deg, #06b6d4, #3b82f6);
    border-radius: 2px;
}

.form-control {
    margin-bottom: 16px;
}

.form-control label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.form-control label small {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-muted);
    font-size: 0.72rem;
}

.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrap i {
    position: absolute;
    left: 14px;
    font-size: 18px;
    color: var(--text-muted);
    pointer-events: none;
    transition: color 0.3s ease;
}

.input-wrap input {
    width: 100%;
    padding: 14px 14px 14px 44px;
    background: var(--bg-input);
    border: 1.5px solid var(--border);
    border-radius: 14px;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 500;
    outline: none;
    transition: all 0.3s ease;
}

.input-wrap input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.input-wrap input:focus {
    border-color: var(--border-focus);
    background: var(--bg-card-hover);
    box-shadow: 0 0 0 4px var(--accent-glow);
}

.input-wrap input:focus + i,
.input-wrap:has(input:focus) i {
    color: var(--accent);
}

/* Remove number input arrows */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] {
    -moz-appearance: textfield;
}

.add-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--accent), #6366f1);
    color: #fff;
    font-family: var(--font);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    margin-top: 4px;
}

.add-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.add-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--accent-glow);
}

.add-btn:hover::before {
    opacity: 1;
}

.add-btn:active {
    transform: translateY(0);
}

/* ===== History Section ===== */
.history {
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 24px;
    box-shadow: var(--shadow);
    animation: fadeSlideUp 0.7s ease-out;
    transition: all 0.3s ease;
}

.history:hover {
    box-shadow: var(--shadow-lg);
}

.list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 380px;
    overflow-y: auto;
    padding-right: 4px;
}

.list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 14px;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    animation: fadeSlideIn 0.4s ease-out;
    position: relative;
    overflow: hidden;
}

.list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    border-radius: 0 2px 2px 0;
    transition: background 0.3s ease;
}

.list li.plus::before {
    background: var(--income);
}

.list li.minus::before {
    background: var(--expense);
}

.list li:hover {
    background: var(--bg-card-hover);
    transform: translateX(3px);
}

.list li .transaction-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.list li .transaction-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list li .transaction-date {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 400;
}

.list li .transaction-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.list li .transaction-amount {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.list li.plus .transaction-amount {
    color: var(--income);
}

.list li.minus .transaction-amount {
    color: var(--expense);
}

.delete-btn {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    border: none;
    background: var(--delete-bg);
    color: var(--expense);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    opacity: 0;
    transform: scale(0.8);
}

.list li:hover .delete-btn {
    opacity: 1;
    transform: scale(1);
}

.delete-btn:hover {
    background: var(--expense);
    color: #fff;
    transform: scale(1.1) !important;
}

/* ===== Empty State ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    gap: 12px;
}

.empty-state .empty-icon {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    background: var(--empty-icon);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: var(--accent);
    margin-bottom: 4px;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 0.88rem;
    font-weight: 500;
    line-height: 1.5;
}

/* ===== Toast Notification ===== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 24px;
    font-family: var(--font);
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
    opacity: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

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

.toast.error {
    border-color: var(--expense-border);
}

.toast i {
    font-size: 18px;
}

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

.toast.error i {
    color: var(--expense);
}

/* ===== Animations ===== */
@keyframes fadeSlideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateX(-12px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateX(30px) scale(0.95);
        max-height: 0;
        padding: 0 16px;
        margin: 0;
        border-width: 0;
    }
}

/* ===== Responsive ===== */
@media (max-width: 540px) {
    .app-container {
        padding: 16px 14px 50px;
    }
    
    .balance-card h1 {
        font-size: 2.1rem;
    }

    .summary-card {
        padding: 16px;
        gap: 10px;
    }

    .icon-circle {
        width: 38px;
        height: 38px;
        font-size: 18px;
    }

    .summary-text p {
        font-size: 1.05rem;
    }

    .blob-1 {
        width: 300px;
        height: 300px;
    }

    .blob-2 {
        width: 250px;
        height: 250px;
    }
}
