/* ============================================================
   استایل‌های اصلی — سیستم حسابداری شخصی
   ============================================================
   پالت رنگی:
   - Primary:    #4F46E5 (آبی-بنفش)
   - Secondary:  #7C3AED (بنفش)
   - Success:    #10B981 (سبز - درآمد)
   - Danger:     #EF4444 (قرمز - هزینه)
   - Warning:    #F59E0B (طلایی)
   - Info:       #3B82F6 (آبی)
   - Background: #F1F5F9
   - Card BG:    #FFFFFF
   ============================================================ */

/* ----- پایه و فونت ----- */
:root {
    --primary: #4F46E5;
    --primary-light: #6366F1;
    --primary-dark: #3730A3;
    --secondary: #7C3AED;
    --success: #10B981;
    --danger: #EF4444;
    --warning: #F59E0B;
    --info: #3B82F6;
    --bg: #F1F5F9;
    --card-bg: #FFFFFF;
    --text: #1E293B;
    --text-light: #64748B;
    --border: #E2E8F0;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 4px 6px rgba(0,0,0,0.07);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.08);
    --shadow-xl: 0 15px 50px rgba(0,0,0,0.12);
    --radius: 16px;
    --radius-sm: 10px;
    --transition: 0.3s ease;
}

* {
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
}

body {
    background-color: var(--bg);
    color: var(--text);
    direction: rtl;
    text-align: right;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    text-decoration: none;
}

/* ----- نوبار ----- */
.navbar {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    box-shadow: var(--shadow);
    padding: 0.5rem 0;
}

.navbar-brand {
    color: #fff !important;
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.5px;
}

.navbar .nav-link {
    color: rgba(255,255,255,0.85) !important;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 10px;
    transition: all var(--transition);
    margin: 0 2px;
}

.navbar .nav-link:hover,
.navbar .nav-link.active {
    color: #fff !important;
    background: rgba(255,255,255,0.15);
}

.navbar .dropdown-menu {
    border: none;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
}

.navbar .dropdown-item {
    border-radius: 8px;
    padding: 0.6rem 1rem;
    transition: all var(--transition);
}

.navbar .dropdown-item:hover {
    background: #F1F5F9;
}

/* ----- کارت‌ها ----- */
.card {
    background: var(--card-bg);
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    transition: transform var(--transition), box-shadow var(--transition);
    overflow: hidden;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.25rem;
    font-weight: 700;
}

.card-body {
    padding: 1.5rem;
}

/* ----- کارت‌های آمار داشبورد ----- */
.stat-card {
    position: relative;
    padding: 1.5rem;
    border-radius: var(--radius);
    color: #fff;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -25px;
    left: -25px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
}

.stat-card::after {
    content: '';
    position: absolute;
    bottom: -30px;
    right: -20px;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: rgba(255,255,255,0.07);
}

.stat-card .stat-icon {
    position: absolute;
    top: 1rem;
    left: 1rem;
    font-size: 2.5rem;
    opacity: 0.2;
}

.stat-card .stat-label {
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0.9;
    margin-bottom: 0.25rem;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -1px;
}

.stat-card .stat-sub {
    font-size: 0.8rem;
    opacity: 0.8;
    margin-top: 0.25rem;
}

