/* Custom Styles for Expense Tracker */

:root {
    --income-color: #28a745;
    --expense-color: #dc3545;
    --primary-color: #0d6efd;
}

/* Active Navigation Link */
.navbar-dark .nav-link.active {
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 0.375rem;
    font-weight: 600;
}

.navbar-dark .nav-link.active:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Ensure html and body take full height for footer positioning */
html {
    height: 100%;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
    font-size: 14px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Main content wrapper - takes available space and pushes footer down */
/* Target containers that come after navbar */
.navbar ~ .container,
.navbar ~ .container-fluid {
    flex: 1 0 auto;
}

/* For pages without navbar (like auth pages), ensure content grows */
body > .container:not(.auth-container),
body > .container-fluid:not(.auth-container) {
    flex: 1 0 auto;
}

/* Ensure footer stays at bottom */
.sticky-footer {
    flex-shrink: 0;
    margin-top: auto;
}

/* Navbar z-index to ensure it's above footer */
.navbar {
    z-index: 1030;
    position: relative;
}

/* Username text transform */
.username-text {
    text-transform: capitalize;
}

/* Footer */
.sticky-footer {
    position: relative;
    width: 100%;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-top: 1px solid #e9ecef;
    margin-top: auto;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
}

.footer-text {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #6c757d;
    font-size: 0.875rem;
}

.footer-label {
    font-weight: 400;
}

.footer-link {
    color: var(--primary-color);
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    text-decoration: none;
}

.footer-link i {
    color: #dc3545;
    font-size: 0.75rem;
    animation: heartbeat 2s ease-in-out infinite;
}

.footer-link:hover {
    color: #0056b3;
    transform: translateY(-1px);
}

.footer-link:hover i {
    transform: scale(1.2);
}

@keyframes heartbeat {
    0%, 100% {
        transform: scale(1);
    }
    10%, 30% {
        transform: scale(1.1);
    }
    20%, 40% {
        transform: scale(1);
    }
}

/* Auth Footer (inside login/register cards) */
.auth-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #e9ecef !important;
}

.auth-footer-link {
    color: var(--primary-color);
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 0.25rem;
}

.auth-footer-link i {
    color: #dc3545;
    font-size: 0.75rem;
    animation: heartbeat 2s ease-in-out infinite;
}

.auth-footer-link:hover {
    color: #0056b3;
    transform: translateY(-1px);
}

.auth-footer-link:hover i {
    transform: scale(1.2);
}

/* Income/Expense Color Coding */
.income {
    color: var(--income-color);
    font-weight: 600;
}

.expense {
    color: var(--expense-color);
    font-weight: 600;
}

/* Card Styles */
.card {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    margin-bottom: 1.5rem;
}

.card-header {
    background-color: #fff;
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
    font-size: 1rem;
    padding: 0.75rem 1rem;
}

/* Form Styles */
.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

/* Button Styles */
.btn {
    border-radius: 0.375rem;
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
}

.btn-sm {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

/* Alert Styles */
.alert {
    border-radius: 0.5rem;
    border: none;
    font-size: 0.875rem;
    padding: 0.75rem 1rem;
}

/* Table Styles */
.table {
    background-color: #fff;
    font-size: 0.875rem;
}

.table thead th {
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    font-size: 0.8rem;
    padding: 0.5rem;
    white-space: nowrap;
}

.table tbody td {
    padding: 0.5rem;
    vertical-align: middle;
}

/* Login/Register Page Styles */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 1rem;
}

