/* تحسين بطاقات الإحصائيات الكلية */
.total-stats-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 15px 35px rgba(31, 38, 135, 0.15);
    border-radius: 25px;
    margin-bottom: 2rem;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.total-stats-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.3) 50%, transparent 70%);
    transform: rotate(35deg);
    transition: all 0.6s ease;
    opacity: 0;
}

.total-stats-card:hover::before {
    opacity: 1;
    animation: shimmer 1.5s ease-in-out;
}

.total-stats-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 25px 50px rgba(31, 38, 135, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
}

@keyframes shimmer {
    0% { transform: translateX(-100%) translateY(-100%) rotate(35deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(35deg); }
}

.total-stat-item {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
    height: 100%;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.total-stat-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.total-stat-item:hover::before {
    opacity: 1;
}

.total-stat-item .stat-icon {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.2) 100%);
    color: #667eea;
    width: 70px;
    height: 70px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    font-size: 1.8rem;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.total-stat-item:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 15px 40px rgba(102, 126, 234, 0.3);
    border-color: rgba(255, 255, 255, 0.6);
}

.total-stat-item:hover .stat-icon {
    background: rgba(255, 255, 255, 0.25);
    color: white;
    transform: scale(1.15) rotate(5deg);
    box-shadow: 0 8px 25px rgba(255, 255, 255, 0.4);
    border-color: rgba(255, 255, 255, 0.5);
}

.total-stat-item .stat-info {
    text-align: center;
}

.total-stat-item .stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: #1e293b;
    display: block;
    margin-bottom: 0.75rem;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.total-stat-item:hover .stat-value {
    transform: scale(1.1);
    color: white;
    -webkit-text-fill-color: white;
    text-shadow: 0 2px 10px rgba(255, 255, 255, 0.3);
}

.total-stat-item .stat-label {
    font-size: 0.95rem;
    color: #64748b;
    display: block;
    font-weight: 600;
    letter-spacing: 0.025em;
    transition: all 0.4s ease;
}

