/* ========================================
   سیستم حسابداری - قالب theme1
   استایل اصلی
======================================== */

/* ========== متغیرهای رنگی ========== */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #3b82f6;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #06b6d4;

    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-sidebar: #ffffff;
    --bg-header: #ffffff;

    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-light: #ffffff;

    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);

    --sidebar-width: 260px;
    --header-height: 70px;

    /* Sidebar-specific (light mode) */
    --sidebar-text: #334155;
    --sidebar-text-muted: #64748b;
    --sidebar-hover-bg: rgba(37, 99, 235, 0.06);
    --sidebar-active-bg: var(--primary-color);
    --sidebar-active-text: #ffffff;
    --sidebar-border: #e2e8f0;
    --sidebar-submenu-bg: #f1f5f9;
    --sidebar-submenu-text: #475569;
}

/* ========== حالت تاریک ========== */
[data-theme="dark"] {
    --primary-color: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #60a5fa;

    --bg-primary: #1e293b;
    --bg-secondary: #0f172a;
    --bg-sidebar: #1e293b;
    --bg-header: #1e293b;

    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-light: #f1f5f9;

    --border-color: #334155;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);

    /* Sidebar-specific (dark mode) */
    --sidebar-text: rgba(255, 255, 255, 0.8);
    --sidebar-text-muted: rgba(255, 255, 255, 0.6);
    --sidebar-hover-bg: rgba(255, 255, 255, 0.05);
    --sidebar-active-bg: var(--primary-color);
    --sidebar-active-text: #ffffff;
    --sidebar-border: rgba(255, 255, 255, 0.1);
    --sidebar-submenu-bg: rgba(0, 0, 0, 0.2);
    --sidebar-submenu-text: rgba(255, 255, 255, 0.7);
}

/* ========== تنظیمات پایه ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Vazirmatn', 'Tahoma', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    direction: rtl;
}

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

a:hover {
    color: var(--primary-dark);
}

/* ========== Layout ========== */
.wrapper {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-right: var(--sidebar-width);
    transition: margin-right 0.3s;
}

.page-content {
    flex: 1;
    padding: 24px;
    margin-top: var(--header-height);
}

/* ========== Sidebar ========== */
.sidebar {
    position: fixed;
    right: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s, background 0.3s, color 0.3s;
    box-shadow: var(--shadow-lg);
    border-left: 1px solid var(--sidebar-border);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid var(--sidebar-border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
    font-weight: 700;
    color: var(--sidebar-text);
}

.logo i {
    font-size: 28px;
    color: var(--primary-color);
}

.sidebar-close {
    background: transparent;
    border: none;
    color: var(--sidebar-text);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
}

/* Navigation Menu */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
}

.nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-item {
    margin-bottom: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--sidebar-text);
    font-size: 14px;
    transition: all 0.2s;
    position: relative;
}

.nav-link:hover {
    background: var(--sidebar-hover-bg);
    color: var(--primary-color);
}

.nav-link.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    font-weight: 600;
}

.nav-link.active::before {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background: var(--primary-light);
}

.nav-link i {
    font-size: 20px;
    margin-left: 12px;
    width: 24px;
    text-align: center;
}

.nav-link span {
    flex: 1;
}

.submenu-arrow {
    font-size: 16px;
    transition: transform 0.2s;
}

/* Submenu */
.submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background: var(--sidebar-submenu-bg);
}

.nav-item.has-submenu.active .submenu {
    max-height: 500px;
}

.nav-item.has-submenu.active .submenu-arrow {
    transform: rotate(-90deg);
}

.submenu li {
    margin: 0;
}

.submenu a {
    display: block;
    padding: 10px 20px 10px 56px;
    color: var(--sidebar-submenu-text);
    font-size: 13px;
    transition: all 0.2s;
}

.submenu a:hover {
    background: var(--sidebar-hover-bg);
    color: var(--primary-color);
    padding-right: 60px;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--sidebar-border);
}

.company-info small {
    color: var(--sidebar-text-muted);
    font-size: 12px;
}

/* ========== Header ========== */
.top-header {
    position: fixed;
    top: 0;
    left: 0;
    right: var(--sidebar-width);
    height: var(--header-height);
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    z-index: 999;
    transition: right 0.3s;
    box-shadow: var(--shadow-sm);
}

.top-header .container-fluid {
    height: 100%;
}

.page-info h4 {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}

.breadcrumb {
    background: transparent;
    margin-bottom: 4px;
    padding: 0;
    font-size: 13px;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: '/';
    padding: 0 8px;
}

/* Header Actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-icon {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 20px;
}

.btn-icon:hover {
    background: var(--bg-secondary);
    border-color: var(--primary-color);
}

.btn-icon .badge {
    position: absolute;
    top: -6px;
    left: -6px;
    right: auto;
    background: var(--danger-color);
    color: white;
    font-size: 10px;
    min-width: 18px;
    height: 18px;
    line-height: 14px;
    padding: 2px 5px;
    border-radius: 10px;
    text-align: center;
}

.btn-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-user:hover {
    background: var(--bg-secondary);
    border-color: var(--primary-color);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

/* Notifications Dropdown */
.notifications-dropdown {
    width: 320px;
    max-height: 400px;
    overflow-y: auto;
    padding: 0;
}

