/* ==========================================
   PERSONAL FINANCE MANAGEMENT - COMPLETE CSS
   ========================================== */

:root {
    --primary-color: #00A86B;
    --secondary-color: #6B46C1;
    --accent-color: #FF6B6B;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #17a2b8;
    --dark-color: #343a40;
    --light-color: #f8f9fa;
    --border-color: #dee2e6;
    --text-color: #212529;
    --text-muted: #6c757d;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --border-radius: 8px;
    --transition: all 0.3s ease;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    min-height: 100vh;
    box-shadow: var(--shadow);
}

/* Header Styles */
.header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 1rem 2rem;
    box-shadow: var(--shadow);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 1.8rem;
    font-weight: 600;
}

.header h1 i {
    margin-right: 0.5rem;
}

.header-stats {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    background: white;
    border-bottom: 3px solid var(--light-color);
    padding: 0 2rem;
    overflow-x: auto;
}

.tab-button {
    background: none;
    border: none;
    padding: 1rem 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
    transition: var(--transition);
    color: var(--text-muted);
    border-bottom: 3px solid transparent;
}

.tab-button:hover {
    background: var(--light-color);
    color: var(--primary-color);
}

.tab-button.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: var(--light-color);
}

.tab-button i {
    font-size: 1.1rem;
}

