/* Simple Water Analytics Pro - Modern Styles v2.2 */

/* متغیرهای CSS */
:root {
    --swa-primary: #3498db;
    --swa-primary-dark: #2980b9;
    --swa-primary-light: #5dade2;
    --swa-success: #2ecc71;
    --swa-success-dark: #27ae60;
    --swa-warning: #f39c12;
    --swa-danger: #e74c3c;
    --swa-gray: #95a5a6;
    --swa-gray-dark: #7f8c8d;
    --swa-text: #2c3e50;
    --swa-text-light: #7f8c8d;
    --swa-bg-light: #f8f9fa;
    --swa-border: #e1e8ed;
    --swa-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
    --swa-shadow-hover: 0 8px 16px rgba(0, 0, 0, 0.1);
    --swa-radius: 12px;
    --swa-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset و تنظیمات پایه */
.swa-dashboard * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* کانتینر اصلی */
.swa-dashboard {
    position: relative;
    width: 100%;
    font-family: inherit;
    color: var(--swa-text);
    background-color: transparent;
    direction: rtl;
    line-height: 1.6;
}

/* سازگاری با المنتور */
.elementor-widget-container .swa-dashboard {
    width: 100%;
    max-width: 100%;
}



.swa-loading-content {
    text-align: center;
    animation: fadeInUp 0.6s ease;
}

.swa-loading-content p {
    margin-top: 20px;
    font-size: 16px;
    color: var(--swa-text-light);
    font-family: inherit;
}

/* اسپینر بهبود یافته */
.spinner {
    position: relative;
    width: 60px;
    height: 60px;
    margin: 0 auto;
}

.spinner::before,
.spinner::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid transparent;
    border-top-color: var(--swa-primary);
    animation: spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

.spinner::after {
    animation-delay: -0.3s;
    border-top-color: var(--swa-primary-light);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.swa-loading-content p {
    margin: 0;
    color: #555;
    font-size: 16px;
    font-weight: 500;
}

/* انیمیشن fade برای لودینگ */
.swa-container-loading.hide {
    opacity: 0;
    transition: opacity 0.3s ease-out;
    pointer-events: none;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* کانتینر داخلی */
/* لودینگ داخل کانتینر */
.swa-container {
    position: relative; /* برای positioning درست لودینگ */
    min-height: 400px; /* حداقل ارتفاع برای نمایش بهتر لودینگ */
}

.swa-container-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    min-height: 400px;
    border-radius: 10px;
}

.swa-loading-content {
    text-align: center;
    padding: 40px;
}

.swa-loading-content .spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

/* هدر بهبود یافته */
.swa-header {
    text-align: center;
    margin-bottom: 50px;
    animation: fadeInDown 0.8s ease;
}

.swa-title {
    font-size: 36px;
    font-weight: 700;
    color: var(--swa-text);
    margin-bottom: 12px;
    font-family: inherit;
    position: relative;
    display: inline-block;
}

.swa-title::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 4px;
    background: var(--swa-primary);
    border-radius: 2px;
}

.swa-subtitle {
    font-size: 17px;
    color: var(--swa-text-light);
    font-family: inherit;
    margin-top: 20px;
}

/* بخش فیلترها بهبود یافته */
.swa-filters-section {
    background: #ffffff;
    border-radius: var(--swa-radius);
    padding: 35px;
    box-shadow: var(--swa-shadow);
    margin-bottom: 35px;
    border: 1px solid var(--swa-border);
    transition: var(--swa-transition);
    animation: fadeIn 0.6s ease;
}

.swa-filters-section:hover {
    box-shadow: var(--swa-shadow-hover);
}

.swa-filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--swa-bg-light);
}

.swa-filters-header h3 {
    font-size: 22px;
    font-weight: 600;
    color: var(--swa-text);
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 10px;
}

.swa-filters-header h3::before {
    content: '🔍';
    font-size: 24px;
}

.swa-total-records {
    font-size: 15px;
    color: var(--swa-text-light);
    font-family: inherit;
    background: var(--swa-bg-light);
    padding: 8px 16px;
    border-radius: 20px;
}

.swa-total-records strong {
    color: var(--swa-primary);
    font-weight: 600;
}

/* کانتینر فیلترها */
.swa-filters-container {
    width: 100%;
}

.swa-filters-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    align-items: flex-end;
}

/* آیتم‌های فیلتر بهبود یافته */
.swa-filter-item {
    position: relative;
}

.swa-filter-item label {
    display: block;
    margin-bottom: 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--swa-text);
    font-family: inherit;
    transition: var(--swa-transition);
}

