/* Root Variables */
:root {
    --primary-color: #6b5ecd;
    --secondary-color: #45b5aa;
    --background-color: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --border-radius: 12px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

/* General Styles */

body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, #f6f9fc 0%, #f1f4f9 100%);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    position: relative;
    margin: 0;
    padding: 0;
}

.wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* body.has-sidebar .wrapper {
    padding-left: 20px;
} */

/* Enhanced Sidebar */
.sidebar {
    height: 100vh;
    width: 300px;
    position: fixed;
    top: 0;
    left: 0;
    background: #2c3e50;
    box-shadow: 4px 0 10px rgba(0,0,0,0.1);
    z-index: 1040;
    transition: all 0.3s ease;
}

.sidebar-header {
    padding: 1.5rem;
    background: rgba(255,255,255,0.05);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand {
    color: #fff;
    font-size: 1.5rem;
    font-weight: 600;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-brand img {
    width: 35px;
    height: 35px;
}

.nav-item {
    margin: 4px 8px;
}

.sidebar .nav-link {
    color: rgba(255,255,255,0.7);
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
}

.sidebar .nav-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}

.sidebar .nav-link.active {
    color: #fff;
    background: var(--primary-color);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.sidebar .nav-link i {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-top: auto;
}

/* Enhanced Top Navigation */
.top-navbar {
    height: 70px;
    background: #fff;
    position: fixed;
    top: 0;
    right: 0;
    left: 280px;
    z-index: 1030;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.navbar-toggler {
    padding: 0.5rem;
    font-size: 1.25rem;
    border: none;
    background: transparent;
    color: var(--text-primary);
}

.navbar-search {
    position: relative;
    max-width: 400px;
    width: 100%;
}

.navbar-search .form-control {
    padding-left: 2.75rem;
    background: #f8f9fa;
    border: none;
    border-radius: 20px;
}

.navbar-search i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.navbar-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--text-primary);
    background: transparent;
    transition: all 0.3s ease;
}

.nav-icon:hover {
    background: #f8f9fa;
    color: var(--primary-color);
}

.nav-icon .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 20px;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: 30px;
    transition: all 0.3s ease;
}

.user-menu:hover {
    background: #f8f9fa;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--primary-color);
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Responsive Adjustments */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .top-navbar {
        left: 0;
    }

    body.has-sidebar .wrapper {
        padding-left: 0;
    }
}

/* Dark Mode Enhancements */
body.dark-mode .top-navbar {
    background: #1a1a1a;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

body.dark-mode .sidebar {
    background: #1a1a1a;
}

body.dark-mode .nav-icon:hover {
    background: rgba(255,255,255,0.1);
}

body.dark-mode .user-menu:hover {
    background: rgba(255,255,255,0.1);
}

/* User Controls */
.user-controls {
    margin-left: auto;
    display: flex;
    align-items: center;
}

.user-avatar {
    position: relative;
    width: 40px;
    height: 40px;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.user-info {
    margin-left: 0.75rem;
    display: none;
}

@media (min-width: 768px) {
    .user-info {
        display: block;
    }
}

.user-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.2;
}

.user-role {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 90px 1.5rem 1.5rem;
    min-height: 100vh;
    transition: var(--transition);
    width: 100%;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: none;
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card-body {
    padding: 1.5rem;
}

.card-title {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1.25rem;
    margin: 0;
    margin-bottom: 1.25rem;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    padding: 1.5rem;
}

.card-footer {
    background-color: transparent;
    border-top: 1px solid rgba(0,0,0,0.05);
    padding: 1.25rem 1.5rem;
}

/* Forms */
.form-control, .form-select {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    transition: all 0.2s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(107, 94, 205, 0.1);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group small {
    margin-top: 0.25rem;
    display: block;
}

.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Loading State */
form.loading {
    position: relative;
    opacity: 0.7;
    pointer-events: none;
}

form.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    z-index: 1;
}

/* Validation Styles */
.was-validated .form-control:invalid,
.form-control.is-invalid {
    border-color: var(--danger-color);
    padding-right: calc(1.5em + 0.75rem);
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.was-validated .form-control:valid,
.form-control.is-valid {
    border-color: var(--success-color);
    padding-right: calc(1.5em + 0.75rem);
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.invalid-feedback {
    display: none;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875em;
    color: var(--danger-color);
}

.was-validated .form-control:invalid ~ .invalid-feedback,
.form-control.is-invalid ~ .invalid-feedback {
    display: block;
}

/* Form Select */
.form-select:disabled {
    background-color: var(--background-color);
    opacity: 0.8;
}

/* Refresh Button */
#refreshCategories {
    padding: 0.375rem 0.75rem;
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

#refreshCategories i {
    transition: transform 0.3s ease;
}

#refreshCategories:not(:disabled):hover i {
    transform: rotate(180deg);
}

#refreshCategories:disabled i {
    opacity: 0.65;
}

/* Form Spinner */
#formSpinner {
    transition: opacity 0.2s;
}

