﻿/* ═══════════════════════════════════════════════════════════════
   Filtered Table Styles — Final Version
   ═══════════════════════════════════════════════════════════════ */

:root {
    --primary: #3498db;
    --success: #2ecc71;
    --danger: #e74c3c;
    --warning: #f39c12;
    --light: #f8f9fa;
    --dark: #2c3e50;
    --border: #e1e5e9;
}

body {
    font-family: 'IRANSans', 'Vazirmatn', sans-serif;
    color: var(--dark);
    background: var(--light);
    margin: 0;
    padding: 15px;
    direction: rtl;
    font-size: 14px;
    line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════════════
   راهنمای رنگ — افقی
   ═══════════════════════════════════════════════════════════════ */
.color-guide {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    padding: 8px 12px;
    background: #f8fafd;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 0.82rem;
    align-items: center;
    border: 1px solid var(--border);
}

    .color-guide .color-item {
        display: flex;
        align-items: center;
        gap: 6px;
        padding: 4px 8px;
        border-radius: 4px;
        background: white;
    }

    .color-guide .color-box {
        width: 16px;
        height: 16px;
        border-radius: 4px;
        border: 1px solid #ccc;
    }

.color-box.first-half-color {
    background: #ffffff;
    border: 1px solid #90caf9;
}

.color-box.second-half-color {
    background: #ffffff;
    border: 1px solid #a5d6a7;
}

.color-box.friday-color {
    background: #ffe8e8;
    border: 1px solid #dc3545;
}

.color-box.holiday-color {
    background: #fff8dc;
    border: 1px solid #f0ad4e;
}

/* ═══════════════════════════════════════════════════════════════
   هدر اطلاعات — افقی
   ═══════════════════════════════════════════════════════════════ */
.header-info {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    background: #f0f6ff;
    border-radius: 10px;
    padding: 10px 16px;
    margin-bottom: 12px;
    border: 1px solid #d6e2ee;
}

    .header-info .header-main {
        display: flex;
        align-items: center;
        gap: 10px;
    }

        .header-info .header-main h3 {
            margin: 0;
            font-size: 1.2rem;
            color: #0b3d67;
            font-weight: 700;
        }

    .header-info .header-details {
        display: flex;
        flex-wrap: wrap;
        gap: 14px;
        font-size: 0.9rem;
    }

    .header-info .detail-item {
        display: flex;
        align-items: center;
        gap: 5px;
    }

        .header-info .detail-item span {
            color: #6b7a90;
            font-weight: 600;
        }

        .header-info .detail-item strong {
            color: #0b3d67;
            font-weight: 700;
        }

/* ═══════════════════════════════════════════════════════════════
   کانتینر جدول — بدون اسکرول افقی
   ═══════════════════════════════════════════════════════════════ */
.table-container {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: white;
    margin-bottom: 15px;
    max-height: 75vh;
}

/* ═══════════════════════════════════════════════════════════════
   جدول اصلی — فونت بزرگ‌تر
   ═══════════════════════════════════════════════════════════════ */
.program-table {
    width: 100%;
    max-width: 100%;
    table-layout: fixed;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12px;
}

    /* ─── سرستون‌ها ─── */
    .program-table thead {
        position: sticky;
        top: 0;
        z-index: 100;
        background: white;
    }

        .program-table thead th {
            background: linear-gradient(to bottom, #f8fafc, #eef2f7);
            color: var(--dark);
            font-weight: 600;
            padding: 6px 3px;
            border: 1px solid var(--border);
            border-bottom: 2px solid var(--primary);
            font-size: 11px;
            text-align: center;
            white-space: nowrap;
            position: sticky;
            top: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            box-sizing: border-box;
        }

    /* ─── سلول‌ها ─── */
    .program-table tbody td {
        padding: 5px 3px;
        border: 1px solid var(--border);
        text-align: center;
        vertical-align: middle;
        white-space: nowrap;
        height: 42px;
        background-color: white;
        overflow: hidden;
        text-overflow: ellipsis;
        box-sizing: border-box;
        font-size: 12px;
    }

    .program-table tbody tr:nth-child(even) td {
        background-color: #fcfdfe;
    }

/* ═══════════════════════════════════════════════════════════════
   رنگ ستون روزها
   ═══════════════════════════════════════════════════════════════ */
.first-half-col {
    background-color: #f0f9ff !important;
    border-left: 2px solid #64b5f6 !important;
}

.second-half-col {
    background-color: #f1f8e9 !important;
    border-left: 2px solid #81c784 !important;
}

.friday-col {
    background-color: #ffebee !important;
    border-left: 2px solid #ef9a9a !important;
    font-weight: 600;
}

.holiday-col {
    background-color: #fff8e1 !important;
    border-left: 2px solid #ffd54f !important;
    font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════════
   ✅ ستون‌های ثابت — عرض بزرگ‌تر + فونت بزرگ‌تر
   ═══════════════════════════════════════════════════════════════ */

/* ─── ردیف — 34px ─── */
.program-table thead th.fixed-col,
.program-table td.fixed-col {
    right: 0;
    width: 34px !important;
    min-width: 34px !important;
    max-width: 34px !important;
    font-size: 11px;
}

/* ─── نام کاربر — 120px ─── */
.program-table thead th.fixed-col-2,
.program-table td.fixed-col-2 {
    right: 34px !important;
    width: 120px !important;
    min-width: 120px !important;
    max-width: 120px !important;
    font-size: 12px;
    text-align: right !important;
    padding-right: 6px !important;
    font-weight: 700;
}

/* ─── سمت — 52px ─── */
.program-table thead th.fixed-col-3,
.program-table td.fixed-col-3 {
    right: 154px !important;
    width: 52px !important;
    min-width: 52px !important;
    max-width: 52px !important;
    font-size: 11px;
}

/* ─── نوع شیفت — 46px ─── */
.program-table thead th.fixed-col-4,
.program-table td.fixed-col-4 {
    right: 206px !important;
    width: 46px !important;
    min-width: 46px !important;
    max-width: 46px !important;
    font-size: 11px;
}

/* ─── قرارداد — 52px ─── */
.program-table thead th.fixed-col-5,
.program-table td.fixed-col-5 {
    right: 252px !important;
    width: 52px !important;
    min-width: 52px !important;
    max-width: 52px !important;
    font-size: 11px;
}

/* ─── ستون‌های ثابت: sticky + z-index ─── */
.program-table thead th.fixed-col,
.program-table thead th.fixed-col-2,
.program-table thead th.fixed-col-3,
.program-table thead th.fixed-col-4,
.program-table thead th.fixed-col-5 {
    position: sticky;
    top: 0;
    background: linear-gradient(to bottom, #f8fafc, #eef2f7) !important;
    box-shadow: -2px 0 4px rgba(0, 0, 0, 0.06);
}

.program-table tbody td.fixed-col,
.program-table tbody td.fixed-col-2,
.program-table tbody td.fixed-col-3,
.program-table tbody td.fixed-col-4,
.program-table tbody td.fixed-col-5 {
    position: sticky !important;
    background-color: white !important;
    box-shadow: -2px 0 4px rgba(0, 0, 0, 0.06);
}

/* ─── z-index ─── */
.program-table thead th.fixed-col {
    z-index: 50;
}

.program-table thead th.fixed-col-2 {
    z-index: 49;
}

.program-table thead th.fixed-col-3 {
    z-index: 48;
}

.program-table thead th.fixed-col-4 {
    z-index: 47;
}

.program-table thead th.fixed-col-5 {
    z-index: 46;
}

.program-table td.fixed-col {
    z-index: 40;
}

.program-table td.fixed-col-2 {
    z-index: 39;
}

.program-table td.fixed-col-3 {
    z-index: 38;
}

.program-table td.fixed-col-4 {
    z-index: 37;
}

.program-table td.fixed-col-5 {
    z-index: 36;
}

/* ─── در حالت hide، ستون‌ها واقعاً حذف شوند ─── */
.program-table.hide-extra-cols .extra-col {
    display: none !important;
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    overflow: hidden !important;
    visibility: hidden !important;
}

.program-table.hide-extra-cols .fixed-col-2 {
    width: 200px !important;
    min-width: 200px !important;
    max-width: 200px !important;
    font-size: 13px;
}

/* ═══════════════════════════════════════════════════════════════
   Dropdown شیفت‌ها — فونت بزرگ‌تر
   ═══════════════════════════════════════════════════════════════ */
.shift-select {
    width: 100%;
    padding: 4px 5px;
    font-size: 11.5px;
    border: 1px solid #d1d9e0;
    border-radius: 4px;
    background-color: white;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    min-height: 30px;
    font-family: monospace;
    font-weight: 700;
    box-sizing: border-box;
}

    .shift-select:focus {
        outline: none;
        border-color: var(--primary);
        box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.15);
    }

.shift-value {
    display: none;
    font-size: 11.5px;
    font-weight: 700;
}

/* ═══════════════════════════════════════════════════════════════
   ردیف جمع — فونت بزرگ‌تر
   ═══════════════════════════════════════════════════════════════ */
.program-table tbody tr.totals-row td {
    padding: 4px 3px !important;
    line-height: 1.35 !important;
    height: auto !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    background-color: #eef2f7 !important;
    white-space: normal !important;
}

    .program-table tbody tr.totals-row td.fixed-col-2 {
        text-align: right !important;
        padding-right: 8px !important;
        color: #0b3d67;
        font-size: 12px !important;
    }

/* ═══════════════════════════════════════════════════════════════
   دکمه ذخیره
   ═══════════════════════════════════════════════════════════════ */
.save-btn {
    background: linear-gradient(to right, var(--success), #27ae60);
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(46, 204, 113, 0.25);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 20px auto;
}

    .save-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 18px rgba(46, 204, 113, 0.35);
    }

/* ═══════════════════════════════════════════════════════════════
   حالت Compact
   ═══════════════════════════════════════════════════════════════ */
.program-table.compact thead th {
    padding: 5px 2px !important;
    font-size: 10.5px !important;
}

.program-table.compact tbody td {
    padding: 4px 2px !important;
    font-size: 11px !important;
    height: 38px !important;
}

.program-table.compact .shift-select {
    padding: 3px 4px !important;
    font-size: 11px !important;
    min-height: 28px !important;
}

/* ═══════════════════════════════════════════════════════════════
   چاپ
   ═══════════════════════════════════════════════════════════════ */
@media print {
    @page {
        size: A4 landscape;
        margin: 0.5cm;
    }

    body {
        background-color: white !important;
        color: black !important;
        font-size: 9pt !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
    }

    .no-print,
    .save-btn,
    .color-guide,
    .shift-select {
        display: none !important;
    }

    .table-container {
        overflow: visible !important;
        border: none !important;
        max-height: none !important;
    }

    .program-table {
        width: 100% !important;
        font-size: 7.5pt !important;
        border-collapse: collapse !important;
    }

        .program-table thead {
            position: static !important;
        }

            .program-table thead th,
            .program-table tbody td {
                border: 1px solid #ddd !important;
                padding: 4px 3px !important;
                font-size: 7.5pt !important;
                position: static !important;
            }

    .shift-value {
        display: block !important;
    }
}

/* ═══════════════════════════════════════════════════════════════
   Responsive — فقط روی موبایل
   ═══════════════════════════════════════════════════════════════ */
@media screen and (max-width: 900px) {
    .table-container {
        overflow-x: auto !important;
    }

    .program-table {
        min-width: 900px;
    }
}
