/* ============================================================
   Mediafi — تم برند رسمی (از mediafi.ir)
   سبز نفتی #083d41 + نارنجی کهربایی #f0a854
   چیدمان: داشبورد با سایدبار (RTL)
   ============================================================ */
@font-face {
    font-family: 'Vazirmatn';
    src: url('/brand/fonts/Vazirmatn-Regular.woff2') format('woff2');
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('/brand/fonts/Vazirmatn-Medium.woff2') format('woff2');
    font-weight: 500 600;
    font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('/brand/fonts/Vazirmatn-Bold.woff2') format('woff2');
    font-weight: 700 800;
    font-display: swap;
}

:root {
    --brand-teal: #083d41;
    --brand-teal-dark: #062d30;
    --brand-teal-700: #0d4f54;
    --brand-teal-600: #12656b;

    --brand-orange: #f0a854;
    --brand-orange-bright: #f4b062;
    --brand-orange-hover: #e2933d;
    --brand-orange-soft: #fdf1e2;

    --ink: #1f2b2b;
    --muted: #6b7778;
    --page-bg: #f4f7f7;
    --card-bg: #ffffff;
    --border: #e4ecec;

    --ok: #157347;
    --ok-bg: #d7f0e2;
    --warn-bg: #fff3cd;
    --warn-text: #8a6d1b;
    --danger: #b02a37;
    --danger-bg: #fbe1e3;

    --sidebar-w: 256px;

    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 6px 22px rgba(8, 61, 65, .09);
    --shadow-sm: 0 2px 10px rgba(8, 61, 65, .06);
    --font: 'IRANSansXFaNum', 'IRANSansX', 'Vazirmatn', 'IRANYekan', 'Segoe UI', Tahoma, sans-serif;
}

* { box-sizing: border-box; }

html { font-size: 14px; }
@media (min-width: 768px) { html { font-size: 15px; } }

body {
    margin: 0;
    font-family: var(--font);
    color: var(--ink);
    background: var(--page-bg);
    line-height: 1.75;
    direction: rtl;
}

a { color: var(--brand-teal-600); text-decoration: none; }
a:hover { color: var(--brand-orange-hover); }
h1, h2, h3, h4, h5 { font-weight: 700; color: var(--brand-teal); }

.btn:focus, .btn:active:focus, .form-control:focus, .form-select:focus, .form-check-input:focus {
    box-shadow: 0 0 0 .2rem rgba(240, 168, 84, .3);
    border-color: var(--brand-orange);
}

/* ============================================================
   App shell — سایدبار + محتوا
   ============================================================ */
.app-shell { min-height: 100vh; }

.sidebar {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--brand-teal);
    color: #fff;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    box-shadow: -2px 0 18px rgba(8, 44, 48, .18);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: 1.15rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, .1);
}
.sidebar-logo {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: #fff;
    padding: 4px;
    flex-shrink: 0;
}
.sidebar-brand .brand-name { font-weight: 800; font-size: 1.15rem; color: #fff; line-height: 1.2; }
.sidebar-brand .brand-sub { font-size: .72rem; color: rgba(255, 255, 255, .6); }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: .9rem .7rem;
    display: flex;
    flex-direction: column;
    gap: .2rem;
}
.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .7rem .85rem;
    border-radius: 10px;
    color: rgba(255, 255, 255, .78);
    font-weight: 600;
    font-size: .95rem;
    transition: all .15s ease;
    white-space: nowrap;
}
.sidebar-nav .nav-link svg { width: 20px; height: 20px; flex-shrink: 0; opacity: .85; }
.sidebar-nav .nav-link:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.sidebar-nav .nav-link.active {
    background: var(--brand-orange);
    color: #fff;
    box-shadow: 0 4px 12px rgba(240, 168, 84, .35);
}
.sidebar-nav .nav-link.active svg { opacity: 1; }

