:root {
    --bg: #F1F5F9;
    --panel: #FFFFFF;
    --border: #DCE6EF;
    --ink: #16202B;
    --ink-soft: #55677A;
    --sidebar: #0B2A4C;
    --sidebar-ink: #DCE7F2;
    --sidebar-ink-dim: #82A0BD;
    --brand: #0E6FB8;
    --brand-ink: #FFFFFF;
    --success-bg: #E7F3EC;
    --success-ink: #23623F;
    --danger-bg: #FBEAE5;
    --danger-ink: #A33B22;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.8;
}

a { text-decoration: none; color: inherit; }

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.app-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--sidebar);
    color: var(--sidebar-ink);
    padding: 28px 20px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 36px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    object-fit: contain;
}

.brand-title { font-weight: 700; font-size: 16px; }
.brand-sub { font-size: 12px; color: var(--sidebar-ink-dim); margin-top: 2px; }

.side-nav { display: flex; flex-direction: column; gap: 4px; }

.nav-link {
    padding: 11px 14px;
    border-radius: 8px;
    color: var(--sidebar-ink);
    font-size: 14px;
    transition: background .15s ease;
}
.nav-link:hover { background: rgba(255,255,255,.08); }

.sidebar-user {
    margin-top: auto;
    padding-top: 24px;
    border-top: 1px solid rgba(255,255,255,.1);
    position: fixed;
    bottom: 24px;
    width: 220px;
}
.sidebar-user-name { font-size: 13px; color: var(--sidebar-ink); margin-bottom: 8px; }
.sidebar-logout {
    background: transparent;
    border: 1px solid rgba(255,255,255,.18);
    color: var(--sidebar-ink-dim);
    font-family: inherit;
    font-size: 12.5px;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
}
.sidebar-logout:hover { color: #fff; border-color: rgba(255,255,255,.4); }

/* ---------- Main ---------- */
.app-main {
    flex: 1;
    padding: 36px 44px;
    max-width: 1180px;
}

h1, h2, h3 { font-weight: 700; margin: 0 0 6px; }
h1 { font-size: 24px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}

.page-desc { color: var(--ink-soft); font-size: 13.5px; margin: 0; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 13.5px;
    cursor: pointer;
    transition: opacity .15s ease;
}
.btn:hover { opacity: .88; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--ink); }
.btn-danger { background: var(--danger-bg); color: var(--danger-ink); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-ghost { background: transparent; color: var(--ink-soft); padding: 5px 8px; }

/* ---------- Cards / Tables ---------- */
.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 18px;
}

.form-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.form-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* کاور (لوگو یا تصویر پیش‌فرض) بالای کارت فرم، تمام‌عرض کارت */
.form-card { overflow: hidden; }
.form-card-cover {
    position: relative;
    height: 128px;
    margin: -18px -18px 4px;
    background: linear-gradient(135deg, #F3F7FA, #E4EEF6);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
}
.form-card-cover img {
    max-width: 100%;
    max-height: 100%;
    padding: 14px 18px;
    object-fit: contain;
}
.form-card-cover.is-default { background: #0B2A4C; }
.form-card-cover.is-default img {
    width: 100%;
    height: 100%;
    padding: 0;
    object-fit: cover;
}
.form-card-cover .cover-badge {
    position: absolute;
    top: 10px;
    inset-inline-start: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.form-card .title { font-weight: 700; font-size: 15.5px; }
.form-card .desc { color: var(--ink-soft); font-size: 13px; min-height: 20px; }

.badge {
    display: inline-block;
    font-size: 11.5px;
    padding: 3px 9px;
    border-radius: 20px;
    background: #E7EEF4;
    color: var(--ink-soft);
    width: fit-content;
}
.badge-active { background: var(--success-bg); color: var(--success-ink); }
.badge-inactive { background: var(--danger-bg); color: var(--danger-ink); }

.meta-row { display: flex; gap: 14px; font-size: 12.5px; color: var(--ink-soft); }

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
table.data-table th {
    text-align: right;
    padding: 10px 12px;
    background: #EFF4F8;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    color: var(--ink-soft);
    white-space: nowrap;
}
table.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table.data-table tr:hover td { background: #F4F8FB; }

/* ---------- Forms ---------- */
.field-group { margin-bottom: 18px; }
label.field-label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 6px; }
.required-mark { color: var(--danger-ink); margin-inline-start: 3px; }

input[type=text], input[type=number], input[type=date], input[type=email],
textarea, select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    background: #fff;
    color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(14,111,184,.15);
}

.help-text { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

.field-error-msg {
    font-size: 12.5px;
    color: var(--danger-ink);
    margin-top: 5px;
    min-height: 0;
}
input.input-invalid {
    border-color: var(--danger-ink);
    box-shadow: 0 0 0 3px rgba(179,59,34,.08);
}

.field-hint-box {
    background: #F3F7FA;
    border: 1px dashed var(--border);
    border-radius: 8px;
    padding: 14px;
}

/* ---------- Alerts ---------- */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13.5px;
    margin-bottom: 18px;
}
.alert-success { background: var(--success-bg); color: var(--success-ink); }
.alert-danger { background: var(--danger-bg); color: var(--danger-ink); }

/* ---------- Builder: field list ---------- */
.field-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 10px;
    background: #fff;
}
.page-group-heading {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--brand);
    margin: 18px 0 8px;
    padding-bottom: 6px;
    border-bottom: 1px dashed var(--border);
}
.page-group-heading:first-child { margin-top: 0; }

