/* ------------------------------------------------ */
/* LOCAL VAZIRMATN FONTS */
/* ------------------------------------------------ */

@font-face {
    font-family: "Vazirmatn";
    src: url("fonts/Vazirmatn-Regular.ttf") format("truetype");
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: "Vazirmatn";
    src: url("fonts/Vazirmatn-Medium.ttf") format("truetype");
    font-weight: 500;
    font-display: swap;
}

@font-face {
    font-family: "Vazirmatn";
    src: url("fonts/Vazirmatn-Bold.ttf") format("truetype");
    font-weight: 700;
    font-display: swap;
}

/* ------------------------------------------------ */
/* RESET */
/* ------------------------------------------------ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ------------------------------------------------ */
/* BODY & LAYOUT */
/* ------------------------------------------------ */

body {
    background-image: url("images/background.jpg");
    background-repeat: no-repeat;
    background-position: center center;
    background-size: cover;
    background-attachment: fixed;

    font-family: "Vazirmatn", sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    direction: rtl;
    padding: 60px 20px;
}

/* ------------------------------------------------ */
/* MAIN CONTAINER */
/* ------------------------------------------------ */

.exams-container {
    background: white;
    padding: 40px;
    border-radius: 14px;
    width: 100%;
    max-width: 900px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.15);
}

.page-title-container {
    text-align: center;
    margin-bottom: 35px;
}

.page-title-container h1 {
    font-weight: 700;
    color: #333;
    margin-bottom: 8px;
}

.page-title-container p {
    color: #666;
    font-size: 15px;
}

/* ------------------------------------------------ */
/* GRID & CARDS (Updated for Single Row) */
/* ------------------------------------------------ */

.exams-grid {
    display: grid;
    grid-template-columns: 1fr; /* نمایش در یک سطر */
    gap: 20px;
}

.exam-card {
    background: #f8f9fa;
    border: 1px solid #eaeaea;
    border-radius: 12px;
    padding: 24px;
    display: flex;
    flex-direction: row; /* چیدمان افقی برای دسکتاپ */
    align-items: center;
    justify-content: space-between;
    gap: 30px;
    transition: transform 0.3s, box-shadow 0.3s;
}

.exam-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.08);
    border-color: #667eea;
}

.exam-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.exam-title {
    font-size: 18px;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 10px;
    line-height: 1.4;
}

.exam-desc {
    font-size: 14px;
    color: #555;
    line-height: 1.6;
    margin-bottom: 8px;

    /* نمایش محدود خطوط در حالت پیش‌فرض */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* کلاسی که با کلیک روی دکمه اضافه می‌شود تا متن کامل نمایش داده شود */
.exam-desc.expanded {
    -webkit-line-clamp: initial;
}

.toggle-desc-btn {
    background: none;
    border: none;
    color: #667eea;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    padding: 0;
    transition: color 0.2s;
}

.toggle-desc-btn:hover {
    color: #5563d6;
    text-decoration: underline;
}

.exam-action {
    min-width: 220px; /* عرض ثابت برای بخش دکمه در دسکتاپ */
    flex-shrink: 0;
}

/* ------------------------------------------------ */
/* BUTTONS */
/* ------------------------------------------------ */

.btn-primary, .btn-secondary {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-family: "Vazirmatn", sans-serif;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s, transform 0.1s;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #5563d6;
}

.btn-primary:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
    margin-top: 15px;
    width: auto;
    padding: 10px 24px;
}

.btn-secondary:hover:not(:disabled) {
    background: #cbd5e0;
}

/* کلاس جدید برای دکمه‌های انصراف / لغو بصورت متنی */
.btn-text {
    background: transparent;
    border: none;
    color: #718096;
    width: 100%;
    padding: 10px;
    margin-top: 5px;
    font-family: "Vazirmatn", sans-serif;
    font-size: 14px;
    cursor: pointer;
    transition: color 0.2s;
}

.btn-text:hover {
    color: #4a5568;
    text-decoration: underline;
}

/* ------------------------------------------------ */
/* LOADING & ERROR STATES */
/* ------------------------------------------------ */

.loading-container, .error-container {
    text-align: center;
    padding: 40px 0;
}

.error-container p {
    color: #e63946;
    margin-bottom: 15px;
    font-weight: 500;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px auto;
}

.spinner-small {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top: 3px solid #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ------------------------------------------------ */
/* MODAL */
/* ------------------------------------------------ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.modal-content h3 {
    margin-bottom: 15px;
    color: #2c3e50;
}

.modal-content p {
    color: #555;
    margin-bottom: 20px;
    font-size: 15px;
    line-height: 1.6;
}

.modal-error {
    background: #fdf0ed;
    color: #e74c3c;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 14px;
    border: 1px solid rgba(231, 76, 60, 0.2);
}

.modal-actions {
    display: flex;
    gap: 10px;
    flex-direction: column;
}

.modal-actions .btn-secondary {
    margin-top: 0;
    width: 100%;
}

/* ------------------------------------------------ */
/* RESPONSIVE */
/* ------------------------------------------------ */

@media (max-width: 600px) {
    .exams-container {
        padding: 25px 20px;
    }
    .exam-card {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }
    .exam-action {
        min-width: 100%;
        margin-top: 10px;
    }
}