.sidebar-footer {
    padding: .9rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, .1);
}
.sidebar-user {
    display: flex; align-items: center; gap: .5rem;
    color: var(--brand-orange-bright);
    font-weight: 700; font-size: .9rem;
    margin-bottom: .6rem;
}
.sidebar-footer .logout-btn {
    display: flex; align-items: center; justify-content: center; gap: .4rem;
    width: 100%;
    padding: .5rem;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 10px;
    color: rgba(255, 255, 255, .82);
    font-weight: 600;
}
.sidebar-footer .logout-btn:hover { background: rgba(255, 255, 255, .1); color: #fff; }

/* main */
.app-main {
    margin-right: var(--sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-right .2s ease;
}

/* ---- سایدبار جمع‌شونده (فقط آیکون) ---- */
.sidebar { transition: width .2s ease; }
.collapse-toggle {
    background: transparent; border: 1px solid var(--border); color: var(--brand-teal);
    width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.collapse-toggle:hover { background: var(--brand-orange-soft); }
@media (min-width: 992px) {
    .app-shell.collapsed .sidebar { width: 68px; }
    .app-shell.collapsed .app-main { margin-right: 68px; }
    .app-shell.collapsed .sidebar-nav .nav-link { font-size: 0; justify-content: center; padding: .7rem 0; gap: 0; }
    .app-shell.collapsed .sidebar-brand { justify-content: center; padding: 1.15rem 0; }
    .app-shell.collapsed .sidebar-brand > div { display: none; }
    .app-shell.collapsed .sidebar-footer { padding: .8rem .4rem; }
    .app-shell.collapsed .sidebar-user { font-size: 0; justify-content: center; }
    .app-shell.collapsed .logout-btn { font-size: 0; padding: .5rem 0; }
}

/* ---- ردیف دکمه‌های عملیات در جدول‌ها ---- */
.row-actions { display: inline-flex; gap: .35rem; flex-wrap: wrap; align-items: center; }
.row-actions .btn { border-radius: 8px; padding: .28rem .7rem; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.topbar {
    position: sticky; top: 0; z-index: 1030;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    padding: .85rem 1.6rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.topbar-title { font-weight: 800; color: var(--brand-teal); font-size: 1.1rem; }
.topbar-spacer { flex: 1; }
.sidebar-toggle {
    display: none;
    background: var(--brand-teal);
    color: #fff; border: none;
    width: 40px; height: 40px; border-radius: 10px;
    font-size: 1.2rem;
}
.content { flex: 1; padding: 1.6rem; }

.app-footer {
    padding: 1rem 1.6rem;
    color: var(--muted);
    font-size: .82rem;
    border-top: 1px solid var(--border);
    text-align: center;
}

/* بک‌درپ موبایل */
.sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(8, 44, 48, .5);
    z-index: 1035;
}

@media (max-width: 991px) {
    .sidebar { transform: translateX(100%); transition: transform .25s ease; }
    .sidebar.open { transform: translateX(0); }
    .app-main { margin-right: 0; }
    .sidebar-toggle { display: inline-flex; align-items: center; justify-content: center; }
    .sidebar-backdrop.show { display: block; }
}

/* ============================================================
   کامپوننت‌ها
   ============================================================ */
.brand-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.card-title-bar {
    display: flex; align-items: center; gap: .6rem;
    font-size: 1.1rem; font-weight: 700; color: var(--brand-teal);
    margin-bottom: 1.25rem; padding-bottom: .75rem;
    border-bottom: 2px solid var(--border);
}
.card-title-bar::before {
    content: ""; width: 6px; height: 22px; border-radius: 4px; background: var(--brand-orange);
}

.page-heading {
    display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
    font-weight: 800; margin: .25rem 0 1.5rem; color: var(--brand-teal);
}

/* buttons */
.btn-primary, .btn-brand {
    background: var(--brand-orange); border-color: var(--brand-orange); color: #fff;
    font-weight: 700; border-radius: var(--radius-sm); padding: .5rem 1.3rem;
    box-shadow: 0 3px 10px rgba(240, 168, 84, .3);
}
.btn-primary:hover, .btn-brand:hover, .btn-primary:focus, .btn-brand:focus {
    background: var(--brand-orange-hover); border-color: var(--brand-orange-hover); color: #fff;
}
.btn-teal {
    background: var(--brand-teal); border-color: var(--brand-teal); color: #fff;
    font-weight: 700; border-radius: var(--radius-sm);
}
.btn-teal:hover { background: var(--brand-teal-700); color: #fff; }
.btn-outline-brand {
    color: var(--brand-teal); border: 1px solid var(--border); background: #fff;
    border-radius: var(--radius-sm); font-weight: 600;
}
.btn-outline-brand:hover { background: var(--brand-orange-soft); color: var(--brand-teal); }
.btn-secondary { border-radius: var(--radius-sm); }
.btn-warning { border-radius: var(--radius-sm); }

/* tables */
.brand-table {
    width: 100%; background: #fff; border-collapse: separate; border-spacing: 0;
    overflow: hidden; border-radius: var(--radius-sm);
}
.brand-table thead th {
    background: var(--brand-teal); color: #fff; font-weight: 700; font-size: .85rem;
    white-space: nowrap; padding: .8rem .7rem; border: none;
}
.brand-table tbody td { padding: .7rem; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: .9rem; }
.brand-table tbody tr:hover td { background: #f8fbfa; }
.brand-table tbody tr:last-child td { border-bottom: none; }

.table > :not(caption) > * > * { background-color: transparent; }
.table thead th { color: var(--brand-teal); border-bottom: 2px solid var(--border); }

/* badges */
.badge-soft { font-size: .78rem; padding: .3rem .7rem; border-radius: 20px; font-weight: 700; display: inline-block; }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-open { background: var(--warn-bg); color: var(--warn-text); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }

/* forms */
.form-label, label { font-weight: 600; color: var(--ink); margin-bottom: .3rem; }
.form-control, .form-select { border-radius: var(--radius-sm); border: 1px solid var(--border); padding: .5rem .8rem; }
.form-control:hover, .form-select:hover { border-color: #cdd8d6; }

/* stat tiles */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-tile {
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); padding: 1.15rem 1.3rem; position: relative; overflow: hidden;
}
.stat-tile::after { content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 5px; background: var(--brand-orange); }
.stat-tile .stat-ico {
    width: 42px; height: 42px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
    background: var(--brand-orange-soft); color: var(--brand-orange-hover); margin-bottom: .7rem;
}
.stat-tile .stat-ico svg { width: 22px; height: 22px; }
.stat-label { font-size: .85rem; color: var(--muted); margin-bottom: .35rem; }
.stat-value { font-size: 1.5rem; font-weight: 800; color: var(--brand-teal); }
.stat-value small { font-size: .8rem; color: var(--muted); font-weight: 600; }
.stat-tile.teal::after { background: var(--brand-teal); }
.stat-tile.teal .stat-ico { background: #e6f0f0; color: var(--brand-teal); }
.stat-tile.ok::after { background: var(--ok); }
.stat-tile.ok .stat-ico { background: var(--ok-bg); color: var(--ok); }
.stat-tile.danger::after { background: var(--danger); }
.stat-tile.danger .stat-ico { background: var(--danger-bg); color: var(--danger); }

/* auth pages */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; background: var(--page-bg); }
.auth-card { width: 100%; max-width: 430px; background: #fff; border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; border: 1px solid var(--border); }
.auth-head { background: var(--brand-teal); color: #fff; padding: 2rem 2rem 1.6rem; text-align: center; }
.auth-head .auth-logo { width: 60px; height: 60px; border-radius: 16px; background: #fff; padding: 6px; margin-bottom: .7rem; }
.brand-logo { width: 54px; height: 54px; border-radius: 50%; background: var(--brand-orange); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 900; font-size: 1.4rem; }
.auth-head h3 { color: #fff; margin: 0; }
.auth-head p { color: rgba(255,255,255,.7); margin: .3rem 0 0; font-size: .9rem; }
.auth-body { padding: 1.8rem 2rem 2rem; }

/* steps / contract (onboarding) */
.steps { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.step { flex: 1 1 140px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .8rem 1rem; display: flex; align-items: center; gap: .6rem; font-weight: 600; color: var(--muted); }
.step .num { width: 28px; height: 28px; border-radius: 50%; background: var(--brand-teal); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: .85rem; font-weight: 800; flex-shrink: 0; }
.contract-box { max-height: 240px; overflow-y: auto; background: #fafcfb; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem 1.2rem; font-size: .9rem; line-height: 2; color: #374151; }

/* misc */
.form-check { margin-bottom: .5rem; }
.form-check-label { margin-right: .5rem; cursor: pointer; }
.margin-left-10 { margin-left: .5rem; }
.action-buttons { display: flex; gap: .5rem; flex-wrap: wrap; }

.select2-container { width: 100% !important; }
.select2-container--default .select2-selection--single {
    height: 42px !important; border: 1px solid var(--border) !important; border-radius: var(--radius-sm) !important;
    display: flex !important; align-items: center !important;
}
.select2-container--default .select2-selection--single .select2-selection__rendered { line-height: normal !important; padding-right: .75rem !important; padding-left: 2rem !important; }
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 40px !important; left: .5rem !important; right: auto !important; }

/* ============================================================
   بهبود موبایل (برای نمایش داخل اپ روی گوشی)
   ============================================================ */
/* گاردِ سرریز افقیِ کلِ صفحه */
html, body { max-width: 100%; overflow-x: hidden; }

@media (max-width: 991px) {
    /* فاصلهٔ کمتر تا فضای صفحه هدر نرود */
    .content { padding: 1rem .75rem; }
    .topbar { padding-inline: .75rem; }
    .brand-card { padding: 1rem; }

    /* جدول‌های پهن به‌صورت افقی اسکرول شوند (در JSِ Layout داخل .table-responsive پیچیده می‌شوند) */
    .table-responsive { -webkit-overflow-scrolling: touch; width: 100%; overflow-x: auto; }
    .table-responsive > table, .table-responsive > .brand-table { white-space: nowrap; }

    /* ورودی‌ها و المان‌های پهن، تمام‌عرض و بدون سرریز */
    input, select, textarea, .form-control, .form-select,
    .select2-container, .jdp-container { max-width: 100%; }

    /* ستون‌های گرید که با استایلِ ثابت نریزند */
    .row > [class*="col-"] { margin-bottom: .5rem; }

    /* عنوان‌ها کمی کوچک‌تر */
    .page-heading { font-size: 1.15rem; }
    .card-title-bar { font-size: 1rem; }

    /* دکمه‌های عملیات در عرض کم زیر هم */
    .action-buttons .btn { flex: 1 1 auto; }
}
