/* ==========================================================================
   إدارة صفحات الأنظمة — pages-admin.css
   Everything here is namespaced under .pa-* / .rd-* so it can never collide
   with app.css (the theme editor). Colours and radii match app.css on purpose.
   ========================================================================== */

.pa-wrap {
    max-width: 1760px;
    margin: 0 auto;
    padding: 16px 16px 80px;
    color: #1b2733;
}

/* ---------- top bar: system picker ---------- */
.pa-bar {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    background: #fff; border-radius: 14px; padding: 12px 16px;
    box-shadow: 0 1px 5px rgba(0,0,0,.07); margin-bottom: 14px;
}
.pa-bar > label { font-weight: 800; color: #2b4c49; }
.pa-sel { flex: 1; max-width: 380px; }

.pa-chip {
    color: #fff; font-size: 12px; font-weight: 700;
    padding: 3px 10px; border-radius: 999px; margin-inline-start: auto;
}

/* ---------- shell: screen list | details ---------- */
.pa-shell {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
}
@media (max-width: 1100px) {
    .pa-shell { grid-template-columns: 1fr; }
}

/* ---------- screen list ---------- */
.pa-pages {
    background: #fff; border-radius: 14px; padding: 12px;
    box-shadow: 0 1px 5px rgba(0,0,0,.07);
    position: sticky; top: 14px;
    max-height: calc(100vh - 120px);
    display: flex; flex-direction: column; gap: 9px;
}
@media (max-width: 1100px) { .pa-pages { position: static; max-height: none; } }

.pa-pages-h { font-weight: 800; color: #2b4c49; }
.pa-pages-h em { font-style: normal; color: #8892a0; font-weight: 600; }
.pa-pages-a { display: flex; gap: 6px; }
.pa-pages-l { overflow-y: auto; display: flex; flex-direction: column; gap: 5px; }
.pa-pages-l::-webkit-scrollbar { width: 6px; }
.pa-pages-l::-webkit-scrollbar-thumb { background: #cfd8e0; border-radius: 4px; }

.pa-page {
    position: relative; cursor: pointer;
    padding: 8px 10px; border-radius: 10px;
    border: 1px solid #e6ebf0; background: #fbfcfe;
}
.pa-page:hover { background: #f2f6fa; }
.pa-page.on { background: #eaf4ff; border-color: #4AA3CA; }
.pa-page-n { font-weight: 700; font-size: 13.5px; }
.pa-page-m { font-size: 11.5px; color: #7b8794; margin-top: 2px; }
.pa-page-m code { font-family: Consolas, monospace; }

.pa-unlink {
    position: absolute; inset-inline-end: 6px; top: 6px;
    border: 0; background: transparent; cursor: pointer;
    color: #c0392b; font-size: 17px; line-height: 1; padding: 0 4px;
    opacity: 0; transition: opacity .12s;
}
.pa-page:hover .pa-unlink { opacity: 1; }

/* ---------- cards ---------- */
.pa-main { min-width: 0; display: flex; flex-direction: column; gap: 12px; }

.pa-card {
    background: #fff; border-radius: 14px; padding: 14px 16px;
    box-shadow: 0 1px 5px rgba(0,0,0,.07);
}
.pa-card-h {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    font-weight: 800; color: #2b4c49; margin-bottom: 12px;
}
.pa-spacer { flex: 1; }

/* ---------- forms ---------- */
.pa-form {
    display: grid; gap: 8px 12px; align-items: center;
    grid-template-columns: 120px minmax(0, 1fr);
}
.pa-form-3 { grid-template-columns: 110px minmax(0,1fr) 110px minmax(0,1fr) 110px minmax(0,1fr); }
@media (max-width: 1400px) { .pa-form-3 { grid-template-columns: 110px minmax(0,1fr) 110px minmax(0,1fr); } }
@media (max-width: 900px)  { .pa-form-3 { grid-template-columns: 110px minmax(0,1fr); } }

.pa-form > label { font-size: 13px; font-weight: 700; color: #47566a; }
.pa-l3 { grid-column: 1; }
.pa-in3 { grid-column: 2 / -1; }

.pa-in {
    width: 100%; padding: 7px 9px; border-radius: 9px;
    border: 1px solid #d6dde4; background: #fff;
    font-family: inherit; font-size: 13.5px; color: #1b2733;
}
.pa-in:focus { outline: 2px solid #4AA3CA; outline-offset: -1px; border-color: #4AA3CA; }
.pa-search { margin: 0; }

.pa-sub {
    margin: 14px 0 8px; font-weight: 800; color: #2b4c49; font-size: 13px;
    border-top: 1px solid #eef1f5; padding-top: 10px;
}

.pa-flags { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 10px; }
.pa-flag {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 13px; color: #47566a; cursor: pointer;
    padding: 4px 8px; border-radius: 8px; background: #f6f8fb;
}
.pa-flag input { accent-color: #4AA3CA; }

.pa-msg {
    margin-top: 10px; padding: 7px 11px; border-radius: 9px;
    background: #eaf7ef; color: #1e6b3f; font-size: 13px; font-weight: 600;
}

/* ---------- buttons ---------- */
.pa-btn {
    border: 1px solid #d6dde4; background: #fff; color: #33475b;
    padding: 6px 12px; border-radius: 9px; cursor: pointer;
    font-family: inherit; font-size: 13px; font-weight: 700;
}
.pa-btn:hover:not(:disabled) { background: #f2f6fa; }
.pa-btn:disabled { opacity: .45; cursor: default; }
.pa-btn-p { background: #2b4c49; border-color: #2b4c49; color: #fff; }
.pa-btn-p:hover:not(:disabled) { background: #37605c; }
.pa-btn-d { color: #c0392b; border-color: #f0cdc8; }
.pa-btn-d:hover:not(:disabled) { background: #fdf1ef; }
.pa-btn-xs { padding: 2px 7px; font-size: 12px; border-radius: 7px; }

/* ---------- tabs ---------- */
.pa-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.pa-tab {
    border: 1px solid #dbe2e9; background: #fff; color: #47566a;
    padding: 8px 16px; border-radius: 11px 11px 0 0; cursor: pointer;
    font-family: inherit; font-size: 13.5px; font-weight: 700;
    border-bottom-color: transparent;
}
.pa-tab:hover { background: #f2f6fa; }
.pa-tab.on { background: #2b4c49; border-color: #2b4c49; color: #fff; }
.pa-tabbody { border-radius: 0 14px 14px 14px; }

.pa-tabhead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.pa-tabhead-t { font-weight: 800; color: #2b4c49; }
.pa-tabhead-t b { font-family: Consolas, monospace; color: #4AA3CA; }
.pa-saving { font-size: 12px; color: #8892a0; }

/* ---------- grids ---------- */
.pa-grid { width: 100%; border-collapse: collapse; font-size: 13px; }
.pa-grid th {
    text-align: start; font-weight: 800; color: #47566a; font-size: 12.5px;
    padding: 8px 9px; border-bottom: 2px solid #eef1f5; white-space: nowrap;
}
.pa-grid td { padding: 6px 9px; border-bottom: 1px solid #f2f5f8; vertical-align: middle; }
.pa-grid tr:hover td { background: #fbfcfe; }
.pa-grid td code { font-family: Consolas, monospace; color: #2b4c49; }
.pa-grid .pa-btn { margin-inline-end: 4px; }
.pa-editing td { background: #eaf4ff !important; }
.pa-c { text-align: center; }
.pa-mut { color: #8892a0; }

.pa-empty { padding: 22px; text-align: center; color: #8892a0; font-size: 13.5px; }
.pa-empty-lg { padding: 60px 22px; background: #fff; border-radius: 14px; }

/* ---------- modal ---------- */
.pa-ovl {
    position: fixed; inset: 0; z-index: 900;
    background: rgba(16,24,32,.45);
    display: flex; align-items: flex-start; justify-content: center;
    padding: 60px 16px; overflow-y: auto;
}
.pa-modal {
    width: 100%; background: #fff; border-radius: 16px;
    box-shadow: 0 18px 50px rgba(0,0,0,.28); overflow: hidden;
}
.pa-modal-h {
    display: flex; align-items: center; gap: 10px;
    padding: 13px 18px; background: #2b4c49; color: #fff; font-weight: 800;
}
.pa-modal-h span { flex: 1; }
.pa-x { border: 0; background: transparent; color: #fff; font-size: 24px; line-height: 1; cursor: pointer; }
.pa-modal-b { padding: 16px 18px; max-height: 66vh; overflow-y: auto; }
.pa-modal-f {
    display: flex; gap: 8px; justify-content: flex-start;
    padding: 12px 18px; background: #f6f8fb; border-top: 1px solid #eef1f5;
}
.pa-pick-bar { display: flex; gap: 8px; margin-bottom: 12px; }

/* ==========================================================================
   Rule designer — drag & drop
   ========================================================================== */
.rd-hint { font-size: 12.5px; color: #8892a0; margin-bottom: 10px; }
.rd-board { display: flex; flex-direction: column; gap: 12px; }

.rd-group {
    border: 1px solid #e2e8ee; border-radius: 12px; overflow: hidden;
    background: #fbfcfe;
}
.rd-group.rd-nogroup { border-style: dashed; background: #fdfdfd; }

.rd-group-h {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 12px; background: #2b4c49; color: #fff;
}
.rd-nogroup .rd-group-h { background: #8892a0; }
.rd-group-t { flex: 1; font-weight: 800; font-size: 13.5px; }
.rd-group-t em { font-style: normal; opacity: .75; font-weight: 600; margin-inline-start: 5px; }
.rd-group-h .pa-btn { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.3); color: #fff; }
.rd-group-h .pa-btn:hover:not(:disabled) { background: rgba(255,255,255,.28); }
.rd-group-h .pa-btn-d { color: #ffd7d1; }

.rd-items { padding: 8px; display: flex; flex-direction: column; gap: 5px; min-height: 44px; }

.rd-drop {
    border: 2px dashed #cfd8e0; border-radius: 9px;
    padding: 14px; text-align: center; color: #a3adb8; font-size: 12.5px;
}

.rd-item {
    display: flex; align-items: center; gap: 9px;
    background: #fff; border: 1px solid #e2e8ee; border-radius: 9px;
    padding: 6px 9px; cursor: grab;
}
.rd-item:hover { border-color: #4AA3CA; box-shadow: 0 1px 6px rgba(74,163,202,.18); }
.rd-item:active { cursor: grabbing; }

.rd-grip { color: #c3ccd5; font-size: 13px; letter-spacing: -2px; }

.rd-name {
    border: 0; background: transparent; cursor: pointer; text-align: start;
    font-family: inherit; padding: 0; min-width: 210px;
}
.rd-name b { font-family: Consolas, monospace; font-size: 13px; color: #2b4c49; }
.rd-name em { display: block; font-style: normal; font-size: 11.5px; color: #8892a0; }
.rd-name:hover b { color: #4AA3CA; text-decoration: underline; }

.rd-badges { flex: 1; display: flex; flex-wrap: wrap; gap: 4px; }
.rd-b {
    font-style: normal; font-size: 10.5px; font-weight: 700;
    padding: 2px 7px; border-radius: 999px;
    background: #eef2f6; color: #5a6878;
}
.rd-b-req { background: #fdecea; color: #c0392b; }
.rd-b-v { background: #eaf4ff; color: #2b6f92; }
.rd-b-off { background: #f4f0e6; color: #8a7434; }

.rd-ord {
    font-size: 11.5px; color: #a3adb8; min-width: 22px; text-align: center;
    font-family: Consolas, monospace;
}

/* ---------- drag feedback (classes toggled by pages-admin.js) ---------- */
.rd-item.rd-dragging { opacity: .4; }
.rd-item.rd-over {
    border-color: #4AA3CA;
    box-shadow: inset 0 3px 0 -1px #4AA3CA, 0 1px 6px rgba(74,163,202,.25);
}
.rd-group.rd-over > .rd-items { background: #f0f8fd; border-radius: 8px; }
.rd-group.rd-over .rd-drop { border-color: #4AA3CA; color: #4AA3CA; }

/* ---------- group meta on the designer header ---------- */
.rd-meta {
    font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px;
    background: rgba(255,255,255,.22); color: #fff; white-space: nowrap;
}
.rd-meta-tab { background: rgba(0,0,0,.28); }

.rd-color { display: flex; gap: 8px; align-items: center; }
.rd-color-p {
    width: 42px; height: 34px; padding: 0; border: 1px solid #d6dde4;
    border-radius: 9px; background: #fff; cursor: pointer; flex-shrink: 0;
}

.pa-note {
    margin-top: 12px; font-size: 12.5px; color: #7b8794;
    background: #f6f8fb; border-radius: 9px; padding: 8px 11px;
}

/* designer / preview switch */
.pa-switch { display: inline-flex; gap: 0; }
.pa-switch .pa-btn { border-radius: 0; }
.pa-switch .pa-btn:first-child { border-radius: 0 9px 9px 0; }
.pa-switch .pa-btn:last-child { border-radius: 9px 0 0 9px; margin-inline-start: -1px; }
.pa-switch .pa-btn.on { background: #2b4c49; border-color: #2b4c49; color: #fff; }

/* ==========================================================================
   Form preview
   ========================================================================== */
.fp-note { font-size: 12.5px; color: #8892a0; margin-bottom: 12px; }
.fp { display: flex; flex-direction: column; gap: 14px; }

.fp-g { border: 1px solid #e2e8ee; border-radius: 12px; overflow: hidden; background: #fff; }
.fp-g-h { padding: 9px 14px; color: #fff; font-weight: 800; font-size: 13.5px; }
.fp-g-h-none { background: #8892a0; }
.fp-g-tab { border-radius: 0 0 12px 12px; border-top: 0; }

.fp-grid { display: grid; gap: 10px 14px; padding: 14px; }

.fp-f { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fp-l { font-size: 12.5px; font-weight: 700; color: #47566a; }
.fp-req { color: #c0392b; font-style: normal; margin-inline-start: 2px; }
.fp-c {
    width: 100%; padding: 8px 10px; border-radius: 9px;
    border: 1px solid #dfe5eb; background: #f4f7fa; color: #5a6878;
    font-family: inherit; font-size: 13px;
}
.fp-c-ro { background: #eceff3; border-style: dashed; }

.fp-tabs { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 4px; }
.fp-tab {
    border: 1px solid #dbe2e9; background: #fff; color: #47566a;
    padding: 8px 16px; border-radius: 11px 11px 0 0; cursor: pointer;
    font-family: inherit; font-size: 13px; font-weight: 700;
}
.fp-tab:hover { background: #f2f6fa; }
.fp-tab.on { color: #fff; }

/* ---------- solution-level view switch (screens / sub-tables) ---------- */
.pa-modes {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}
.pa-mode {
    padding: 10px 18px;
    border: 1px solid var(--pa-border, #d6dde4);
    border-radius: 10px;
    background: #fff;
    color: #55697b;
    font-size: 14px;
    font-weight: 800;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 7px;
}
.pa-mode:hover { border-color: #4AA3CA; color: #1f4257; }
.pa-mode em {
    font-style: normal;
    font-size: 11.5px;
    color: #90a0ad;
    font-weight: 700;
}
.pa-mode.on {
    background: #23414d;
    border-color: #23414d;
    color: #fff;
}
.pa-mode.on em { color: #b9cbd4; }

/* ---------- sub-table tools header ---------- */
.pa-main-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.pa-main-h h2 { margin: 0; font-size: 20px; font-weight: 800; color: #1f2d3a; }
.pa-code {
    display: inline-block; margin-top: 4px; font-size: 12px; font-weight: 700;
    color: #55697b; background: #eef2f6; border-radius: 7px; padding: 3px 10px;
}

/* --- traduction des groupes (GroupLabelTab) --- */
.pa-hint {
    margin: 2px 0 14px; font-size: 13px; font-weight: 600;
    color: #55697b; line-height: 1.7;
}
.pa-ok { margin-inline-start: 8px; color: #1a9c5b; font-weight: 800; }
