/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #ec4899;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --warning-color: #f59e0b;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

body {
    font-family: 'Kanit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Flash Messages */
.flash-messages {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    max-width: 400px;
}

.flash {
    padding: 16px 20px;
    border-radius: 12px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
}

.flash-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.flash-error {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

.flash button {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0 0 0 10px;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Auth Pages */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.auth-card {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header .logo {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 36px;
    color: white;
}

.auth-header h1 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 8px;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 15px;
}

.auth-form .form-group {
    margin-bottom: 20px;
}

.auth-form label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.auth-form label i {
    color: var(--primary-color);
}

.auth-form input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 15px;
    transition: all 0.3s ease;
    font-family: inherit;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.auth-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
}

.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-outline:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-full {
    width: 100%;
    padding: 16px;
}

.btn-delete {
    background: none;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.btn-delete:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Dashboard */
.dashboard-container {
    min-height: 100vh;
}

.navbar {
    background: var(--card-bg);
    padding: 16px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 600;
    color: var(--primary-color);
}

.nav-brand i {
    font-size: 28px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 10px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

.nav-link:hover {
    background: var(--bg-color);
    color: var(--primary-color);
}

.nav-link.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-user span {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}

.dashboard-content {
    padding: 32px;
    max-width: 1400px;
    margin: 0 auto;
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease;
}

.card:hover {
    transform: translateY(-4px);
}

.card-icon {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

.card-income .card-icon {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.card-expense .card-icon {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.card-balance .card-icon {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info-color);
}

.card-info h3 {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.card-info .amount {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 32px;
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

.section {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 28px;
    box-shadow: var(--shadow);
}

.section-header {
    margin-bottom: 24px;
}

.section-header h2 {
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-header h2 i {
    color: var(--primary-color);
}

/* Form Styles */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 640px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 15px;
    transition: all 0.3s ease;
    font-family: inherit;
    background: var(--card-bg);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Type Selector */
.type-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.type-option input {
    display: none;
}

.type-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.type-option input:checked + .type-label.income {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--success-color);
    color: var(--success-color);
}

.type-option input:checked + .type-label.expense {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger-color);
    color: var(--danger-color);
}

/* Slip Upload Section */
.slip-upload-section {
    margin-bottom: 24px;
}

.slip-upload-section h3 {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--secondary-color);
}

.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.02);
}

.upload-area.dragover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.upload-placeholder i {
    font-size: 48px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.upload-placeholder p {
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 8px;
}

.upload-hint {
    font-size: 13px;
    color: var(--text-secondary);
}

.ai-result {
    margin-top: 16px;
    padding: 20px;
    background: rgba(99, 102, 241, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.ai-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--primary-color);
}

.ai-loading i {
    font-size: 20px;
}

.divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 24px 0;
}

/* Transaction List */
.transaction-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.transaction-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    border-radius: 16px;
    background: var(--bg-color);
    transition: all 0.3s ease;
}

.transaction-item:hover {
    transform: translateX(4px);
}

.transaction-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.transaction-item.income .transaction-icon {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.transaction-item.expense .transaction-icon {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.transaction-info {
    flex: 1;
}

.transaction-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.transaction-main .category {
    font-weight: 500;
    color: var(--text-primary);
}

.transaction-main .amount {
    font-weight: 600;
    font-size: 16px;
}

.transaction-main .amount.income {
    color: var(--success-color);
}

.transaction-main .amount.expense {
    color: var(--danger-color);
}

.transaction-sub {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--text-secondary);
}

.delete-form {
    margin-left: auto;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 8px;
}

.empty-state span {
    font-size: 14px;
}

/* Statistics Section */
.stats-grid {
    margin-bottom: 32px;
}

.stats-section {
    min-height: 500px;
}

.chart-container {
    height: 300px;
    margin-bottom: 24px;
    position: relative;
}

.stats-table {
    overflow-x: auto;
}

.stats-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.stats-table th,
.stats-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.stats-table th {
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-color);
}

.stats-table td.income {
    color: var(--success-color);
    font-weight: 500;
}

.stats-table td.expense {
    color: var(--danger-color);
    font-weight: 500;
}

.stats-table td.positive {
    color: var(--success-color);
    font-weight: 600;
}

.stats-table td.negative {
    color: var(--danger-color);
    font-weight: 600;
}

.stats-table tr:hover {
    background: var(--bg-color);
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        padding: 16px 20px;
    }

    .nav-brand span {
        display: none;
    }

    .dashboard-content {
        padding: 20px;
    }

    .summary-cards {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 20px;
    }

    .card-info .amount {
        font-size: 24px;
    }

    .section {
        padding: 20px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .chart-container {
        height: 250px;
    }
}