#formSpinner.d-none {
    opacity: 0;
}

.input-group-text {
    border-top-left-radius: var(--border-radius);
    border-bottom-left-radius: var(--border-radius);
    border-top-right-radius: 0rem;
    border-bottom-right-radius: 0rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.btn i {
    font-size: 1rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, #8075d5 100%);
    border: none;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(107, 94, 205, 0.2);
}

/* Stats Cards */
.stat-card {
    padding: 1.5rem;
    border-radius: var(--border-radius);
    background: linear-gradient(135deg, var(--card-bg) 0%, #f8fafc 100%);
    border: 1px solid rgba(0,0,0,0.05);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
}

/* Progress Bars */
.progress {
    height: 0.5rem;
    background: #edf2f7;
    border-radius: 1rem;
    overflow: hidden;
    margin: 0.5rem 0;
}

.progress-bar {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
}

/* Responsive Design */
@media (max-width: 768px) {
    body.has-sidebar .wrapper {
        padding-left: 0;
    }
    
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .top-navbar {
        left: 0;
        width: 100%;
    }
    
    .main-content {
        width: 100%;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: fixed;
        bottom: 0;
        left: 0;
        z-index: 1000;
    }

    .sidebar-menu {
        display: flex;
        justify-content: space-around;
        padding: 0.5rem;
    }

    .main-content {
        margin-left: 0;
        margin-bottom: 60px;
    }

    .card {
        margin: 1rem 0;
    }
}

/* Dark Mode */
body.dark-mode {
    --background-color: #1a1a1a;
    --card-background: #242424;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
}

/* Modals */
.modal-content {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.modal-header {
    border-bottom: 1px solid rgba(0,0,0,0.05);
    padding: 1.25rem 1.5rem;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid rgba(0,0,0,0.05);
    padding: 1.25rem 1.5rem;
}

.modal-title {
    font-weight: 600;
    color: var(--text-primary);
}

/* Dropdowns */
.dropdown-menu {
    border: none;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border-radius: var(--border-radius);
}

.dropdown-item {
    padding: 0.75rem 1rem;
}

.dropdown-item i {
    width: 20px;
    margin-right: 0.5rem;
    text-align: center;
}

/* Alerts */
.alert {
    border: none;
    border-radius: var(--border-radius);
}

/* Tables */
.table-container {
    background: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    overflow: hidden;
    margin: 1.5rem 0;
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 0;
}

.table th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    border-bottom: 2px solid #edf2f7;
}

.table td {
    padding: 1rem 1.5rem;
    color: var(--text-secondary);
    vertical-align: middle;
}

.table-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.table-badge {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
}

.table-badge.income {
    background: rgba(72, 187, 120, 0.1);
    color: #38a169;
}

.table-badge.expense {
    background: rgba(245, 101, 101, 0.1);
    color: #e53e3e;
}

.table-badge.transfer {
    background: rgba(107, 94, 205, 0.1);
    color: var(--primary-color);
}

/* Table Responsive */
@media (max-width: 768px) {
    .table-container {
        border-radius: 0;
        margin: 1rem -1rem;
    }

    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-responsive::-webkit-scrollbar {
        height: 6px;
    }

    .table-responsive::-webkit-scrollbar-thumb {
        background-color: rgba(0,0,0,0.2);
        border-radius: 3px;
    }

    .table td, .table th {
        min-width: 120px;
    }

    .table td:first-child, .table th:first-child {
        position: sticky;
        left: 0;
        background: inherit;
        z-index: 1;
    }
}

/* Custom File Input */
.custom-file-input:focus ~ .custom-file-label {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Profile Image */
.profile-image-wrapper {
    position: relative;
    display: inline-block;
}

.profile-image {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 50%;
}

.change-photo-btn {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    /* Layout adjustments */
    .wrapper {
        padding-left: 0 !important;
    }

    .main-content {
        padding: 70px 1rem 1rem;
    }

    /* Sidebar mobile styling */
    .sidebar {
        transform: translateX(-100%);
        width: 100%;
        max-width: 280px;
        transition: transform 0.3s ease;
        z-index: 1050;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    /* Card adjustments for mobile */
    .card {
        margin: 0.5rem 0;
        border-radius: 0.75rem;
    }

    .card-body {
        padding: 1rem;
    }

    /* Form adjustments */
    .form-group {
        margin-bottom: 1rem;
    }

    .input-group {
        /* flex-direction: column; */
    }

    .input-group > * {
        margin-bottom: 0.5rem;
        /* width: 100%; */
    }

    .input-group-text {
        border-radius: var(--border-radius);
        justify-content: center;
    }

    /* Table responsive */
    .table-responsive {
        margin: 0 -1rem;
        width: calc(100% + 2rem);
    }

    .table {
        font-size: 0.875rem;
    }

    /* Button adjustments */
    .btn {
        width: 100%;
        margin: 0.25rem 0;
    }

    /* Radio button groups */
    .btn-group {
        flex-direction: column;
        width: 100%;
    }

    .btn-group > .btn {
        border-radius: var(--border-radius) !important;
        margin: 0.25rem 0;
    }
}

/* Small phones */
@media (max-width: 375px) {
    .card-title {
        font-size: 1.25rem;
    }

    .form-label {
        font-size: 0.875rem;
    }

    .table {
        font-size: 0.75rem;
    }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    .wrapper {
        padding-left: 20px;
    }

    .sidebar {
        width: 200px;
    }

    .card {
        margin: 0.75rem 0;
    }
}

/* Enhanced Table Styles */
.table-container {
    background: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    overflow: hidden;
    margin: 1.5rem 0;
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 0;
}

.table thead th {
    background: #f8fafc;
    color: var(--text-primary);
    font-weight: 600;
    padding: 1rem;
    text-align: left;
    border-bottom: 2px solid rgba(0,0,0,0.05);
    white-space: nowrap;
}

.table tbody tr {
    transition: background-color 0.2s;
}

.table tbody tr:hover {
    background-color: rgba(13, 110, 253, 0.04);
}

.table td {
    padding: 1rem;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    vertical-align: middle;
}

.table-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.table-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
}

.table-badge.income {
    background: rgba(72, 187, 120, 0.1);
    color: #38a169;
}

.table-badge.expense {
    background: rgba(245, 101, 101, 0.1);
    color: #e53e3e;
}

.table-badge.transfer {
    background: rgba(107, 94, 205, 0.1);
    color: var(--primary-color);
}

/* Table Responsive */
@media (max-width: 768px) {
    .table-container {
        border-radius: 0;
        margin: 1rem -1rem;
    }

    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-responsive::-webkit-scrollbar {
        height: 6px;
    }

    .table-responsive::-webkit-scrollbar-thumb {
        background-color: rgba(0,0,0,0.2);
        border-radius: 3px;
    }

    .table td, .table th {
        min-width: 120px;
    }

    .table td:first-child, .table th:first-child {
        position: sticky;
        left: 0;
        background: inherit;
        z-index: 1;
    }
}

/* Loading States and Animations */
@keyframes shimmer {
    0% { background-position: -1000px 0; }
    100% { background-position: 1000px 0; }
}

.loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #f8f8f8 50%, #f0f0f0 75%);
    background-size: 1000px 100%;
    animation: shimmer 2s infinite linear;
}
