/* Variables */
:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --sidebar-width: 280px;
    --fab-size: 56px;
    --border-color: #dee2e6;
    --text-muted: #6c757d;
}

/* Global Styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--light-color);
    line-height: 1.6;
    margin: 0;
    padding: 0;
}

/* Custom Layout System */
.app-container {
    display: flex;
    min-height: 100vh;
}

#sidebar,
.app-sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background-color: var(--light-color);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    overflow-y: auto;
    transition: transform 0.3s ease;
    display: block; /* Force display */
}

.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    padding: 0 1.5rem;
}

.app-main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.app-main-content {
    padding-bottom: 2rem;
}

/* Sidebar Content */
.sidebar-content {
    padding: 1rem 0;
}

.sidebar-nav {
    padding: 0 1rem;
}

.sidebar-nav .nav {
    display: flex;
    flex-direction: column;
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav .nav-item {
    margin-bottom: 0.25rem;
}

.sidebar-nav .nav-link {
    font-weight: 500;
    color: #333;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    text-decoration: none;
    transition: all 0.2s ease;
}

.sidebar-nav .nav-link:hover {
    color: var(--primary-color);
    background-color: rgba(0, 123, 255, 0.1);
}

.sidebar-nav .nav-link.active {
    color: white;
    background-color: var(--primary-color);
}

.sidebar-nav .nav-link i {
    margin-right: 0.75rem;
    width: 16px;
    text-align: center;
}

.sidebar-divider {
    margin: 1rem 0;
    border-top: 1px solid var(--border-color);
}

.sidebar-user {
    padding: 0 1rem;
}

.mobile-header {
    display: none;
}

.mobile-toggle {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: #333;
    cursor: pointer;
}

/* Hero Section */
.hero-section {
    background: linear-gradient(135deg, var(--primary-color), #0056b3);
    color: white;
    min-height: 100vh;
}

.feature-preview {
    padding: 2rem 0;
}

/* Expense List */
.expense-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.5rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
}

.expense-item:last-child {
    border-bottom: none;
}

.expense-details {
    flex: 1;
    min-width: 0;
}

.expense-amount {
    font-weight: 600;
    font-size: 1.1rem;
}

.expense-actions {
    flex-shrink: 0;
    display: flex;
    gap: 0.5rem;
}

.expense-actions .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    width: var(--fab-size);
    height: var(--fab-size);
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 1.5rem;
    z-index: 1000;
    transition: all 0.3s ease;
    cursor: pointer;
}

.fab:hover {
    background-color: #0056b3;
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

/* Category Cards */
.category-card {
    transition: transform 0.2s ease;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
    background: white;
}

.category-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.category-card-active {
    border-left: 4px solid var(--primary-color);
}

.category-card-inactive {
    border-left: 4px solid var(--border-color);
    opacity: 0.8;
}

.category-icon {
    width: 40px;
    text-align: center;
}

.suggestion-btn {
    margin: 2px;
}

/* Budget specific styles */
.bg-gradient-primary {
    background: linear-gradient(135deg, var(--primary-color), #0056b3);
}

.budget-icon {
    width: 40px;
    text-align: center;
}

.budget-progress {
    margin-bottom: 1rem;
}

.budget-card {
    padding: 1.5rem;
    border-radius: 0.5rem;
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
}

.budget-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.budget-success {
    border-left: 4px solid var(--success-color);
}

.budget-warning {
    border-left: 4px solid var(--warning-color);
}

.budget-danger {
    border-left: 4px solid var(--danger-color);
}

.amount-btn {
    margin: 2px;
}

.budget-card.warning {
    border-left-color: var(--warning-color);
}

.budget-card.danger {
    border-left-color: var(--danger-color);
}

/* Calendar Styling */
.flatpickr-calendar {
    font-family: inherit;
}

.flatpickr-day.has-expenses {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
}

.flatpickr-day.has-expenses:hover {
    background-color: #0056b3;
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* Alerts */
.alert-dismissible {
    padding-right: 4rem;
}

.alert .btn-close {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
}

/* Form Enhancements */
.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.was-validated .form-control:valid {
    border-color: var(--success-color);
}

.was-validated .form-control:invalid {
    border-color: var(--danger-color);
}

/* Charts */
.chart-container {
    position: relative;
    height: 300px;
    margin-bottom: 2rem;
}

/* Import/Export */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 0.5rem;
    padding: 2rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--primary-color);
    background-color: rgba(0, 123, 255, 0.05);
}

.upload-area.dragover {
    border-style: solid;
}

.file-info {
    margin-top: 1rem;
    padding: 0.5rem;
    background-color: var(--light-color);
    border-radius: 0.25rem;
}

/* Settings Page */
.settings-section {
    background: white;
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.settings-section h5 {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    #sidebar,
    .app-sidebar {
        transform: translateX(-100%);
        width: 100%;
    }

    #sidebar.show,
    .app-sidebar.show {
        transform: translateX(0);
    }

    .app-main {
        margin-left: 0;
        padding: 0 1rem;
    }

    .mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 1rem 0;
        border-bottom: 1px solid var(--border-color);
        margin-bottom: 1rem;
    }

    .fab {
        bottom: 1.5rem;
        right: 1.5rem;
    }

    .expense-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .expense-actions {
        align-self: flex-end;
        margin-top: 0.5rem;
    }

    .card-header {
        padding: 0.75rem;
    }

    .modal-dialog {
        margin: 0.5rem;
    }

    .table-responsive {
        font-size: 0.875rem;
    }

    /* Stack form controls on mobile */
    .row.mb-3 .col-md-3,
    .row.mb-3 .col-md-6 {
        margin-bottom: 0.5rem;
    }
}

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 360px) and (max-width: 575.98px) {
    .container {
        padding: 0 0.5rem;
    }

    .card {
        margin-bottom: 1rem;
    }

    .btn {
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem;
    }

    .expense-amount {
        font-size: 1rem;
    }

    .chart-container {
        height: 250px;
    }
}