.swa-filter-item:hover label {
    color: var(--swa-primary);
}

/* استایل select بهبود یافته */
.swa-select {
    width: 100%;
    padding: 14px 45px 14px 16px;
    border: 2px solid var(--swa-border);
    border-radius: 10px;
    background-color: #fff;
    font-size: 15px;
    color: var(--swa-text);
    font-family: inherit;
    transition: var(--swa-transition);
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg width='14' height='8' viewBox='0 0 14 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M1 1L7 7L13 1' stroke='%233498db' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left 16px center;
    cursor: pointer;
    position: relative;
}

.swa-select:hover {
    border-color: var(--swa-primary);
    background-color: var(--swa-bg-light);
}

.swa-select:focus {
    outline: none;
    border-color: var(--swa-primary);
    box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.15);
    background-color: #fff;
}

/* دکمه‌های بهبود یافته */
.swa-filter-actions {
    display: flex;
    gap: 12px;
    margin-top: 25px;
}

.swa-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--swa-transition);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.swa-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.swa-btn:hover::before {
    width: 300px;
    height: 300px;
}

.swa-btn-icon {
    font-size: 18px;
    position: relative;
    z-index: 1;
}

.swa-btn span {
    position: relative;
    z-index: 1;
}

.swa-btn-primary {
    background: linear-gradient(135deg, var(--swa-primary) 0%, var(--swa-primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.swa-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
}

.swa-btn-secondary {
    background: linear-gradient(135deg, var(--swa-gray) 0%, var(--swa-gray-dark) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(149, 165, 166, 0.3);
}

.swa-btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(149, 165, 166, 0.4);
}

.swa-btn-success {
    background: linear-gradient(135deg, var(--swa-success) 0%, var(--swa-success-dark) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(46, 204, 113, 0.3);
}

.swa-btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(46, 204, 113, 0.4);
}

/* انیمیشن pulse برای دکمه export */
@keyframes pulse {
    0% {
        box-shadow: 0 4px 12px rgba(46, 204, 113, 0.3);
    }
    50% {
        box-shadow: 0 4px 20px rgba(46, 204, 113, 0.6);
    }
    100% {
        box-shadow: 0 4px 12px rgba(46, 204, 113, 0.3);
    }
}

#export-data {
    animation: pulse 2s ease-in-out infinite;
}

/* کانتینر دکمه export */
.swa-export-container {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 25px;
    gap: 12px;
    animation: fadeInRight 0.6s ease;
}

/* بخش آمار بهبود یافته */
.swa-stats-section {
    margin-bottom: 35px;
    animation: fadeIn 0.8s ease;
}

.swa-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
}

.swa-stat-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: var(--swa-radius);
    padding: 30px;
    box-shadow: var(--swa-shadow);
    border: 1px solid var(--swa-border);
    display: flex;
    align-items: center;
    gap: 25px;
    transition: var(--swa-transition);
    position: relative;
    overflow: hidden;
}

.swa-stat-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(52, 152, 219, 0.05) 0%, transparent 70%);
    transform: rotate(45deg);
    transition: var(--swa-transition);
}

.swa-stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--swa-shadow-hover);
}

.swa-stat-card:hover::before {
    transform: rotate(45deg) scale(1.1);
}

.swa-stat-icon {
    font-size: 48px;
    opacity: 0.9;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
    transition: var(--swa-transition);
}

.swa-stat-card:hover .swa-stat-icon {
    transform: scale(1.1);
}

.swa-stat-content {
    flex: 1;
    position: relative;
}

.swa-stat-content h3 {
    font-size: 36px;
    font-weight: 700;
    color: var(--swa-primary);
    margin-bottom: 8px;
    font-family: inherit;
    line-height: 1;
}

.swa-stat-content p {
    font-size: 15px;
    color: var(--swa-text-light);
    font-family: inherit;
}

.swa-stat-percentage {
    display: inline-block;
    margin-top: 8px;
    padding: 5px 12px;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    color: #1565c0;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    box-shadow: 0 2px 4px rgba(21, 101, 192, 0.1);
}

/* بخش نمودارها بهبود یافته */
.swa-charts-section {
    margin-bottom: 35px;
    animation: fadeIn 1s ease;
}

.swa-charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
}

.swa-chart-card {
    background: #ffffff;
    border-radius: var(--swa-radius);
    padding: 30px;
    box-shadow: var(--swa-shadow);
    border: 1px solid var(--swa-border);
    transition: var(--swa-transition);
    position: relative;
    overflow: hidden;
}

