/* ============================================================
   متجر بلس المركزي — تنسيق لوحة التحكم (نسخة كاملة v2)
   يشمل: الدخول، اللوحة، المشرفين، قسم Android
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: "Tajawal", "Segoe UI", Tahoma, sans-serif;
    background: #f4f6f9;
    color: #1f2937;
    line-height: 1.7;
}

a { color: #2563eb; text-decoration: none; }

/* ===== صفحة الدخول ===== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e3a8a, #2563eb);
}

.login-box {
    background: #fff;
    padding: 40px 34px;
    border-radius: 14px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}

.login-box h1 {
    font-size: 22px;
    text-align: center;
    color: #1e3a8a;
}

.login-sub {
    text-align: center;
    color: #6b7280;
    margin-bottom: 24px;
}

/* ===== نماذج ===== */
label {
    display: block;
    margin: 14px 0 6px;
    font-weight: 600;
    font-size: 14px;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="url"],
select,
textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid #d1d5db;
    border-radius: 9px;
    font-size: 15px;
    font-family: inherit;
    background: #fff;
    transition: border-color .15s;
}

input[type="file"] {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px dashed #d1d5db;
    border-radius: 9px;
    font-size: 14px;
    font-family: inherit;
    background: #fafafa;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #2563eb;
}

textarea { resize: vertical; }

.hint {
    font-size: 12.5px;
    color: #6b7280;
    margin-top: 5px;
}

/* ===== أزرار ===== */
.btn {
    display: inline-block;
    padding: 10px 22px;
    border: none;
    border-radius: 9px;
    font-size: 15px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .15s;
}

.btn:hover { opacity: .88; }