/* Main Content */
.main-content {
    padding: 2rem;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.section-header h2 {
    color: var(--dark-color);
    font-size: 1.5rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.income-card .stat-icon {
    background: var(--success-color);
}

.expense-card .stat-icon {
    background: var(--danger-color);
}

.balance-card .stat-icon {
    background: var(--info-color);
}

.credit-card .stat-icon {
    background: var(--warning-color);
}

.stat-content h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--dark-color);
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.chart-container {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.chart-container h3 {
    margin-bottom: 1rem;
    color: var(--dark-color);
    text-align: center;
}

.chart-container canvas {
    max-height: 300px;
}

/* Filters */
.filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.filters select {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: white;
}

/* Data Tables */
.data-table {
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.table-header {
    background: var(--light-color);
    border-bottom: 2px solid var(--border-color);
}

.table-row {
    display: grid;
    grid-template-columns: 120px 2fr 1fr 1fr 1fr 100px;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    min-height: 50px;
}

.table-row:last-child {
    border-bottom: none;
}

.table-row:hover {
    background: rgba(0, 168, 107, 0.05);
}

.table-cell {
    padding: 1rem;
    border-right: 1px solid var(--border-color);
}

.table-cell:last-child {
    border-right: none;
}

.table-header .table-cell {
    font-weight: 600;
    color: var(--dark-color);
}

.table-footer {
    background: var(--light-color);
    font-weight: bold;
    border-top: 2px solid var(--border-color);
}

/* Amount Styling */
.expense-amount,
.payment-amount {
    color: var(--danger-color);
    font-weight: bold;
}

.income-amount {
    color: var(--success-color);
    font-weight: bold;
}

.expense-total,
.income-total {
    color: var(--dark-color);
    font-weight: bold;
}

/* Credit Cards */
.credit-cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.credit-card-item {
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.credit-card-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.card-header {
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
}

.card-body {
    padding: 1.5rem;
}

.card-stats,
.card-dates {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.card-stats div,
.card-dates div {
    font-size: 0.9rem;
}

.card-features {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.feature-tag {
    background: var(--light-color);
    color: var(--text-muted);
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

/* Loan Items */
.loan-item {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    overflow: hidden;
    box-shadow: var(--shadow);
}

.loan-header {
    background: var(--light-color);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.loan-header h3 {
    margin: 0;
    color: var(--dark-color);
}

.loan-status {
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
}

.status-active {
    background: var(--success-color);
    color: white;
}

.status-completed {
    background: var(--text-muted);
    color: white;
}

.loan-body {
    padding: 1.5rem;
}

.loan-info,
.loan-dates {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.loan-progress {
    margin-top: 1rem;
}

.progress-bar {
    width: 100%;
    height: 15px;
    background: var(--light-color);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success-color), var(--info-color));
    transition: width 0.3s ease;
}

.progress-text {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.loan-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    justify-content: flex-end;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
    font-size: 0.9rem;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #008f5a;
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--text-muted);
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-edit {
    background: var(--info-color);
    color: white;
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

.btn-edit:hover {
    background: #138496;
}

.btn-delete {
    background: var(--danger-color);
    color: white;
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
}

.btn-delete:hover {
    background: #c82333;
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.modal-content {
    background: white;
    margin: 5% auto;
    padding: 2rem;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.modal-close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--light-color);
    color: var(--danger-color);
}

.modal-content h2 {
    margin-bottom: 1.5rem;
    color: var(--dark-color);
    border-bottom: 2px solid var(--light-color);
    padding-bottom: 0.5rem;
}

.modal-content form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.modal-content label {
    font-weight: 500;
    color: var(--dark-color);
    margin-bottom: 0.25rem;
}

.modal-content input,
.modal-content select,
.modal-content textarea {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    transition: var(--transition);
}

.modal-content input:focus,
.modal-content select:focus,
.modal-content textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 168, 107, 0.1);
}

.modal-buttons {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

/* Payment Type Styling */
.debt-info {
    background: var(--light-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1rem;
    margin: 1rem 0;
    font-size: 0.9rem;
}

.debt-info.success {
    background: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.debt-info.error {
    background: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.payment-breakdown {
    background: #e9ecef;
    border-radius: 4px;
    padding: 1rem;
    margin: 1rem 0;
    font-size: 0.9rem;
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    margin: 0.5rem 0;
}

.breakdown-item.total {
    border-top: 1px solid var(--border-color);
    padding-top: 0.5rem;
    margin-top: 0.5rem;
    font-weight: bold;
}

#normal-payment-fields,
#credit-payment-fields,
#loan-payment-fields,
#edit-normal-payment-fields,
#edit-credit-payment-fields,
#edit-loan-payment-fields {
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1rem;
    margin: 1rem 0;
    background: rgba(0, 168, 107, 0.02);
}

/* Notifications */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 4px;
    color: white;
    font-weight: 500;
    z-index: 2000;
    transform: translateX(400px);
    transition: var(--transition);
    max-width: 300px;
}

.notification.show {
    transform: translateX(0);
}

.notification.success {
    background: var(--success-color);
}

.notification.error {
    background: var(--danger-color);
}

.notification.warning {
    background: var(--warning-color);
}

.notification.info {
    background: var(--info-color);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--primary-color);
    border-radius: 50%;
    border-right-color: transparent;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        margin: 0;
        border-radius: 0;
    }

    .header {
        padding: 1rem;
    }

    .header-content {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }

    .main-content {
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .charts-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .credit-cards-container {
        grid-template-columns: 1fr;
    }

    .table-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        padding: 1rem;
    }

    .table-cell {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 0.5rem 0;
    }

    .table-cell:last-child {
        border-bottom: none;
    }

    .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .filters {
        justify-content: center;
    }

    .modal-content {
        margin: 10% auto;
        padding: 1.5rem;
        width: 95%;
    }

    .modal-buttons {
        flex-direction: column;
    }

    .card-stats,
    .card-dates,
    .loan-info,
    .loan-dates {
        grid-template-columns: 1fr;
    }

    .loan-actions,
    .card-actions {
        justify-content: center;
    }

    .nav-tabs {
        padding: 0 1rem;
    }

    .tab-button {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .stat-card {
        flex-direction: column;
        text-align: center;
    }

    .stat-icon {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }

    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }

    .modal-content {
        margin: 5% auto;
        padding: 1rem;
    }
}

/* Print Styles */
@media print {
    .header,
    .nav-tabs,
    .btn,
    .modal {
        display: none !important;
    }

    .container {
        box-shadow: none;
    }

    .main-content {
        padding: 0;
    }

    .chart-container canvas {
        max-height: 200px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus styles for accessibility */
button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
        --border-color: #000;
    }

    .stat-card,
    .chart-container,
    .credit-card-item,
    .loan-item {
        border: 2px solid var(--border-color);
    }
}
/* Dashboard breakdown styling */
.stat-breakdown {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.2);
}

.stat-breakdown small {
    color: rgba(255,255,255,0.8);
    font-size: 0.85em;
}

.balance-card {
    background: linear-gradient(135deg, #28a745, #20c997);
}

.balance-note {
    color: rgba(255,255,255,0.9);
    font-style: italic;
    margin-top: 4px;
    display: block;
}
