/* ===== Timetable / Weekly Schedule (Pro UI Edition) ===== */

.timetable-section {
    margin-bottom: 40px;
    animation: fade-in-up 0.4s ease-out forwards;
}

.timetable-section > h2 {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.timetable-section > h2 svg {
    color: var(--primary, #3b82f6);
    background: var(--primary-soft, #eff6ff);
    padding: 4px;
    border-radius: 8px;
    width: 28px;
    height: 28px;
}

/* =========================================
   1. حالت دسکتاپ و تبلت (جدول گرید مدرن و خلوت)
   ========================================= */
.timetable-wrap {
    width: 100%;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    overflow: hidden;
}

.timetable {
    width: 100%;
    table-layout: fixed; /* باعث میشود عرض ستون ها دقیقا متناسب با colspan باشند */
    border-collapse: collapse;
    direction: rtl;
}

/* هدر ساعت‌ها */
.timetable thead tr {
    border-bottom: 2px solid var(--border);
    background: var(--bg-card);
}

.tt-corner {
    border-left: 1px solid var(--border);
}

.tt-hour-th {
    position: relative;
    height: 40px;
    padding: 0;
    border-left: 1px dashed var(--border);
    vertical-align: bottom;
}

.tt-hour-label {
    position: absolute;
    bottom: 0px;
    right: 0;
    transform: translateX(50%);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-card);
    opacity: 0.7;
    padding: 2px 6px;
    border-radius: 12px;
    z-index: 2;
    pointer-events: none;
}

/* ردیف‌های روز */
.timetable tbody tr {
    border-bottom: 1px dashed var(--border);
}
.timetable tbody tr:last-child {
    border-bottom: none;
}

.tt-day-th {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
    background: var(--bg-hover);
    border-left: 1px solid var(--border);
    text-align: center;
    vertical-align: middle;
    height: 80px; /* کمی ارتفاع را کم کردیم تا جمع و جورتر شود */
    padding: 0 8px;
}

/* سلول‌های خالی */
.tt-empty {
    border-left: 1px dashed var(--border);
    height: 80px;
    transition: background 0.2s;
}
.timetable tbody tr:hover .tt-empty {
    background: rgba(0, 0, 0, 0.015);
}

/* سلول کلاس */
.tt-class {
    padding: 4px;
    vertical-align: middle;
    height: 80px;
    border-left: 1px dashed var(--border);
    box-sizing: border-box;
}

/* بلوک داخل سلول */
.tt-block {
    border-radius: 10px;
    padding: 8px;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center; /* محتوا دقیقاً وسط قرار میگیرد */
    gap: 4px;
    text-align: right;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    z-index: 1;
    box-sizing: border-box;
}

.tt-block:hover {
    /* transform: translateY(-2px); */
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.08);
    z-index: 5;
}

.tt-block-title {
    font-size: 0.8rem;
    font-weight: 800;
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.tt-block-loc {
    font-size: 0.65rem;
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@keyframes fade-in-up {
    0% { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* تنظیمات اختصاصی دسکتاپ و تبلت برای مخفی کردن ساعت */
@media (min-width: 769px) {
    /* چون ساعت در هدر بالایی (محور X) هست، در دسکتاپ از داخل سلول حذف میشود */
    .tt-block-time {
        display: none !important; 
    }
}

@media (max-width: 900px) and (min-width: 769px) {
    .tt-day-th { font-size: 0.75rem; padding: 0 4px; }
    .tt-block { padding: 4px 6px; }
    .tt-block-title { font-size: 0.75rem; }
    .tt-class, .tt-empty, .tt-day-th { height: 70px; }
}

/* =========================================
   2. حالت موبایل (Agenda View / فشرده و حرفه‌ای)
   ========================================= */
@media (max-width: 768px) {
    .timetable-wrap {
        border: none;
        background: transparent;
        box-shadow: none;
        border-radius: 0;
    }

    .timetable, .timetable tbody, .timetable tr, .timetable th, .timetable td {
        display: block;
        width: 100% !important;
    }

    .timetable thead, .tt-empty {
        display: none !important;
    }

    /* کارت روزانه فشرده‌تر */
    .timetable tbody tr {
        background: var(--bg-card);
        border: 1px solid var(--border);
        border-radius: 12px;
        margin-bottom: 12px; /* کاهش فاصله بین روزها */
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
        overflow: hidden;
    }

    /* عنوان روز باریک‌تر */
    .tt-day-th {
        height: auto;
        padding: 8px 12px;
        text-align: right;
        border-bottom: 1px solid var(--border);
        font-size: 0.85rem;
        background: var(--bg-hover);
        color: var(--primary, #3b82f6);
    }

    /* کاهش پدینگ سلول‌ها برای صرفه‌جویی در فضای عمودی */
    .tt-class {
        height: auto;
        padding: 8px;
        border-bottom: 1px dashed var(--border);
    }
    .timetable tbody tr td:last-child {
        border-bottom: none;
    }

    /* === تغییر جادویی: استفاده از Grid برای موبایل === */
    .tt-block {
        display: grid;
        /* ستون اول: ساعت (عرض 75px)، ستون دوم: بقیه اطلاعات */
        grid-template-columns: 75px 1fr;
        grid-template-rows: auto auto;
        grid-template-areas: 
            "time title"
            "time loc";
        align-items: center;
        gap: 2px 12px;
        padding: 8px;
        border-radius: 8px;
    }

    .tt-block:hover {
        transform: none;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    }

    /* بلاک ساعت در سمت راست (موبایل) */
    .tt-block-time {
        grid-area: time;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        background: rgba(0, 0, 0, 0.04); /* بک‌گراند تیره ملایم برای متمایز شدن ساعت */
        border-radius: 6px;
        padding: 6px 4px;
        font-size: 0.65rem;
        font-weight: 700;
        opacity: 0.9;
        text-align: center;
        line-height: 1.3;
        /* حذف آیکون در موبایل برای خلوت شدن */
    }
    .tt-block-time::before {
        display: none;
    }

    .tt-block-title {
        grid-area: title;
        font-size: 0.85rem;
        -webkit-line-clamp: 2;
        margin-top: 2px;
    }

    .tt-block-loc {
        grid-area: loc;
        font-size: 0.7rem;
        opacity: 0.75;
        margin-bottom: 2px;
    }
}
