/* ساختار کلی صفحه */
main {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #e3f2fd, #ffe0b2);
}

/* حالت عدم لاگین */
.login-required {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    background: linear-gradient(135deg, #90caf9, #ffab91, #e3f2fd);
    animation: gradientShift 10s ease infinite;
}
@keyframes gradientShift {
    0% { background: linear-gradient(135deg, #90caf9, #ffab91); }
    50% { background: linear-gradient(135deg, #e3f2fd, #ffcc80); }
    100% { background: linear-gradient(135deg, #90caf9, #ffab91); }
}
.login-card {
    background: #ffffff;
    border: 1px solid #cfd8dc;
    border-radius: 20px;
    padding: 32px 24px;
    box-shadow: 0 12px 28px rgba(0,0,0,0.18);
    text-align: center;
    max-width: 430px;
    width: 100%;
    animation: fadeIn 0.8s ease;
    transition: transform 0.3s ease;
}
.login-card:hover { transform: translateY(-8px); box-shadow: 0 16px 32px rgba(0,0,0,0.25); }
.icon-wrap { font-size: 48px; color: #ff7043; margin-bottom: 16px; }
.login-text { font-size: 18px; color: #37474f; margin-bottom: 24px; line-height: 1.6; }
.login-actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.login-actions .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 10px 18px; border-radius: 8px; font-size: 14px; font-weight: 600;
    text-decoration: none; transition: all 0.25s ease;
}
.btn-home { background: #e0f2f7; color: #0288d1; border: 1px solid #b3e5fc; }
.btn-home:hover { background: #b3e5fc; box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
.btn-login { background: linear-gradient(135deg, #2196F3, #ff7043); color: #fff; border: none; }
.btn-login:hover { background: linear-gradient(135deg, #1976D2, #f4511e); box-shadow: 0 8px 20px rgba(33,150,243,0.5); }
@keyframes fadeIn { from{opacity:0;transform:translateY(20px);} to{opacity:1;transform:translateY(0);} }

/* کانتینر اصلی پنل */
.content {
    position: relative;
    display: flex;
    flex-direction: row;
    min-height: 100vh;
    overflow: hidden;
    padding-top: 32px;
}

/* ستون منو */
.sidebar {
    flex: 0 0 320px;
    background: linear-gradient(180deg, #ffffff, #e3f2fd);
    border-left: 1px solid #cfd8dc;
    box-shadow: -8px 0 20px rgba(0,0,0,0.15);
    overflow-y: auto;
    border-radius: 12px;
    transition: transform 280ms ease;
    z-index: 10;
    margin: 31px 15px 30px 0;
}
.sidebar .brand {
    padding: 16px;
    border-bottom: 1px solid #cfd8dc;
    font-weight: 700;
    color: #ff7043;
    font-size: 18px;
}

/* دکمه منو (موبایل) */
.toggle-btn { display: none; }

/* آیتم‌های منو */
.menu { list-style: none; padding: 8px 0; margin: 0; }
.menu li {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #e0e0e0;
    color: #455a64;
    transition: background 160ms ease, color 160ms ease, transform 0.2s ease;
}
.menu li:hover { background: #e3f2fd; transform: scale(1.02); color: #ff7043; }
.menu li.active { background: linear-gradient(90deg, #ffab91, #ff8a65); color: #424242; font-weight: bold; }

/* ستون کارت‌ها */
.cards-area { flex: 1; padding: 1rem; }
.card {
    width: 95%;
    margin: 12px 20px;
    background: #ffffff;
    border: 1px solid #cfd8dc;
    border-radius: 16px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.card:hover { transform: translateY(-8px); box-shadow: 0 14px 28px rgba(0,0,0,0.2); }
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid #cfd8dc;
    font-weight: 700;
    color: #0288d1;
}

/* عکس پروفایل */
.user-photo {
    width: 128px; height: 128px;
    border-radius: 50%;
    overflow: hidden;
    border: 5px solid #2196F3;
    margin: 20px auto;
    box-shadow: 0 0 15px rgba(33,150,243,0.6);
    transition: transform 0.3s ease;
}
.user-photo:hover { transform: scale(1.08); }
.user-photo img { width: 100%; height: 100%; object-fit: cover; }

/* دکمه ویرایش عکس */
.photo-edit-btn {
    position: relative;
    bottom: -200px;
    right: 50%;
    transform: translateX(-50%);
    background: #ff7043;
    color: #2196F3;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    z-index: 1;
    display: none;
    border: solid #22689f 2px;
}
.photo-edit-btn:hover { background: #f4511e; box-shadow: 0 4px 10px rgba(244,81,30,0.4); }

/* جدول کاربر */
.user-table { width: 96%; margin: 0 auto 20px; border-collapse: collapse; }
.user-table th, .user-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #a7d9ed;
    text-align: right;
    font-size: 14px;
    vertical-align: middle;
}
.user-table th { background: #b3e5fc; color: #ff7043; font-weight: 700; }
.user-table tr:hover td { background: #e1f5fe; }
.edit-btn {
    background: none; border: none; cursor: pointer;
    font-size: 20px;
    color: #0288d1;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    transition: all 0.3s ease;
}
.edit-btn:hover { color: #f4511e; background: #ffe0b2; box-shadow: 0 2px 8px rgba(244,81,30,0.2); }
.inline-input {
    width: 100%; padding: 8px 10px;
    border: 1px solid #90caf9;
    border-radius: 8px;
    font-family: inherit; background: #fff;
}

/* پنجره پیام مرکزی */
.message-box {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: #ff7043;
    color: #fff;
    padding: 18px 26px;
    border-radius: 12px;
    box-shadow: 0 6px 16px rgba(255,112,67,0.4);
    font-size: 17px;
    opacity: 0;
    transition: all 0.4s ease;
    z-index: 9999;
}
.message-box.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* --- CSS برای جدول امتیازات --- */
.scores-table-container {
    overflow-x: auto;
    margin-top: 15px;
    border: 1px solid #cfd8dc;
    border-radius: 12px;
    padding: 12px;
    background: #ffffff;
    box-shadow: 0 4px 8px rgba(0,0,0,0.08);
    max-height: 600px;
}

/* اسکرول سفارشی */
.scores-table-container::-webkit-scrollbar {
    height: 12px;
    width: 12px;
}
.scores-table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}
.scores-table-container::-webkit-scrollbar-thumb {
    background: linear-gradient(90deg, #2196F3, #ff7043);
    border-radius: 10px;
}
.scores-table-container::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(90deg, #1976D2, #f4511e);
}

.scores-table {
    width: max-content; /* مهم: اجازه می‌دهد جدول بر اساس محتوا عرض بگیرد */
    min-width: 100%; /* حداقل عرض کامل کانتینر */
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 5px;
    font-family: Vazirmatn, sans-serif;
    font-size: 15px;
}

/* افزایش عرض ستون‌ها */
.scores-table th,
.scores-table td {
    min-width: 200px; /* عرض حداقل برای هر ستون */
    padding: 16px 20px;
    border-bottom: 1px solid #e1f5fe;
    text-align: right;
    vertical-align: middle;
    white-space: nowrap;
}

/* استایل سرستون‌ها */
.scores-table th {
    background: linear-gradient(180deg, #b3e5fc, #90caf9);
    color: #ff7043;
    font-weight: 700;
    font-size: 16px;
    border-bottom: 2px solid #2196F3;
    position: sticky;
    top: 0;
    z-index: 2;
    box-shadow: 0 2px 3px rgba(0,0,0,0.1);
}

/* ستون‌های خاص با عرض بیشتر */
.scores-table th:nth-child(1), /* ستون اول (عنوان) */
.scores-table td:nth-child(1) {
    min-width: 250px;
    background-color: #f0f8ff;
    font-weight: 600;
    position: sticky;
    left: 0;
    z-index: 1;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
}

.scores-table th:nth-child(2), /* ستون دوم (امتیاز) */
.scores-table td:nth-child(2) {
    min-width: 180px;
    background-color: #f9f9f9;
}

.scores-table th:nth-child(3), /* ستون سوم (تاریخ) */
.scores-table td:nth-child(3) {
    min-width: 220px;
    background-color: #f0f8ff;
}

.scores-table th:nth-child(4), /* ستون چهارم (وضعیت) */
.scores-table td:nth-child(4) {
    min-width: 200px;
    background-color: #f9f9f9;
}

/* اگر ستون‌های بیشتری دارید */
.scores-table th:nth-child(5),
.scores-table td:nth-child(5) {
    min-width: 200px;
    background-color: #f0f8ff;
}

.scores-table th:nth-child(6),
.scores-table td:nth-child(6) {
    min-width: 200px;
    background-color: #f9f9f9;
}

/* رنگ‌آمیزی سطرها */
.scores-table tbody tr:nth-child(even) {
    background-color: #f8fdff;
}
.scores-table tbody tr:nth-child(odd) {
    background-color: #ffffff;
}

.scores-table tbody tr:hover {
    background-color: #e1f5fe !important;
    transform: scale(1.005);
    transition: transform 0.2s ease, background-color 0.2s ease;
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
}

/* تراز وسط برای ستون‌های عددی */
.scores-table tr td:nth-child(2),
.scores-table tr td:nth-child(5),
.scores-table tr td:nth-child(6) {
    text-align: center;
}

/* استایل برای اعداد امتیاز */
.scores-table td:nth-child(2) {
    font-weight: 700;
    color: #ff7043;
    font-size: 16px;
}

/* استایل برای تاریخ‌ها */
.scores-table td:nth-child(3) {
    color: #0288d1;
    font-family: 'Vazirmatn', 'Courier New', monospace;
    direction: ltr;
    text-align: center;
}

/* استایل برای وضعیت */
.scores-table td:nth-child(4) {
    font-weight: 600;
    text-align: center;
}
.scores-table td.status-completed {
    color: #4CAF50;
    background-color: rgba(76, 175, 80, 0.1) !important;
}
.scores-table td.status-pending {
    color: #FF9800;
    background-color: rgba(255, 152, 0, 0.1) !important;
}
.scores-table td.status-failed {
    color: #f44336;
    background-color: rgba(244, 67, 54, 0.1) !important;
}

/* --- CSS برای سطر مجموع در جدول امتیازات --- */
.scores-table tr.total-row {
    background: linear-gradient(90deg, #e1f5fe, #b3e5fc) !important;
    border-top: 3px solid #0288d1;
    font-weight: bold;
}

.scores-table tr.total-row td {
    color: #0288d1;
    font-size: 16px;
    font-weight: 700;
}

.scores-table tr.total-row td:first-child {
    background: linear-gradient(90deg, #e1f5fe, #b3e5fc) !important;
}

/* هایلایت برای امتیازات بالا */
.scores-table tr.high-score td:nth-child(2) {
    background-color: rgba(255, 235, 59, 0.3) !important;
    color: #ff8f00;
    font-size: 17px;
}

/* --- استایل برای حالت بارگذاری --- */
.loading-scores {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
    color: #0288d1;
    font-size: 17px;
    min-height: 200px;
}

.loading-scores::after {
    content: '';
    width: 24px;
    height: 24px;
    margin-right: 12px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #ff7043;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* استایل برای کارت امتیازات */
.scores-card {
    overflow: hidden;
}

.scores-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
}

.scores-summary {
    display: flex;
    justify-content: space-around;
    padding: 20px;
    background: linear-gradient(135deg, #e3f2fd, #ffecb3);
    border-radius: 12px;
    margin: 0 24px 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.summary-item {
    text-align: center;
    padding: 15px;
}

.summary-item .value {
    font-size: 28px;
    font-weight: 700;
    color: #ff7043;
    display: block;
}

.summary-item .label {
    font-size: 14px;
    color: #0288d1;
    margin-top: 5px;
}

/* واکنش‌گرایی */
@media (max-width: 1200px) {
    .scores-table th,
    .scores-table td {
        min-width: 180px;
        padding: 14px 16px;
        font-size: 14px;
    }
    
    .scores-table th:nth-child(1),
    .scores-table td:nth-child(1) {
        min-width: 220px;
    }
}

@media (max-width: 992px) {
    .content { flex-direction: column; padding-top: 52px; }
    .toggle-btn {
        display: block;
        position: absolute;
        top: 15px; right: 14px;
        background: #2196F3;
        color: #ff7043;
        border: none; width: 45px; height: 45px;
        border-radius: 10px;
        cursor: pointer;
        z-index: 20;
        font-size: 24px;
        box-shadow: 0 4px 12px rgba(33,150,243,0.3);
    }
    .sidebar {
        position: absolute;
        top: 0; right: -15px;
        width: 250px;
        height: 100%;
        transform: translateX(100%);
        margin-top: 77px;
        border-radius: 12px 0 0 12px;
        z-index: 10;
    }
    .sidebar.open { transform: translateX(0); }
    .cards-area { padding: 12px; }
    .card { width: 100%; margin: 12px 0; }
    
    .scores-table-container {
        padding: 8px;
        margin: 10px;
    }
    
    .scores-table th,
    .scores-table td {
        min-width: 160px;
        padding: 12px 14px;
        font-size: 13px;
    }
    
    .scores-table th:nth-child(1),
    .scores-table td:nth-child(1) {
        min-width: 200px;
    }
    
    .scores-summary {
        flex-direction: column;
        padding: 15px;
    }
    
    .summary-item {
        padding: 10px;
    }
}

@media (max-width: 768px) {
    .scores-table th,
    .scores-table td {
        min-width: 140px;
        padding: 10px 12px;
        font-size: 12px;
    }
    
    .scores-table th:nth-child(1),
    .scores-table td:nth-child(1) {
        min-width: 180px;
        position: static;
        box-shadow: none;
    }
    
    .scores-table th:nth-child(1) {
        position: sticky;
        left: 0;
    }
    
    .scores-table-container {
        border-radius: 8px;
        padding: 6px;
    }
    
    .summary-item .value {
        font-size: 22px;
    }
}

@media (max-width: 576px) {
    .scores-table-container {
        margin: 5px;
        padding: 4px;
    }
    
    .scores-table th,
    .scores-table td {
        min-width: 120px;
        padding: 8px 10px;
        font-size: 11px;
    }
    
    .scores-table th:nth-child(1),
    .scores-table td:nth-child(1) {
        min-width: 160px;
    }
}