/* Vazirmatn Font Setup */
@font-face {
  font-family: Vazirmatn;
  src: url('../webfonts/Vazirmatn[wght].woff2') format('woff2 supports variations'),
       url('../webfonts/Vazirmatn[wght].woff2') format('woff2-variations');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* General Styles */
body {
    font-family: 'Vazirmatn', sans-serif;
    background-color: #f4f7f6;
    color: #333;
    font-size: 14px;
}

:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --sidebar-bg: #ffffff;
    --sidebar-width: 190px;
    --header-height: 60px;
    --main-radius: 0.75rem;
    --card-shadow: 0 0.25rem 0.75rem rgba(0,0,0,0.05);
}

a {
    text-decoration: none;
    color: var(--primary-color);
}

.card {
    border: none;
    border-radius: var(--main-radius);
    box-shadow: var(--card-shadow);
    margin-bottom: 1.5rem;
}

.card-header {
    background-color: #fff;
    border-bottom: 1px solid #f0f0f0;
    border-top-left-radius: var(--main-radius);
    border-top-right-radius: var(--main-radius);
}

.btn {
    border-radius: var(--main-radius);
    font-weight: 600;
    padding: 0.5rem 1rem;
}

.form-control, .form-select {
    border-radius: var(--main-radius);
}

/* Layout */
.main-wrapper {
    display: flex;
}

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    height: 100vh;
    position: fixed;
    top: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 15px rgba(0,0,0,0.05);
    transition: margin-right 0.3s ease;
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid #f0f0f0;
    text-align: center;
}

.sidebar-menu {
    list-style: none;
    padding: 1rem 0;
    margin: 0;
    flex-grow: 1;
}

.sidebar-menu .menu-item a {
    display: flex;
    align-items: center;
    padding: 0.9rem 1.5rem;
    color: #555;
    transition: all 0.2s ease;
    font-size: 1rem;
}
.sidebar-menu .menu-item a i {
    margin-left: 1rem;
    width: 20px;
    text-align: center;
    color: #888;
    transition: color 0.2s ease;
}

.sidebar-menu .menu-item.active a,
.sidebar-menu .menu-item a:hover {
    background-color: #eef5ff;
    color: var(--primary-color);
    border-right: 3px solid var(--primary-color);
    font-weight: 700;
}

.sidebar-menu .menu-item.active a i,
.sidebar-menu .menu-item a:hover i {
    color: var(--primary-color);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid #f0f0f0;
}

.logout-btn {
    display: block;
    width: 100%;
    text-align: center;
    padding: 0.75rem;
    border-radius: var(--main-radius);
    background-color: #f8d7da;
    color: #721c24;
    font-weight: 600;
}
.logout-btn:hover {
    background-color: #f5c6cb;
    color: #721c24;
}
.logout-btn i {
    margin-left: 0.5rem;
}

.main-content {
    margin-right: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    padding-bottom: 80px; /* For mobile nav */
    transition: margin-right 0.3s ease;
}

/* Dashboard Stat Cards */
.stat-card {
    border-radius: var(--main-radius);
    color: #fff;
    overflow: hidden;
    position: relative;
    border: none;
    box-shadow: var(--card-shadow);
    padding: 15px 25px 15px 25px;
}

.stat-card .card-body {
    position: relative;
    z-index: 2;
}

.stat-card i {
    color: rgba(255, 255, 255, 0.5);
    transition: all 0.3s ease;
}

.stat-card:hover i {
    transform: scale(1.1);
    color: rgba(255, 255, 255, 0.8);
}

.stat-card .text-xs {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.8);
}

.stat-card .h5 {
    font-size: 2.7vh;
}

