/* ===== CSS Variables ===== */
:root {
    /* Black & White Palette */
    --color-black: #1a1a1a;
    --color-dark-gray: #2d2d2d;
    --color-medium-gray: #4a4a4a;
    --color-light-gray: #e5e5e5;
    --color-lighter-gray: #f5f5f5;
    --color-white: #ffffff;
    
    /* Light Mode Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-card: #ffffff;
    --bg-hover: #fafafa;
    
    --text-primary: #1a1a1a;
    --text-secondary: #4a4a4a;
    --text-tertiary: #6b6b6b;
    
    --border-color: #e5e5e5;
    --border-hover: #d0d0d0;
    
    --accent-primary: #1a1a1a;
    --accent-secondary: #2d2d2d;
    
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    
    /* Transitions */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Variables */
body.dark-mode {
    --bg-primary: #1a1a1a;
    --bg-secondary: #0f0f0f;
    --bg-card: #2d2d2d;
    --bg-hover: #3a3a3a;
    
    --text-primary: #f5f5f5;
    --text-secondary: #d0d0d0;
    --text-tertiary: #a0a0a0;
    
    --border-color: #3a3a3a;
    --border-hover: #4a4a4a;
    
    --accent-primary: #f5f5f5;
    --accent-secondary: #e5e5e5;
    
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* ===== Icon Visibility ===== */
.light-icon {
    display: block;
}

.dark-icon {
    display: none;
}

body.dark-mode .light-icon {
    display: none;
}

body.dark-mode .dark-icon {
    display: block;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: var(--transition);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== Container ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

/* ===== Header ===== */
.header {
    margin-bottom: 40px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color);
}

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

.logo-icon {
    width: 32px;
    height: 32px;
}

.header h1 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.theme-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
}

.theme-toggle:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
}

.theme-icon {
    width: 20px;
    height: 20px;
}

/* ===== Balance Section ===== */
.balance-section {
    margin-bottom: 32px;
}

.balance-card {
    background: var(--accent-primary);
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    text-align: center;
    color: var(--bg-primary);
    transition: var(--transition);
}

body.dark-mode .balance-card {
    background: var(--accent-primary);
    color: var(--bg-primary);
}

.balance-label {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    opacity: 0.8;
    margin-bottom: 12px;
    font-weight: 500;
}

.balance-amount {
    font-size: 48px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -1px;
}

/* ===== Limit Alert ===== */
.limit-alert {
    background-color: var(--bg-card);
    border: 2px solid var(--accent-primary);
    color: var(--text-primary);
    padding: 16px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: shake 0.5s;
}

.alert-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.limit-alert.hidden {
    display: none;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

/* ===== Form Section ===== */
.form-section {
    background: var(--bg-card);
    padding: 32px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 32px;
    transition: var(--transition);
}

.form-section h3 {
    margin-bottom: 24px;
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 14px;
    letter-spacing: -0.1px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 15px;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: var(--transition);
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(26, 26, 26, 0.05);
}

body.dark-mode .form-group input:focus,
body.dark-mode .form-group select:focus {
    box-shadow: 0 0 0 3px rgba(245, 245, 245, 0.1);
}

.form-group input::placeholder {
    color: var(--text-tertiary);
}

/* ===== Buttons ===== */
.btn {
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
    font-family: inherit;
    letter-spacing: -0.2px;
}

.btn-primary {
    background: var(--accent-primary);
    color: var(--bg-primary);
}

.btn-primary:hover {
    background: var(--accent-secondary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.btn-danger {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    font-size: 13px;
    width: auto;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-danger:hover {
    background: var(--bg-hover);
    border-color: var(--border-hover);
}

.btn-danger-icon {
    width: 16px;
    height: 16px;
}

/* ===== Controls Section ===== */
.controls-section {
    margin-bottom: 24px;
}

.sort-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    padding: 16px 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.sort-controls label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 14px;
    white-space: nowrap;
}

.sort-controls select {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    font-family: inherit;
    transition: var(--transition);
}

.sort-controls select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* ===== Transactions Section ===== */
.transactions-section {
    background: var(--bg-card);
    padding: 32px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 32px;
}

.transactions-section h3 {
    margin-bottom: 24px;
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.transaction-list {
    max-height: 500px;
    overflow-y: auto;
    padding-right: 8px;
}

/* Custom Scrollbar */
.transaction-list::-webkit-scrollbar {
    width: 6px;
}

.transaction-list::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 10px;
}

.transaction-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

.transaction-list::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

.empty-state {
    text-align: center;
    color: var(--text-tertiary);
    padding: 60px 20px;
    font-size: 14px;
}

.transaction-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    margin-bottom: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.transaction-item:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-sm);
}

.transaction-item.highlight {
    border-color: var(--accent-primary);
    background: var(--bg-hover);
}

.transaction-info {
    flex: 1;
}

.transaction-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary);
    margin-bottom: 6px;
    letter-spacing: -0.2px;
}

.transaction-meta {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.transaction-category {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.category-icon {
    width: 16px;
    height: 16px;
}

.transaction-amount {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
    margin-right: 16px;
    letter-spacing: -0.3px;
}

/* ===== Chart Section ===== */
.chart-section {
    background: var(--bg-card);
    padding: 32px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 32px;
}

.chart-section h3 {
    margin-bottom: 24px;
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.chart-container {
    position: relative;
    height: 320px;
    display: flex;
    justify-content: center;
    align-items: center;
    max-width: 100%;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .container {
        padding: 16px;
    }

    .header h1 {
        font-size: 20px;
    }

    .logo-icon {
        width: 28px;
        height: 28px;
    }

    .balance-card {
        padding: 32px 24px;
    }

    .balance-amount {
        font-size: 40px;
    }

    .form-section,
    .transactions-section,
    .chart-section {
        padding: 24px;
    }

    .transaction-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .transaction-amount {
        margin-right: 0;
    }

    .chart-container {
        height: 260px;
        max-width: 320px;
        margin: 0 auto;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 18px;
    }

    .logo-icon {
        width: 24px;
        height: 24px;
    }

    .balance-amount {
        font-size: 36px;
    }

    .sort-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .transaction-meta {
        flex-direction: column;
        gap: 4px;
    }

    .form-section,
    .transactions-section,
    .chart-section {
        padding: 20px;
    }

    .chart-container {
        height: 240px;
        max-width: 280px;
        margin: 0 auto;
    }
}

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

.transaction-item {
    animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Print Styles ===== */
@media print {
    .theme-toggle,
    .btn,
    .sort-controls {
        display: none;
    }
}