/* تخصيص الألوان والتأثيرات لكل نوع */
.total-stat-item.success .stat-icon {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.total-stat-item.success:hover {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.total-stat-item.success:hover .stat-icon {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

.total-stat-item.info .stat-icon {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.total-stat-item.info:hover {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.total-stat-item.info:hover .stat-icon {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

.total-stat-item.warning .stat-icon {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.total-stat-item.warning:hover {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.total-stat-item.warning:hover .stat-icon {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

.total-stat-item.danger .stat-icon {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.total-stat-item.danger:hover {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.total-stat-item.danger:hover .stat-icon {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

.total-stat-item.cancelled .stat-icon {
    background: rgba(148, 163, 184, 0.1);
    color: #64748b;
}

.total-stat-item.cancelled:hover {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
}

.total-stat-item.cancelled:hover .stat-icon {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

/* تأثير التحويم على النص */
.total-stat-item:hover .stat-value,
.total-stat-item:hover .stat-label {
    color: white;
}

/* تحسين عنوان القسم */
.total-stats-card .card-title {
    font-size: 1.5rem;
    color: #1e293b;
    font-weight: 600;
    position: relative;
    padding-bottom: 1rem;
    margin-bottom: 2rem;
    text-align: center;
}

.total-stats-card .card-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: linear-gradient(to right, #3b82f6, #2563eb);
    border-radius: 2px;
}

/* تحسين التجاوب */
@media (max-width: 768px) {
    .total-stat-item {
        margin-bottom: 1rem;
    }
    
    .total-stat-item .stat-value {
        font-size: 1.5rem;
    }
    
    .total-stat-item .stat-label {
        font-size: 0.8rem;
    }
}

/* إضافة تأثيرات الحركة */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translate3d(0, 20px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

[data-aos="fade-up"] {
    opacity: 0;
    transform: translate3d(0, 20px, 0);
    transition: transform 0.6s ease, opacity 0.6s ease;
}

[data-aos="fade-up"].aos-animate {
    opacity: 1;
    transform: translate3d(0, 0, 0);
}

/* تحسين بطاقة مقارنة المناطق */
.region-comparison-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: none;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05);
    border-radius: 20px;
    margin-bottom: 2rem;
    transition: all 0.3s ease;
}

.region-comparison-card:hover {
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
}

.region-stats-card {
    background: white;
    border-radius: 15px;
    padding: 1.5rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    height: 100%;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.region-stats-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.region-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    position: relative;
}

.region-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    color: white;
    font-size: 1.5rem;
    transition: all 0.3s ease;
}

.region-stats-card:hover .region-icon {
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}

.municipality-name {
    color: #1e293b;
    font-size: 1.25rem;
    font-weight: 600;
    margin: 1rem 0;
}

.total-permits {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.total-permits .number {
    font-size: 2rem;
    font-weight: 700;
    color: #6366f1;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.total-permits .label {
    font-size: 0.9rem;
    color: #64748b;
}

.stats-details {
    margin-top: 1.5rem;
}

.stat-row {
    margin-bottom: 1.5rem;
    padding: 0.75rem;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.stat-row:hover {
    background: #f8fafc;
}

.stat-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.stat-label-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-label-group i {
    font-size: 1rem;
}

.stat-label {
    color: #4b5563;
    font-size: 0.9rem;
    font-weight: 500;
}

.stat-number {
    font-weight: 600;
    color: #1e293b;
}

.stat-progress {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.progress {
    flex: 1;
    height: 8px;
    background: #f1f5f9;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    border-radius: 4px;
    position: relative;
    overflow: hidden;
    transition: width 0.6s ease;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, 
        rgba(255, 255, 255, 0) 0%, 
        rgba(255, 255, 255, 0.3) 50%, 
        rgba(255, 255, 255, 0) 100%);
    animation: shimmer 2s infinite;
}

.percentage {
    min-width: 45px;
    font-size: 0.85rem;
    color: #64748b;
    font-weight: 500;
}

/* تخصيص ألوان شريط التقدم */
.progress-bar.bg-success {
    background: linear-gradient(90deg, #10b981, #059669);
}

.progress-bar.bg-info {
    background: linear-gradient(90deg, #6366f1, #4f46e5);
}

.progress-bar.bg-warning {
    background: linear-gradient(90deg, #f59e0b, #d97706);
}

.progress-bar.bg-danger {
    background: linear-gradient(90deg, #ef4444, #dc2626);
}

/* تحسين التجاوب للشاشات الصغيرة */
@media (max-width: 768px) {
    .region-stats-card {
        margin-bottom: 1rem;
    }

    .municipality-name {
        font-size: 1.1rem;
    }

    .total-permits .number {
        font-size: 1.75rem;
    }

    .stat-label {
        font-size: 0.85rem;
    }

    .stat-number {
        font-size: 0.9rem;
    }
}

/* تأثير التحميل */
@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* إضافة أنماط عصرية للوحة التحكم */
.dashboard-container {
    padding: 0;
    animation: fadeInUp 0.8s ease-out;
}

.dashboard-header {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 2rem;
    margin-bottom: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 10px 30px rgba(31, 38, 135, 0.1);
}

.dashboard-header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    text-align: center;
}

/* تحسين تأثيرات الصفوف والأعمدة */
.row {
    margin-left: -0.75rem;
    margin-right: -0.75rem;
}

.row > * {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

/* تأثيرات الحركة المحسنة */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* تحسين البطاقات العامة */
.card {
    border: none;
    border-radius: 20px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.card .card-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 1.5rem;
    position: relative;
    padding-bottom: 1rem;
}

.card .card-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 2px;
}

/* تحسين الأزرار */
.btn {
    border-radius: 12px;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

/* تحسين الجداول */
.table {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 15px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.table th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
    border: none;
    padding: 1rem;
}

.table td {
    padding: 0.875rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    vertical-align: middle;
}

.table tbody tr:hover {
    background: rgba(102, 126, 234, 0.05);
    transform: scale(1.01);
    transition: all 0.3s ease;
}

/* تحسين النماذج */
.form-control {
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 0.75rem 1rem;
    transition: all 0.3s ease;
}

.form-control:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
    background: rgba(255, 255, 255, 0.95);
}

/* تحسين التنبيهات */
.alert {
    border-radius: 15px;
    border: none;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 1rem 1.5rem;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* تحسين الرسائل المنبثقة */
.modal .modal-content {
    border-radius: 20px;
    border: none;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 20px 50px rgba(31, 38, 135, 0.3);
}

.modal .modal-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding: 1.5rem 2rem;
}

.modal .modal-body {
    padding: 2rem;
}

.modal .modal-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    padding: 1.5rem 2rem;
}

/* تحسين الفواصل */
hr {
    border: none;
    height: 1px;
    background: linear-gradient(135deg, transparent 0%, rgba(102, 126, 234, 0.3) 50%, transparent 100%);
    margin: 2rem 0;
}

/* تحسين شامل للألوان */
.text-primary {
    color: #667eea !important;
}

.bg-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
}

.border-primary {
    border-color: #667eea !important;
}

/* ===== Multi-region dashboard refinements ===== */
.multi-region-dashboard .stat-clickable {
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.region-summary-card .card-title {
    text-align: right;
}

.compact-region-table th,
.compact-region-table td {
    white-space: nowrap;
}

.compact-region-table th.sortable {
    cursor: pointer;
}

.compact-region-table th.sortable:hover {
    color: #2563eb;
}

.chart-scroll-wrapper {
    overflow-x: auto;
    min-height: 360px;
}

.chart-scroll-wrapper canvas {
    min-height: 340px;
}

.region-search-wrap {
    width: min(100%, 320px);
}

.tables-navigation .btn-group .btn-toggle {
    background: rgba(255, 255, 255, 0.75);
    color: #334155;
    border: 1px solid rgba(148, 163, 184, 0.25);
}

.tables-navigation .btn-group .btn-toggle.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}

.table-section {
    display: none;
}

.table-section.active {
    display: block;
}

.table-container .card-header {
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(255, 255, 255, 0.6);
}

.modern-modal {
    border: none;
    border-radius: 20px;
    overflow: hidden;
}

.modern-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
}

.modal-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    margin-left: 10px;
}

.stats-control-bar {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.total-count-badge {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: #fff;
    border-radius: 999px;
    padding: 6px 12px;
    font-weight: 600;
}

.stats-content-wrapper {
    max-height: 60vh;
    overflow-y: auto;
}

.load-more-section {
    background: #fff;
    border-top: 1px solid #e2e8f0;
    padding: 14px 20px;
    text-align: center;
}

.btn-gradient {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
}

.modern-table thead th {
    background: #eef2ff;
    color: #1e293b;
}

.loading-state,
.empty-state {
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.modern-spinner {
    width: 48px;
    height: 48px;
}

.spinner-ring {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 4px solid #e2e8f0;
    border-top-color: #667eea;
    animation: spin 1s linear infinite;
}