/* ---------- Multi-page wizard (Fill form) ---------- */
.page-indicator {
    text-align: center;
    font-size: 12.5px;
    color: var(--ink-soft);
    margin-bottom: 18px;
    font-weight: 600;
}
.page-section-title {
    font-size: 17px;
    margin-bottom: 18px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}
.page-nav-buttons {
    display: flex;
    gap: 10px;
    margin-top: 22px;
}
.page-nav-buttons .btn-prev-page { flex: 0 0 auto; }
.page-nav-buttons .btn-next-page { flex: 1; }

.field-list-item .field-main { display: flex; align-items: center; gap: 12px; }
.field-order {
    width: 26px; height: 26px;
    border-radius: 50%;
    background: #E7EEF4;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px;
    color: var(--ink-soft);
    flex-shrink: 0;
}
.field-type-tag {
    font-size: 11.5px;
    padding: 2px 8px;
    border-radius: 20px;
    background: #E9F2F7;
    color: #0E6FB8;
}
.field-actions { display: flex; gap: 6px; align-items: center; }

/* ---------- Public fill page ---------- */
.fill-wrapper {
    max-width: 640px;
    margin: 40px auto;
}
.fill-header { text-align: center; margin-bottom: 30px; }
.fill-header h1 { margin-bottom: 8px; }
.fill-header p { color: var(--ink-soft); }

/* ---------- Form logo (responsive) ---------- */
.form-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 18px;
}
.form-logo img {
    /* ارتفاع بر اساس اندازه‌ی صفحه تنظیم می‌شود: روی موبایل کوچک‌تر، روی دسکتاپ بزرگ‌تر،
       ولی هیچ‌وقت از عرض کادر فرم بیرون نمی‌زند و نسبت تصویر هم حفظ می‌شود */
    height: clamp(56px, 14vw, 104px);
    width: auto;
    max-width: 100%;
    object-fit: contain;
}

/* لوگوی فعلی در صفحه‌ی ویرایش فرم */
.logo-current {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #F3F7FA;
    margin-bottom: 10px;
}
.logo-current img {
    height: 52px;
    width: auto;
    max-width: 160px;
    object-fit: contain;
}
.logo-remove {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--ink-soft);
}

.radio-group, .checkbox-group { display: flex; flex-direction: column; gap: 8px; }
.radio-option, .checkbox-option {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
}

/* ---------- Jalali date widget ---------- */
.jalali-date-widget {
    display: flex;
    gap: 8px;
}
.jalali-date-widget select {
    padding: 9px 10px;
}
.jalali-date-widget .jalali-day { flex: 0 0 76px; }
.jalali-date-widget .jalali-month { flex: 1 1 auto; }
.jalali-date-widget .jalali-year { flex: 0 0 92px; }

/* ---------- Iranian license plate widget ---------- */
.plate-widget {
    display: inline-flex;
    align-items: stretch;
    border: 3px solid var(--ink);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    width: fit-content;
    direction: rtl;
}
.plate-widget .plate-part,
.plate-widget .plate-letter {
    border: none;
    text-align: center;
    font-size: 20px;
    font-weight: 700;
    padding: 8px 4px;
    background: #fff;
    border-radius: 0;
}
.plate-widget .plate-p1 { width: 56px; }
.plate-widget .plate-p3 { width: 74px; }
.plate-widget .plate-letter { width: 68px; font-size: 15px; font-weight: 600; }
.plate-widget .plate-divider { width: 1px; background: var(--border); }
.plate-widget .plate-part:focus, .plate-widget .plate-letter:focus {
    outline: none;
    box-shadow: none;
    background: #F3F7FA;
}
.plate-region-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: #1B4B8F;
    color: #fff;
    padding: 4px 8px;
    flex-shrink: 0;
}
.plate-iran-label { font-size: 10.5px; font-weight: 700; }
.plate-region-box .plate-region {
    width: 38px;
    background: transparent;
    color: #fff;
    font-size: 15px;
    padding: 0;
}