.stat-card.card-customers {
    background: linear-gradient(45deg, #4e73df, #224abe);
}
.stat-card.card-loans {
    background: linear-gradient(45deg, #f6c23e, #dda20a);
}
.stat-card.card-amount {
    background: linear-gradient(45deg, #1cc88a, #13855c);
}
.stat-card.card-paid {
    background: linear-gradient(45deg, #36b9cc, #2a96a5);
}


/* Table Styles */
.table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
}
.table thead th {
    background-color: #f8f9fa;
    border-bottom-width: 1px;
    font-weight: 600;
    color: #666;
    text-align: center;
}
.table td, .table th {
    vertical-align: middle;
    text-align: center;
}
.table-hover > tbody > tr:hover > * {
  --bs-table-accent-bg: #f5f8ff;
}

.badge {
    border-radius: var(--main-radius);
    padding: 0.4em 0.8em;
    font-weight: 600;
}

/* Mobile Bottom Navigation */
.mobile-bottom-nav {
    display: none; /* Hidden on desktop */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 65px;
    background-color: #ffffff;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    border-top-right-radius: 1.5rem;
    border-top-left-radius: 1.5rem;
}

.mobile-bottom-nav .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--secondary-color);
    flex-grow: 1;
    padding: 8px 0;
}
.mobile-bottom-nav .nav-item i {
    font-size: 1.4rem;
    margin-bottom: 4px;
}
.mobile-bottom-nav .nav-item span {
    font-size: 0.7rem;
    font-weight: 500;
}
.mobile-bottom-nav .nav-item.active {
    color: var(--primary-color);
    font-weight: 700;
}

/* Responsive Design */
@media (max-width: 992px) {
    .sidebar {
        margin-right: -250px; /* Hide sidebar */
    }
    .main-content {
        width: 100%;
        margin-right: 0;
    }
    .mobile-bottom-nav {
        display: flex;
    }
        /* For Horizontal Table Scrolling on Mobile */
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .table-responsive .table th,
    .table-responsive .table td {
        white-space: nowrap;
    }
}

/* Page Specific Styles */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.page-title {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Modal Customization */
.modal-content {
    border-radius: var(--main-radius);
    border: none;
}
.modal-header {
    border-bottom: 1px solid #f0f0f0;
}
.modal-footer {
    border-top: 1px solid #f0f0f0;
}

/* end */
/* مخفی کردن اینپوت اصلی */
.file-input {
    display: none;
}

.file-upload-wrapper {
    width: 100%;
    margin-top: 10px;
}

.file-drop-area {
    padding: 2rem;
    border: 2px dashed var(--primary-color);
    border-radius: var(--main-radius);
    background: #f8fbff;
    text-align: center;
    cursor: pointer;
    transition: 0.3s;
    color: var(--primary-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.file-drop-area:hover, .file-drop-area.dragover {
    background: #e8f1ff;
    border-color: #0b5ed7;
}

.file-drop-area .upload-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
    opacity: 0.7;
}

.file-msg {
    font-weight: 600;
}

/* لیست پیش‌نمایش */
.file-preview-list {
    margin-top: 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 10px;
}

.file-preview-item {
    display: flex;
    align-items: center;
    background: #fff;
    padding: 0.5rem;
    border-radius: var(--main-radius);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    border: 1px solid #e4e4e4;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.file-preview-item img {
    width: 45px;
    height: 45px;
    border-radius: 8px;
    object-fit: cover;
    margin-left: 12px;
}

.file-info {
    flex-grow: 1;
    font-size: 0.85rem;
    color: #444;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.remove-file {
    background: #fff5f5;
    color: #e53e3e;
    border: 1px solid #fed7d7;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: 0.2s;
    margin-right: 5px;
}

.remove-file:hover {
    background: #feb2b2;
    color: #fff;
}

.remove-file-btn {
    background: #fff0f0;
    color: #d63031;
    border: 1px solid #fab1a0;
    padding: 2px 8px;
    border-radius: 5px;
    font-size: 12px;
    cursor: pointer;
}
.remove-file-btn:hover {
    background: #d63031;
    color: #fff;
}


/* Container for all receipts */
.receipts-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 5px;
}

/* Individual Card Styling */
.custom-receipt-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
    border: 1px solid #eef0f2;
    border-radius: 12px;
    padding: 12px 16px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.custom-receipt-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

/* Visual Part (Image or Icon) */
.receipt-main {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0; /* Important for text-truncate */
}

.receipt-visual {
    width: 55px;
    height: 55px;
    border-radius: 10px;
    overflow: hidden;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: 15px;
    border: 1px solid #eee;
}

.img-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-icon-box i {
    font-size: 24px;
    color: #6c757d;
}

.receipt-details {
    display: flex;
    flex-direction: column;
    min-width: 0; /* حیاتی برای کارکرد ellipsis در فلکس‌باکس */
    flex: 1;      /* اجازه می‌دهد فضای باقی‌مانده را پر کند */
}

.receipt-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: #2d3436;
}

/* اصلاح نام فایل برای اعمال سه نقطه (...) */
.receipt-filename {
    font-size: 0.75rem;
    color: #636e72;
    margin-top: 2px;
    direction: ltr;         /* نمایش بهتر نام فایل‌های انگلیسی */
    text-align: right;      /* هماهنگی با ظاهر فارسی */
    display: block;
    white-space: nowrap;    /* جلوگیری از شکستن خط */
    overflow: hidden;       /* مخفی کردن متن اضافه */
    text-overflow: ellipsis; /* اضافه کردن سه نقطه */
    width: 100%;            /* اشغال تمام عرض در دسترس */
}

/* Custom Action Buttons */
.receipt-actions {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none !important;
    transition: all 0.2s ease;
    border: none;
}

.view-btn {
    background-color: #ebf5ff;
    color: #007bff;
}

.view-btn:hover {
    background-color: #007bff;
    color: #ffffff;
}

.download-btn {
    background-color: #f1f2f6;
    color: #2f3542;
}

.download-btn:hover {
    background-color: #2f3542;
    color: #ffffff;
}

/* No Data Style */
.no-data-msg {
    text-align: center;
    padding: 40px;
    color: #a0a0a0;
    font-size: 1rem;
}

/* RESPONSIVE DESIGN */
@media (max-width: 576px) {
    .custom-receipt-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

        .receipt-details {
        width: calc(100% - 70px); /* کسر کردن فضای تصویر/آیکون */
    }

    .receipt-main {
        width: 100%;        /* اشغال تمام عرض در موبایل */
    }

    .receipt-actions {
        width: 100%;
        justify-content: space-between;
        border-top: 1px solid #f1f2f6;
        padding-top: 12px;
    }

    .action-btn {
        flex: 1;
        justify-content: center;
    }

    .receipt-visual {
        width: 45px;
        height: 45px;
    }
}



.select2-container--bootstrap-5 .select2-selection {
    border-radius: var(--main-radius) !important;
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    min-height: 38px;
    font-family: 'Vazirmatn', sans-serif;
    font-size: 14px;
}
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    line-height: 36px;
    padding-right: 12px;
    font-family: 'Vazirmatn', sans-serif;
}
.select2-container--bootstrap-5 .select2-dropdown {
    font-family: 'Vazirmatn', sans-serif;
    border-radius: var(--main-radius);
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.15);
}
.select2-container--bootstrap-5 .select2-search__field {
    font-family: 'Vazirmatn', sans-serif;
}
.select2-container--bootstrap-5 .select2-results__option {
    font-family: 'Vazirmatn', sans-serif;
    padding: 8px 12px;
}