/* Tablet optimizations */
@media (min-width: 768px) and (max-width: 1024px) {
    .modal-dialog {
        max-width: 600px;
    }

    .fab {
        display: none; /* Hide FAB on tablet and up */
    }
}

/* Desktop optimizations */
@media (min-width: 769px) {
    .mobile-header {
        display: none;
    }
}

@media (min-width: 1200px) {
    .container-fluid {
        padding: 0 2rem;
    }
}

/* Print styles */
@media print {
    .app-sidebar,
    .fab,
    .btn,
    .modal,
    .mobile-header {
        display: none !important;
    }

    .app-main {
        margin-left: 0;
    }

    .expense-actions {
        display: none;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* Accessibility */
.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 keyboard navigation */
.btn:focus,
.form-control:focus,
.form-select:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .card {
        border-width: 2px;
    }

    .btn {
        border-width: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .fab {
        transition: none;
    }

    .category-card {
        transition: none;
    }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    :root {
        --light-color: #2d3748;
        --dark-color: #f7fafc;
    }

    body {
        background-color: #1a202c;
        color: #f7fafc;
    }

    .card,
    .app-sidebar {
        background-color: #2d3748;
        color: #f7fafc;
    }

    .form-control,
    .form-select {
        background-color: #2d3748;
        border-color: #4a5568;
        color: #f7fafc;
    }
}

/* Animation classes */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.slide-up {
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Utility classes */
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cursor-pointer {
    cursor: pointer;
}

.border-radius-lg {
    border-radius: 0.5rem;
}

.shadow-sm {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.shadow-md {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.shadow-lg {
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
}

/* Final UI improvements */

/* Loading improvements */
.skeleton-loader {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Better focus indicators */
.form-control:focus,
.form-select:focus,
.btn:focus {
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Smooth page transitions */
.page-transition {
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.page-transition.loaded {
    opacity: 1;
    transform: translateY(0);
}

/* Better mobile interactions */
@media (max-width: 768px) {
    .btn {
        min-height: 44px; /* Touch-friendly buttons */
    }

    .form-control,
    .form-select {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* Status indicators */
.status-online {
    color: var(--success-color);
}

.status-offline {
    color: var(--danger-color);
}

/* Draft indicator */
.draft-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--warning-color);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
}

/* Enhanced date error messages */
.date-error {
    display: block;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875em;
    color: var(--danger-color);
    line-height: 1.3;
}

/* Improved invalid input styling */
.form-control.is-invalid:focus {
    border-color: var(--danger-color);
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

/* Custom Button Style for Sign In in Hero Section */
.custom-btn-outline-light-hero {
    color: #fff; /* White text */
    border-color: #fff; /* White border */
    background-color: rgba(255, 255, 255, 0.2); /* Semi-transparent white background */
    transition: all 0.3s ease;
}

.custom-btn-outline-light-hero:hover {
    background-color: rgba(255, 255, 255, 0.3); /* Slightly more opaque on hover */
    color: #fff;
    border-color: #fff;
}

/* Navbar padding fix for mobile devices to prevent overlap */
@media (max-width: 991.98px) {
	.hero-section {
		padding-top: 120px; /* Further increased to ensure no overlap on tablets and mobiles */
	}
}

/* Additional padding for very small screens where navbar height increases due to stacking */
@media (max-width: 767.98px) {
	.hero-section {
		padding-top: 140px; /* Extra padding for stacked navbar content on mobile */
	}
	.navbar > .container {
		display: flex;
		flex-direction: column;
		align-items: center; /* Center horizontally */
		padding: 10px 0; /* Add padding for spacing */
	}
	.navbar-brand {
		margin-bottom: 10px; /* Space between brand and buttons */
		margin-right: 0; /* Reset Bootstrap's margin-right */
	}
	.navbar-buttons {
		display: flex;
		flex-direction: row;
		justify-content: center;
		gap: 10px;
		width: 100%; /* Ensure full width for centering */
	}
}

/* Custom Navbar Background Color */
.custom-navbar-bg {
	background-color: #4A148C; 
}