.thankyou-box {
    max-width: 480px;
    margin: 80px auto;
    text-align: center;
}
.thankyou-icon {
    width: 64px; height: 64px;
    border-radius: 50%;
    background: var(--success-bg);
    color: var(--success-ink);
    display: flex; align-items: center; justify-content: center;
    font-size: 30px;
    margin: 0 auto 18px;
}

/* ---------- Captcha ---------- */
.captcha-box {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.captcha-image {
    line-height: 0;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.captcha-image svg { display: block; }

/* ---------- Star rating ---------- */
.rating-container {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.rating-widget {
    direction: ltr;
    position: relative;
    display: inline-block;
    font-size: 30px;
    line-height: 1;
    letter-spacing: 6px;
    cursor: pointer;
    user-select: none;
}
.rating-stars-bg { color: #DDE6EE; }
.rating-stars-fg {
    position: absolute;
    inset: 0;
    width: 0%;
    overflow: hidden;
    white-space: nowrap;
    color: var(--brand);
    transition: width .08s ease;
}
.rating-value-label {
    font-size: 13px;
    color: var(--ink-soft);
    min-width: 60px;
}
.rating-clear {
    font-size: 12px;
}

/* ---------- Report filters ---------- */
.filter-bar {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.filter-bar .field-group { margin-bottom: 0; min-width: 160px; }

/* ---------- Pagination ---------- */
.pagesize-box { margin-bottom: 12px; }
.pagesize-form {
    display: flex;
    align-items: center;
    gap: 8px;
}
.pagesize-label { font-size: 13px; color: var(--ink-soft); }
.pagesize-select {
    width: auto;
    min-width: 72px;
    padding: 6px 10px;
    font-size: 13.5px;
}

.pager-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 16px;
}
.pager-info { font-size: 13px; color: var(--ink-soft); }
.pager-links { display: flex; gap: 4px; flex-wrap: wrap; }
.pager-link {
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: var(--panel);
    font-size: 13.5px;
    color: var(--ink);
    transition: background .15s ease;
}
.pager-link:hover { background: #EFF4F8; }
.pager-current {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
    font-weight: 700;
}
.pager-current:hover { background: var(--brand); }

/* ---------- Long text modal ---------- */
.btn-link-view {
    display: inline-block;
    margin-top: 3px;
    font-size: 12px;
    color: var(--brand);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    text-decoration: underline;
}
.text-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20, 20, 18, .45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.text-modal-overlay.open { display: flex; }
.text-modal-box {
    background: var(--panel);
    border-radius: 12px;
    max-width: 560px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.text-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    font-size: 15px;
}
.text-modal-close {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: var(--ink-soft);
    line-height: 1;
}
.text-modal-body {
    padding: 20px;
    overflow-y: auto;
    white-space: pre-wrap;
    line-height: 2;
    font-size: 14px;
}

/* ---------- Mobile off-canvas sidebar ---------- */
.mobile-topbar {
    display: none;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: var(--sidebar);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 150;
}
.hamburger-btn {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
}
.hamburger-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
}
.mobile-topbar-brand { font-weight: 700; font-size: 15px; }
.mobile-topbar-logo {
    width: 30px;
    height: 30px;
    object-fit: contain;
    flex-shrink: 0;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 8, .5);
    z-index: 190;
    opacity: 0;
    transition: opacity .2s ease;
}
.sidebar-overlay.open { display: block; opacity: 1; }

.sidebar-close-btn { display: none; }

@media (max-width: 900px) {
    .mobile-topbar { display: flex; }

    .app-shell { flex-direction: column; }

    .app-sidebar {
        position: fixed;
        top: 0;
        right: 0;
        height: 100vh;
        width: 82%;
        max-width: 300px;
        transform: translateX(100%);
        transition: transform .25s ease;
        z-index: 200;
        overflow-y: auto;
        box-shadow: -10px 0 30px rgba(0, 0, 0, .28);
    }
    .app-sidebar.open { transform: translateX(0); }

    .sidebar-close-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 30px;
        height: 30px;
        margin-bottom: 14px;
        margin-inline-start: auto;
        background: rgba(255, 255, 255, .08);
        border: none;
        border-radius: 7px;
        color: var(--sidebar-ink);
        cursor: pointer;
        font-size: 14px;
    }

    .sidebar-user {
        position: static;
        width: auto;
        margin-top: 26px;
    }

    .app-main { padding: 20px 16px; }
}