.notifications-dropdown .dropdown-header {
    padding: 12px 16px;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

.notification-item {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

.notification-item:hover {
    background: var(--bg-secondary);
}

.notification-item i {
    font-size: 20px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(37, 99, 235, 0.1);
}

.notification-content {
    flex: 1;
}

.notification-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.notification-text {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.notification-time {
    font-size: 12px;
    color: var(--text-muted);
}

.dropdown-footer {
    display: block;
    padding: 12px 16px;
    text-align: center;
    font-weight: 500;
    color: var(--primary-color);
    background: var(--bg-secondary);
}

/* ========== Footer ========== */
.page-footer {
    padding: 20px 24px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

/* ========== Cards ========== */
.card {
    background: var(--bg-primary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.card-body {
    padding: 20px;
}

/* Stats Cards */
.stat-card {
    background: var(--bg-primary);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 12px;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.stat-card .stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.stat-card .stat-change {
    font-size: 12px;
    font-weight: 500;
}

.stat-change.positive {
    color: var(--success-color);
}

.stat-change.negative {
    color: var(--danger-color);
}

/* ========== Tables ========== */
.table {
    width: 100%;
    margin-bottom: 0;
}

.table th {
    background: var(--bg-secondary);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    color: var(--text-secondary);
    padding: 12px;
    border-bottom: 2px solid var(--border-color);
}

.table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

.table tbody tr:hover {
    background: var(--bg-secondary);
}

/* ========== Buttons ========== */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* AJAX Button Loading State */
.ajax-btn .btn-loading {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ajax-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* ========== Responsive ========== */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-right: 0;
    }

    .top-header {
        right: 0;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .sidebar-overlay.active {
        display: block;
    }
}

@media (max-width: 767px) {
    .page-content {
        padding: 16px;
    }

    .stat-card {
        margin-bottom: 16px;
    }
}

/* ========== Utilities ========== */
.text-primary { color: var(--primary-color) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-success { color: var(--success-color) !important; }
.text-danger { color: var(--danger-color) !important; }
.text-warning { color: var(--warning-color) !important; }
.text-muted { color: var(--text-muted) !important; }

.bg-primary { background-color: var(--primary-color) !important; }
.bg-success { background-color: var(--success-color) !important; }
.bg-danger { background-color: var(--danger-color) !important; }
.bg-warning { background-color: var(--warning-color) !important; }
.bg-info { background-color: var(--info-color) !important; }

.d-none { display: none !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 8px !important; }
.mb-2 { margin-bottom: 16px !important; }
.mb-3 { margin-bottom: 24px !important; }
.mb-4 { margin-bottom: 32px !important; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 8px !important; }
.mt-2 { margin-top: 16px !important; }
.mt-3 { margin-top: 24px !important; }
.mt-4 { margin-top: 32px !important; }

/* ========== Dark Mode Toggle ========== */
.btn-theme-toggle {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 20px;
    color: var(--text-secondary);
}

.btn-theme-toggle:hover {
    background: var(--bg-secondary);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.btn-theme-toggle .icon-light,
.btn-theme-toggle .icon-dark {
    transition: opacity 0.2s, transform 0.3s;
    position: absolute;
}

.btn-theme-toggle .icon-dark {
    opacity: 0;
    transform: rotate(-90deg) scale(0);
}

[data-theme="dark"] .btn-theme-toggle .icon-light {
    opacity: 0;
    transform: rotate(90deg) scale(0);
}

[data-theme="dark"] .btn-theme-toggle .icon-dark {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* ========== Dark Mode Transitions ========== */
body,
.sidebar,
.top-header,
.card,
.stat-card,
.page-footer,
.dropdown-menu,
.btn-icon,
.btn-user {
    transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

/* ========== Dark Mode Overrides ========== */
[data-theme="dark"] .dropdown-menu {
    background: var(--bg-primary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .dropdown-item {
    color: var(--text-primary);
}

[data-theme="dark"] .dropdown-item:hover {
    background: var(--bg-secondary);
}

[data-theme="dark"] .dropdown-header {
    color: var(--text-secondary);
}

[data-theme="dark"] .dropdown-divider {
    border-color: var(--border-color);
}

[data-theme="dark"] .btn-icon {
    color: var(--text-secondary);
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background-color: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background-color: var(--bg-primary);
    border-color: var(--primary-color);
    color: var(--text-primary);
}

[data-theme="dark"] .modal-content {
    background-color: var(--bg-primary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .modal-header {
    border-bottom-color: var(--border-color);
}

[data-theme="dark"] .modal-footer {
    border-top-color: var(--border-color);
}

[data-theme="dark"] .btn-close {
    filter: invert(1);
}

[data-theme="dark"] .table {
    color: var(--text-primary);
}

[data-theme="dark"] .toast-notification {
    background: var(--bg-primary) !important;
    color: var(--text-primary);
}
