/* ==========================================================================
   واکنش‌گرایی (Responsive) کل سامانه — بعد از style-responsive.css لود می‌شود
   فقط روی تبلت و گوشی اثر دارد؛ نمای دسکتاپ تغییری نمی‌کند.
   ========================================================================== */

img, video { max-width: 100%; }
input, select, textarea, .w3-input { max-width: 100%; box-sizing: border-box; }

/* ---------- تبلت و کوچک‌تر (زیر 992px) ---------- */
@media (max-width: 991px) {
    /* کارتابل: ستون کناری (پروفایل و صندوق‌ها) بالای فهرست نامه‌ها */
    .mail-box, .mail-box aside { display: block !important; width: 100% !important; }
    .mail-box .sm-side { border-radius: 4px 4px 0 0; }
    .mail-box .lg-side { border-radius: 0 0 4px 4px; }
    .mail-box .sm-side .inbox-nav { display: flex; flex-wrap: wrap; margin: 0; }
    .mail-box .sm-side .inbox-nav li { flex: 1 1 50%; }
    .mail-box .sm-side .inbox-body { padding: 8px 15px; }
    .mail-box .sm-side .btn-compose { margin: 0; }
}

/* ---------- جدول‌ها: تبلت و گوشی (زیر 992px) ---------- */
@media (max-width: 991px) {
    /* جدول‌ها به شکل کارت (کلاس rtable را responsive-fix.js اضافه می‌کند) */
    table.rtable, table.rtable > tbody, table.rtable > tbody > tr, table.rtable > tbody > tr > td,
    table.rtable > thead { display: block; width: 100% !important; }
    table.rtable > thead, table.rtable tr.rhead { display: none !important; }
    table.rtable > tbody > tr {
        border: 1px solid #e1e4ea; border-radius: 6px; margin: 0 0 8px; padding: 6px 10px;
        background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.04);
    }
    table.rtable > tbody > tr.unread { background: #f5f8ff; border-right: 3px solid #1f6fb2; }
    table.rtable > tbody > tr > td {
        display: flex; gap: 6px; align-items: baseline; border: none !important;
        padding: 3px 0 !important; text-align: right !important; white-space: normal !important; height: auto !important;
    }
    table.rtable > tbody > tr > td[data-label]:not([data-label=""])::before {
        content: attr(data-label); flex: none; min-width: 78px; color: #8a8f99; font-size: 11px;
    }
    table.rtable > tbody > tr > td.r-empty { display: none !important; }
    table.rtable > tbody > tr > td.r-main { font-weight: bold; font-size: 13px; }
    table.rtable > tbody > tr > td.r-main::before { display: none; }
    table.rtable > tbody > tr > td.r-actions {
        flex-wrap: wrap; gap: 14px; font-size: 17px; margin-top: 4px; padding-top: 6px !important;
        border-top: 1px dashed #e5e5e5 !important;
    }
    table.rtable > tbody > tr > td.r-actions::before { display: none; }
    table.rtable img { max-width: 60px; height: auto; }

    /* جدول‌هایی که کارت نمی‌شوند: اسکرول افقی */
    .r-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }

}

/* ---------- گوشی (زیر 768px) ---------- */
@media (max-width: 767px) {
    body { overflow-x: hidden; }

    /* محتوای اصلی تمام‌عرض (عرض‌ها و حاشیه‌های ثابت داخل صفحه‌ها خنثی می‌شوند) */
    #main-content { margin-right: 0 !important; margin-left: 0 !important; }
    #main-content .wrapper {
        width: 100% !important; margin-right: 0 !important; margin-left: 0 !important;
        padding: 8px !important; box-sizing: border-box;
    }
    #main-content .row { margin-left: 0; margin-right: 0; }
    #main-content [class*="col-lg-"], #main-content [class*="col-md-"], #main-content [class*="col-sm-"] {
        float: none !important; width: 100% !important; padding-left: 4px; padding-right: 4px;
    }
    #main-content div[style*="float: left"], #main-content div[style*="float:left"] { float: none !important; text-align: right !important; }

    /* فیلدها و دکمه‌ها */
    #main-content input[type=text], #main-content input[type=password], #main-content input[type=email],
    #main-content input:not([type]), #main-content select, #main-content textarea { width: 100% !important; }
    #main-content input[type=checkbox], #main-content input[type=radio] { width: auto !important; }
    #main-content .btn { margin-bottom: 5px; white-space: normal; }
    #main-content .row.center, #main-content #actionBar { text-align: center; }

    /* نوار بالا */
    .header .logo { font-size: 17px; }
    .header .top-nav .username { display: none; }
    .header .top-menu > li > a { padding: 6px 8px !important; }

    /* سربرگ صندوق نامه‌ها و جستجو */
    .inbox-head { padding: 10px !important; height: auto !important; }
    .inbox-head h3 { font-size: 16px; }
    .inbox-head .mail-option, .inbox-head .position, .inbox-head .btn-group { width: 100% !important; float: none !important; }
    .inbox-head .input-append { display: flex; flex-wrap: wrap; gap: 4px; width: 100%; }
    .inbox-head .input-append .sr-input { flex: 1 1 40%; width: auto !important; min-width: 0; }
    .inbox-head .btn-compose { width: 100% !important; margin-top: 6px; }
    .inbox-body { padding: 8px !important; }

    /* صفحه‌بندی */
    .pagination > li > a, .pagination > li > span { padding: 5px 9px; }

    /* پنجره‌های مودال */
    .modal-content { width: 94% !important; }
    .modal-content textarea { width: 100% !important; }

    /* فرم نامه جدید/ویرایش */
    .nl-grid { grid-template-columns: minmax(0,1fr) !important; }
    .nl-field.span2 { grid-column: auto !important; }
    .nl-dropdown { left: 0 !important; }
    .span_item_file, .span_item_file_old { width: auto !important; max-width: 100%; float: none !important; display: inline-block; margin: 3px; }

    /* ورود */
    .container .form-group.center { width: 92% !important; max-width: 320px; }

    /* نمایش نامه */
    #main-content .wrapper h3 { font-size: 18px; }
}

/* ---------- منوی کناری در گوشی ---------- */
@media (max-width: 767px) {
    .nicescroll-rails { display: none !important; }            /* خط قرمز اسکرول منو در لبه صفحه */
    #sidebar { top: 60px; box-shadow: 0 6px 16px rgba(0,0,0,.25); max-height: calc(100vh - 60px); overflow-y: auto !important; }
    .sidebar-toggle-box { cursor: pointer; padding: 6px 4px; }
}