.auth-card {
    max-width: 450px;
    width: 100%;
    border-radius: 1rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

/* Dashboard Stats */
.stat-card {
    border-left: 4px solid;
    border: none;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.stat-card.income-card {
    border-left: 4px solid var(--income-color);
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
}

.stat-card.income-card h3,
.stat-card.income-card h6 {
    color: white;
}

.stat-card.expense-card {
    border-left: 4px solid var(--expense-color);
    background: linear-gradient(135deg, #dc3545 0%, #fd7e14 100%);
    color: white;
}

.stat-card.expense-card h3,
.stat-card.expense-card h6 {
    color: white;
}

.stat-card.balance-card {
    border-left: 4px solid var(--primary-color);
    background: linear-gradient(135deg, #007bff 0%, #6610f2 100%);
    color: white;
}

.stat-card.balance-card h3,
.stat-card.balance-card h6 {
    color: white;
}

.stat-card.info-card {
    border-left: 4px solid #17a2b8;
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
    color: white;
}

.stat-card.info-card h3,
.stat-card.info-card h6 {
    color: white;
}

.stat-card h3 {
    font-size: 1.5rem;
    margin-bottom: 0;
    font-weight: 700;
}

.stat-card h6 {
    font-size: 0.75rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
    opacity: 0.9;
}

/* Mobile Transaction Cards (for small screens)
   Always show; Bootstrap utility .d-md-none hides them on md+ screens. */
.transaction-card-mobile {
    display: block;
}

.transaction-card-mobile .card {
    margin-bottom: 0.75rem;
    border-left: 4px solid;
}

.transaction-card-mobile .card.income-card {
    border-left-color: var(--income-color);
}

.transaction-card-mobile .card.expense-card {
    border-left-color: var(--expense-color);
}

/* Spinning animation for refresh button */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.spinning {
    animation: spin 1s linear infinite;
}

/* Responsive Typography */
h1, h2 {
    font-size: 1.75rem;
}

h3 {
    font-size: 1.5rem;
}

h4 {
    font-size: 1.25rem;
}

h5 {
    font-size: 1.1rem;
}

h6 {
    font-size: 1rem;
}

/* Container Padding */
.container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

/* Responsive */
@media (max-width: 768px) {
    body {
        font-size: 13px;
    }
    
    .auth-card {
        margin: 0.5rem;
        border-radius: 0.5rem;
    }
    
    .card-header {
        font-size: 0.9rem;
        padding: 0.5rem 0.75rem;
    }
    
    h1, h2 {
        font-size: 1.5rem;
    }
    
    h3 {
        font-size: 1.25rem;
    }
    
    h4 {
        font-size: 1.1rem;
    }
    
    h5 {
        font-size: 1rem;
    }
    
    .stat-card h3 {
        font-size: 1.25rem;
    }
    
    .stat-card h6 {
        font-size: 0.7rem;
    }
    
    .table {
        font-size: 0.8rem;
    }
    
    .table thead th {
        font-size: 0.75rem;
        padding: 0.4rem 0.3rem;
    }
    
    .table tbody td {
        padding: 0.4rem 0.3rem;
    }
    
    .btn {
        font-size: 0.8rem;
        padding: 0.3rem 0.6rem;
    }
    
    .btn-sm {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }
    
    /* Transactions index uses d-none d-md-block / d-md-none for table vs cards; do not hide .table-responsive globally or report tables break on mobile */
    
    /* Stack summary cards on mobile */
    .stat-card {
        margin-bottom: 0.75rem;
    }
    
    /* Adjust container padding */
    .container {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    /* Make filters stack vertically */
    .row.g-3 > div {
        margin-bottom: 0.5rem;
    }
    
    /* Adjust navbar */
    .navbar-brand {
        font-size: 1rem;
    }
    
    .nav-link {
        font-size: 0.85rem;
        padding: 0.5rem 0.75rem;
    }
}

@media (max-width: 576px) {
    body {
        font-size: 12px;
    }
    
    h1, h2 {
        font-size: 1.25rem;
    }
    
    h3 {
        font-size: 1.1rem;
    }
    
    .stat-card h3 {
        font-size: 1.1rem;
    }
    
    .table {
        font-size: 0.75rem;
    }
    
    .btn {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
    
    .card-body {
        padding: 0.75rem;
    }
    
    .card-header {
        padding: 0.5rem;
    }
    
    /* Make buttons smaller on very small screens */
    .btn-group .btn {
        padding: 0.2rem 0.4rem;
    }
}

/* Flatpickr Date Picker Styles */
.flatpickr-input {
    cursor: pointer;
    background-color: #fff;
    border: 1px solid #ced4da;
    transition: all 0.3s ease;
}

.flatpickr-input:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.1);
}

.flatpickr-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
    outline: 0;
}

/* Date input wrapper with icon */
.date-input-wrapper {
    position: relative;
}

.date-input-wrapper::after {
    content: '\F1F6';
    font-family: 'bootstrap-icons';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    pointer-events: none;
    font-size: 1.1rem;
}

.date-input-wrapper .form-control {
    padding-right: 40px;
}

/* Flatpickr Calendar Styling */
.flatpickr-calendar {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border-radius: 0.75rem;
    border: none;
    overflow: hidden;
    animation: fadeInDown 0.3s ease;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.flatpickr-months {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0056b3 100%);
    padding: 1rem;
    border-radius: 0.75rem 0.75rem 0 0;
}

.flatpickr-month {
    color: #fff;
}

.flatpickr-current-month {
    color: #fff;
    font-weight: 600;
    font-size: 1.1rem;
}

.flatpickr-prev-month,
.flatpickr-next-month {
    color: #fff;
    fill: #fff;
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
}

.flatpickr-prev-month:hover,
.flatpickr-next-month:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.flatpickr-weekdays {
    background: #f8f9fa;
    padding: 0.75rem 0;
    border-bottom: 1px solid #dee2e6;
}

.flatpickr-weekday {
    color: #495057;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.flatpickr-days {
    padding: 0.5rem;
}

.flatpickr-day {
    border-radius: 0.5rem;
    margin: 0.15rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.flatpickr-day:hover {
    background: rgba(13, 110, 253, 0.1);
    border-color: rgba(13, 110, 253, 0.3);
    transform: scale(1.05);
}

.flatpickr-day.today {
    border-color: var(--primary-color);
    background: rgba(13, 110, 253, 0.1);
    font-weight: 700;
    color: var(--primary-color);
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange,
.flatpickr-day.selected.inRange,
.flatpickr-day.startRange.inRange,
.flatpickr-day.endRange.inRange {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0056b3 100%);
    border-color: var(--primary-color);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 8px rgba(13, 110, 253, 0.3);
    transform: scale(1.05);
}

.flatpickr-day.selected:focus,
.flatpickr-day.startRange:focus,
.flatpickr-day.endRange:focus,
.flatpickr-day.selected:hover,
.flatpickr-day.startRange:hover,
.flatpickr-day.endRange:hover {
    background: linear-gradient(135deg, #0056b3 0%, var(--primary-color) 100%);
    transform: scale(1.1);
    box-shadow: 0 6px 12px rgba(13, 110, 253, 0.4);
}

.flatpickr-day.flatpickr-disabled,
.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay {
    color: #adb5bd;
    opacity: 0.5;
}

.flatpickr-day.flatpickr-disabled:hover {
    background: transparent;
    transform: none;
    border-color: transparent;
}

/* Time picker styling if used */
.flatpickr-time {
    border-top: 1px solid #dee2e6;
    padding: 0.75rem;
    background: #f8f9fa;
}

.flatpickr-time input {
    border-radius: 0.375rem;
    border: 1px solid #ced4da;
    padding: 0.25rem 0.5rem;
    font-weight: 500;
}

.flatpickr-time input:hover {
    border-color: var(--primary-color);
}

.flatpickr-time input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Tag autocomplete dropdown (add/edit transaction) */
.tag-autocomplete-dropdown {
    position: fixed;
    z-index: 1050;
    max-height: 200px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 0.25rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    padding: 0.25rem 0;
    min-width: 120px;
}
.tag-autocomplete-dropdown[data-visible="false"] {
    display: none !important;
}
.tag-autocomplete-item {
    padding: 0.35rem 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tag-autocomplete-item:hover,
.tag-autocomplete-item.active {
    background-color: var(--primary-color);
    color: #fff;
}
.tag-input-wrap {
    position: relative;
}