.swa-chart-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--swa-primary) 0%, var(--swa-primary-light) 100%);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}

.swa-chart-card:hover::before {
    transform: translateX(0);
}

.swa-chart-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--swa-shadow-hover);
}

.swa-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.swa-chart-header h3 {
    font-size: 19px;
    font-weight: 600;
    color: var(--swa-text);
    font-family: inherit;
}

.swa-chart-type {
    font-size: 12px;
    color: var(--swa-gray);
    background: var(--swa-bg-light);
    padding: 5px 12px;
    border-radius: 20px;
    font-family: inherit;
    font-weight: 500;
}

.swa-chart-body {
    position: relative;
    height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* پیام عدم وجود داده بهبود یافته */
.swa-no-data-message {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: var(--swa-radius);
    padding: 80px 40px;
    text-align: center;
    border: 2px dashed var(--swa-border);
    animation: fadeIn 0.6s ease;
}

.swa-no-data-icon {
    font-size: 72px;
    margin-bottom: 25px;
    opacity: 0.6;
    animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.swa-no-data-message h3 {
    font-size: 26px;
    color: var(--swa-text);
    margin-bottom: 12px;
    font-family: inherit;
}

.swa-no-data-message p {
    font-size: 17px;
    color: var(--swa-text-light);
    font-family: inherit;
    max-width: 500px;
    margin: 0 auto;
}

/* Loading States برای المان‌ها */
.swa-loading {
    position: relative;
    pointer-events: none;
}

.swa-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
}

/* Skeleton Loading */
.swa-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* تغییرات برای تم‌های تیره */
.swa-dashboard.dark-mode {
    --swa-text: #ecf0f1;
    --swa-text-light: #bdc3c7;
    --swa-bg-light: #34495e;
    --swa-border: #2c3e50;
}

.swa-dashboard.dark-mode .swa-filters-section,
.swa-dashboard.dark-mode .swa-stat-card,
.swa-dashboard.dark-mode .swa-chart-card {
    background: #2c3e50;
    border-color: #34495e;
}

.swa-dashboard.dark-mode .swa-select {
    background-color: #34495e;
    border-color: #576574;
    color: #ecf0f1;
}

/* Scrollbar سفارشی بهبود یافته */
.swa-select::-webkit-scrollbar {
    width: 10px;
}

.swa-select::-webkit-scrollbar-track {
    background: var(--swa-bg-light);
    border-radius: 5px;
}

.swa-select::-webkit-scrollbar-thumb {
    background: var(--swa-primary);
    border-radius: 5px;
    transition: background 0.3s;
}

.swa-select::-webkit-scrollbar-thumb:hover {
    background: var(--swa-primary-dark);
}

/* سازگاری با SweetAlert2 */
.swal2-popup {
    font-family: inherit !important;
    border-radius: var(--swa-radius) !important;
}

.swal2-rtl .swal2-content {
    text-align: right;
    font-family: inherit;
}

/* انیمیشن‌های اضافی */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ریسپانسیو بهبود یافته */
@media (max-width: 768px) {
    .swa-container {
        padding: 20px;
    }

    .swa-title {
        font-size: 28px;
    }

    .swa-subtitle {
        font-size: 15px;
    }

    .swa-filters-section {
        padding: 25px 20px;
    }

    .swa-filters-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .swa-filters-row {
        grid-template-columns: 1fr;
    }

    .swa-filter-actions {
        width: 100%;
        flex-direction: column;
        margin-top: 20px;
    }

    .swa-btn {
        width: 100%;
        justify-content: center;
        padding: 16px;
    }

    .swa-stats-grid,
    .swa-charts-grid {
        grid-template-columns: 1fr;
    }

    .swa-stat-card {
        padding: 25px 20px;
    }

    .swa-chart-card {
        padding: 25px 20px;
    }

    .swa-chart-body {
        height: 280px;
    }

    .swa-export-container {
        justify-content: center;
    }

    .swa-no-data-message {
        padding: 60px 30px;
    }
}

@media (max-width: 480px) {
    .swa-title {
        font-size: 24px;
    }

    .swa-stat-content h3 {
        font-size: 28px;
    }

    .swa-stat-icon {
        font-size: 40px;
    }
}

/* Print Styles */
@media print {
    .swa-filter-actions,
    .swa-export-container {
        display: none !important;
    }

    .swa-dashboard {
        color: #000 !important;
    }

    .swa-chart-card,
    .swa-stat-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}