.btn-primary { background: #2563eb; color: #fff; }
.btn-danger  { background: #dc2626; color: #fff; }
.btn-outline {
    background: transparent;
    border: 1.5px solid #d1d5db;
    color: #374151;
}

.btn-sm    { padding: 6px 14px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 20px; }

/* ===== تنبيهات ===== */
.alert {
    padding: 12px 16px;
    border-radius: 9px;
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-error   { background: #fee2e2; color: #991b1b; }
.alert-success { background: #dcfce7; color: #166534; }

/* ===== الشريط العلوي ===== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    padding: 14px 28px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
}

.topbar-brand {
    font-size: 18px;
    font-weight: 700;
    color: #1e3a8a;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

/* ===== شريط التبويبات ===== */
.tabs {
    display: flex;
    gap: 4px;
    background: #fff;
    padding: 0 28px;
    border-bottom: 1px solid #e5e7eb;
    overflow-x: auto;
}

.tabs a {
    padding: 13px 18px;
    font-size: 14.5px;
    font-weight: 600;
    color: #4b5563;
    border-bottom: 2.5px solid transparent;
    white-space: nowrap;
}

.tabs a:hover { color: #1e3a8a; }

.tabs a.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
}

/* ===== المحتوى ===== */
.container {
    max-width: 1100px;
    margin: 30px auto;
    padding: 0 20px;
}

.container h2 { margin-bottom: 20px; }

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.page-head h2 { margin-bottom: 0; }

.count-badge {
    display: inline-block;
    background: #e0e7ff;
    color: #3730a3;
    font-size: 13px;
    font-weight: 700;
    padding: 2px 11px;
    border-radius: 999px;
    vertical-align: middle;
}

.muted { color: #6b7280; font-size: 14px; margin-top: 24px; }

.empty-state {
    background: #fff;
    border: 1.5px dashed #d1d5db;
    border-radius: 12px;
    padding: 40px 24px;
    text-align: center;
    color: #6b7280;
}

/* ===== بطاقات الإحصائيات ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px;
}

.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
}

.stat-number {
    font-size: 34px;
    font-weight: 700;
    color: #2563eb;
}

.stat-label {
    color: #6b7280;
    font-size: 14px;
    margin-top: 4px;
}

/* ===== جداول ===== */
table.data {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
}

table.data th, table.data td {
    padding: 12px 16px;
    text-align: right;
    border-bottom: 1px solid #f1f5f9;
    font-size: 14px;
    vertical-align: middle;
}

table.data th {
    background: #f8fafc;
    font-weight: 700;
    color: #374151;
}

table.data tr:last-child td { border-bottom: none; }

tr.row-hidden { background: #fafafa; opacity: .65; }

.actions-cell { white-space: nowrap; }

/* ===== شارات ===== */
.badge {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 700;
}

.badge-green  { background: #dcfce7; color: #166534; }
.badge-gray   { background: #f3f4f6; color: #4b5563; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-purple { background: #ede9fe; color: #5b21b6; }

/* ===== أيقونات التطبيقات ===== */
.app-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    object-fit: cover;
    display: inline-block;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
}

.app-icon-empty {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    font-weight: 700;
}

/* ===== النماذج الصفّية ===== */
.inline-form {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    margin: 2px 0;
    flex-wrap: wrap;
}

.inline-form input[type="password"],
.inline-form input[type="text"] {
    width: 160px;
    padding: 7px 10px;
    font-size: 13px;
}

.inline-form .input-xs {
    width: 70px;
    padding: 7px 8px;
    font-size: 13px;
}

.inline-form .input-file-sm {
    width: 170px;
    padding: 5px 8px;
    font-size: 12px;
}

/* ===== اللوحات ===== */
.panel {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    margin-top: 28px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
}

.panel h3 { margin-bottom: 16px; }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 4px;
}

/* ===== تبديل طريقة التوصيل ===== */
.delivery-toggle {
    display: flex;
    gap: 10px;
    margin-bottom: 6px;
}

.radio-pill {
    margin: 0;
    cursor: pointer;
}

.radio-pill input { display: none; }

.radio-pill span {
    display: inline-block;
    padding: 9px 20px;
    border: 1.5px solid #d1d5db;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    color: #4b5563;
    transition: all .15s;
}

.radio-pill input:checked + span {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

/* ===== معاينة الأيقونة ===== */
.icon-preview-wrap {
    display: flex;
    align-items: flex-end;
    padding-bottom: 4px;
}

.icon-preview {
    width: 76px;
    height: 76px;
    border-radius: 16px;
    object-fit: cover;
    border: 1.5px solid #e5e7eb;
    background: #f9fafb;
}

/* ===== النافذة المنبثقة (Modal) ===== */
body.modal-open { overflow: hidden; }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, .55);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px;
    z-index: 100;
    overflow-y: auto;
}

.modal {
    background: #fff;
    border-radius: 14px;
    width: 100%;
    max-width: 620px;
    padding: 26px 28px 28px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, .3);
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 30px;
    line-height: 1;
    color: #9ca3af;
    cursor: pointer;
}

.modal-close:hover { color: #374151; }

.modal-actions {
    display: flex;
    justify-content: flex-start;
    gap: 10px;
    margin-top: 22px;
}

/* ===== إصلاح: إخفاء النافذة المنبثقة افتراضياً ===== */
.modal-overlay[hidden] { display: none; }

/* ===== استجابة الجوال ===== */
@media (max-width: 640px) {
    .topbar { flex-direction: column; gap: 10px; }
    .actions-cell form,
    .actions-cell button { margin-bottom: 4px; }
}

/* ===== الصلاحيات ===== */
.perm-section {
    border-top: 1.5px solid #e5e7eb;
    margin-top: 22px;
    padding-top: 18px;
    margin-bottom: 22px;
}

.perm-section-head { margin-bottom: 14px; }

.perm-section-head h4 {
    font-size: 15.5px;
    color: #1e3a8a;
    margin-bottom: 2px;
}

.perm-group {
    background: #fbfcfe;
    border: 1.5px solid #e5e7eb;
    border-radius: 11px;
    padding: 14px 16px;
    margin-bottom: 12px;
}

.perm-group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.perm-group-title {
    font-weight: 700;
    font-size: 14.5px;
    color: #374151;
}

.btn-link {
    background: none;
    border: none;
    color: #2563eb;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 2px 4px;
}

.btn-link:hover { text-decoration: underline; }

.perm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
}

.perm-item {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0;
    padding: 9px 12px;
    background: #fff;
    border: 1.5px solid #e5e7eb;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}

.perm-item:hover { border-color: #bfdbfe; }

.perm-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #2563eb;
    cursor: pointer;
    flex-shrink: 0;
}

.perm-item:has(input:checked) {
    background: #eff6ff;
    border-color: #2563eb;
}

.perm-summary {
    font-size: 13px;
    color: #4b5563;
}

/* النافذة المنبثقة للصلاحيات */
#permModal .perm-group:last-of-type { margin-bottom: 0; }

/* ===== الحزم والتوثيق ===== */
.mono {
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-size: 13px;
    direction: ltr;
    unicode-bidi: embed;
}

.muted-inline {
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
}

.btn-icon {
    background: none;
    border: 1.5px solid #e5e7eb;
    border-radius: 7px;
    padding: 3px 8px;
    font-size: 13px;
    cursor: pointer;
    color: #4b5563;
    vertical-align: middle;
    transition: border-color .15s;
}

.btn-icon:hover { border-color: #2563eb; color: #2563eb; }

/* اختيار التطبيقات للحزمة */
.app-filter {
    margin-bottom: 14px;
    max-width: 340px;
}

.app-pick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 10px;
    margin-bottom: 18px;
    max-height: 340px;
    overflow-y: auto;
    padding: 4px;
}

.app-pick {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 10px 12px;
    background: #fff;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 500;
    transition: border-color .15s, background .15s;
}

.app-pick:hover { border-color: #bfdbfe; }

.app-pick:has(input:checked) {
    background: #eff6ff;
    border-color: #2563eb;
}

.app-pick input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #2563eb;
    flex-shrink: 0;
}

.pick-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    object-fit: cover;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.pick-icon-empty {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
}

.pick-name {
    font-size: 14px;
    line-height: 1.4;
}

.pick-name small {
    display: block;
    color: #6b7280;
    font-size: 12px;
}

/* التوثيق */
.doc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.doc-item { margin-bottom: 10px; }

.doc-item label {
    margin-top: 0;
    font-size: 13px;
    color: #6b7280;
}

.doc-value {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    background: #f8fafc;
    border: 1.5px solid #e5e7eb;
    border-radius: 9px;
    padding: 10px 14px;
}

.code-line {
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-size: 13px;
    direction: ltr;
    unicode-bidi: embed;
    word-break: break-all;
}

.code-block-wrap { position: relative; }

.code-copy {
    position: absolute;
    top: 10px;
    left: 10px;
}

.code-block {
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 11px;
    padding: 18px 20px;
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.7;
    direction: ltr;
    text-align: left;
    overflow-x: auto;
    white-space: pre;
}