.stat-balance { background: linear-gradient(135deg, #4F46E5, #7C3AED); }
.stat-income  { background: linear-gradient(135deg, #059669, #10B981); }
.stat-expense { background: linear-gradient(135deg, #DC2626, #EF4444); }
.stat-count   { background: linear-gradient(135deg, #D97706, #F59E0B); }

/* ----- جداول ----- */
.table {
    margin-bottom: 0;
}

.table th {
    font-weight: 700;
    color: var(--text-light);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom-width: 1px;
    border-color: var(--border);
}

.table td {
    vertical-align: middle;
    padding: 0.85rem 1rem;
    border-color: var(--border);
    font-size: 0.95rem;
}

.table-hover tbody tr:hover {
    background-color: rgba(79, 70, 229, 0.03);
}

/* ----- نشان تراکنش ----- */
.badge-income {
    background-color: rgba(16, 185, 129, 0.12);
    color: #059669;
    padding: 0.4rem 0.9rem;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.85rem;
}

.badge-expense {
    background-color: rgba(239, 68, 68, 0.12);
    color: #DC2626;
    padding: 0.4rem 0.9rem;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.85rem;
}

/* ----- فرم‌ها ----- */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    padding: 0.65rem 1rem;
    font-size: 0.95rem;
    transition: all var(--transition);
    background-color: #F8FAFC;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
    background-color: #fff;
}

.form-label {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
}

/* ----- دکمه‌ها ----- */
.btn {
    border-radius: var(--radius-sm);
    padding: 0.6rem 1.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all var(--transition);
    border: none;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
}

.btn-success {
    background: linear-gradient(135deg, #059669, #10B981);
}

.btn-danger {
    background: linear-gradient(135deg, #DC2626, #EF4444);
}

.btn-warning {
    background: linear-gradient(135deg, #D97706, #F59E0B);
    color: #fff;
}

.btn-outline-primary {
    border: 1.5px solid var(--primary);
    color: var(--primary);
    background: transparent;
}

.btn-outline-primary:hover {
    background: var(--primary);
    color: #fff;
}

.btn-sm {
    padding: 0.35rem 0.9rem;
    font-size: 0.82rem;
    border-radius: 8px;
}

/* ----- دکمه شناور افزودن ----- */
.fab-add {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 25px rgba(79, 70, 229, 0.4);
    z-index: 1000;
    transition: all var(--transition);
    border: none;
}

.fab-add:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 35px rgba(79, 70, 229, 0.5);
    color: #fff;
}

/* ----- Toast پیام‌ها ----- */
.toast-message {
    position: fixed;
    top: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(-120px);
    padding: 0.9rem 2rem;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.95rem;
    z-index: 9999;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    white-space: nowrap;
}

.toast-message.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast-success {
    background: linear-gradient(135deg, #059669, #10B981);
    color: #fff;
}

.toast-error {
    background: linear-gradient(135deg, #DC2626, #EF4444);
    color: #fff;
}

/* ----- صفحه‌بندی ----- */
.pagination {
    gap: 0.25rem;
}

.page-link {
    border: none;
    border-radius: 8px !important;
    padding: 0.5rem 1rem;
    color: var(--text);
    font-weight: 500;
    transition: all var(--transition);
}

.page-link:hover {
    background: var(--primary);
    color: #fff;
}

.page-item.active .page-link {
    background: var(--primary);
    color: #fff;
}

/* ----- صفحه ورود/ثبت‌نام ----- */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 2rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: 0 25px 80px rgba(0,0,0,0.2);
}

.auth-card .logo {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-card .logo i {
    font-size: 3rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-card .logo h2 {
    font-weight: 800;
    margin-top: 0.5rem;
    color: var(--text);
}

/* ----- فوتر ----- */
footer {
    background: var(--card-bg);
    color: var(--text-light);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

/* ----- فیلترها ----- */
.filter-bar {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow-lg);
    margin-bottom: 1.5rem;
}

/* ----- نمودار ----- */
.chart-container {
    position: relative;
    width: 100%;
}

.chart-container canvas {
    max-height: 320px;
}

/* ----- موشن و انیمیشن ----- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-in {
    animation: fadeInUp 0.5s ease forwards;
}

.row > [class*="col-"] {
    animation: fadeInUp 0.5s ease forwards;
}

.row > [class*="col-"]:nth-child(1) { animation-delay: 0.05s; }
.row > [class*="col-"]:nth-child(2) { animation-delay: 0.10s; }
.row > [class*="col-"]:nth-child(3) { animation-delay: 0.15s; }
.row > [class*="col-"]:nth-child(4) { animation-delay: 0.20s; }

/* ----- واکنش‌گرایی ----- */
@media (max-width: 767.98px) {
    /* موبایل */
    .stat-card .stat-value {
        font-size: 1.35rem;
    }
    .stat-card {
        padding: 1.25rem;
    }
    .auth-card {
        padding: 1.5rem;
    }
    .fab-add {
        bottom: 1.5rem;
        right: 1.5rem;
        width: 52px;
        height: 52px;
        font-size: 1.3rem;
    }
    .table {
        font-size: 0.8rem;
    }
    .table td, .table th {
        padding: 0.6rem 0.4rem;
    }
    .navbar .nav-link {
        padding: 0.6rem 1rem;
    }
}

@media (min-width: 768px) and (max-width: 1023.98px) {
    /* تبلت */
    .stat-card .stat-value {
        font-size: 1.5rem;
    }
}

/* ----- دکمه‌های عملیات ----- */
.action-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    transition: all var(--transition);
    font-size: 0.9rem;
}

.action-btn.edit-btn {
    background: rgba(59, 130, 246, 0.1);
    color: #3B82F6;
}

.action-btn.edit-btn:hover {
    background: #3B82F6;
    color: #fff;
}

.action-btn.delete-btn {
    background: rgba(239, 68, 68, 0.1);
    color: #DC2626;
}

.action-btn.delete-btn:hover {
    background: #EF4444;
    color: #fff;
}

/* ----- حالت Loading ----- */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(255,255,255,0.7);
    z-index: 9998;
    justify-content: center;
    align-items: center;
}

.loading-overlay.active {
    display: flex;
}

/* ----- Empty State ----- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-light);
}

.empty-state i {
    font-size: 4rem;
    opacity: 0.3;
    margin-bottom: 1rem;
}

/* ----- Title with icon ----- */
.page-title {
    font-weight: 800;
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.page-title i {
    color: var(--primary);
    font-size: 1.4rem;
}

/* ----- Modal ----- */
.modal-content {
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow-xl);
}

.modal-header {
    border-bottom: 1px solid var(--border);
}

.modal-footer {
    border-top: 1px solid var(--border);
}

/* ----- سلکتور تاریخ شمسی ----- */
.jalali-picker {
    display: flex;
    gap: 0.5rem;
    direction: rtl;
}

.jalali-picker .jp-col {
    flex: 1;
}

.jalali-picker .jp-col-year {
    flex: 1.4;
}

.jalali-picker .jp-col-month {
    flex: 1.8;
}

.jalali-picker .jp-col-day {
    flex: 1;
}

.jalali-picker .jp-select {
    width: 100%;
    cursor: pointer;
    text-align: center;
    font-weight: 500;
    padding: 0.65rem 0.4rem;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234F46E5' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 0.6rem center;
    background-size: 10px;
}

.jalali-picker .jp-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

/* ----- صفحه دسته‌بندی‌ها ----- */
.category-icon-preview {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    background: #F1F5F9;
    color: var(--primary);
}

.category-list-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    background: #F8FAFC;
    margin-bottom: 0.5rem;
}

.category-list-item:hover {
    background: #EEF2FF;
}

/* ----- صفحه گزارشات ----- */
.report-card {
    cursor: pointer;
    transition: all var(--transition);
    border: 2px solid transparent;
}

.report-card:hover,
.report-card.selected {
    border-color: var(--primary);
    background: #EEF2FF;
}

.report-summary-item {
    text-align: center;
    padding: 1rem;
}

.report-summary-item .rs-value {
    font-size: 1.4rem;
    font-weight: 800;
}

.report-summary-item .rs-label {
    font-size: 0.82rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

/* ----- تب‌های فیلتر (nav-pills) ----- */
.nav-pills .nav-link {
    border-radius: 8px;
    padding: 0.5rem 1.2rem;
    font-weight: 500;
    color: var(--text);
    transition: all var(--transition);
}

.nav-pills .nav-link.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
}

.nav-pills .nav-link:hover:not(.active) {
    background: #EEF2FF;
    color: var(--primary);
}

/* ----- لینک داخل جدول ----- */
table a.text-decoration-none {
    color: var(--primary);
}
table a.text-decoration-none:hover {
    color: var(--primary-dark);
    text-decoration: underline !important;
}

@media (max-width: 767.98px) {
    .jalali-picker {
        flex-direction: column;
        gap: 0.4rem;
    }
    
    .jalali-picker .jp-col {
        flex: 1;
    }
}
