/* ============================================================
   أرشيف مؤسسة إعداد الدعاة — UI (مطابق لتصميم نظام الرواتب)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800;900&display=swap');

/* ─── CSS Variables ───────────────────────────────────────────*/
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #e0e7ff;
    --secondary: #8b5cf6;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #06b6d4;
    --info-light: #cffafe;

    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e2e8f0;
    --border-light: #f1f5f9;

    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    --sidebar-bg: #0f172a;
    --sidebar-w: 275px;
    --navbar-h: 64px;

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Reset & Base ────────────────────────────────────────────*/
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Cairo', 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    padding-top: var(--navbar-h);
    min-height: 100vh;
    font-size: 14.5px;
    line-height: 1.6;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Navbar ──────────────────────────────────────────────────*/
.app-navbar {
    height: var(--navbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: fixed;
    top: 0; right: 0; left: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
}

.navbar-toggler-custom {
    width: 40px; height: 40px;
    border: none;
    background: var(--bg);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.2rem;
    transition: all var(--transition);
    flex-shrink: 0;
}
.navbar-toggler-custom:hover { background: var(--primary-light); color: var(--primary); }

.navbar-brand-custom {
    flex: 1; text-align: center;
    font-weight: 800; font-size: 1.05rem;
    color: var(--text-primary);
}

.navbar-user { display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0; }

.user-avatar {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 0.9rem;
}

.user-name {
    font-size: 0.85rem; font-weight: 600; color: var(--text-primary);
    display: none; align-items: center; gap: .4rem;
}
.user-role-chip {
    font-size: .68rem; font-weight: 700;
    background: var(--primary-light); color: var(--primary-dark);
    padding: .1rem .5rem; border-radius: 999px;
}
@media (min-width: 768px) { .user-name { display: flex; } }

.btn-logout {
    width: 36px; height: 36px;
    border: none;
    background: var(--danger-light);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    color: var(--danger); cursor: pointer;
    transition: all var(--transition);
    text-decoration: none; font-size: 1rem;
}
.btn-logout:hover { background: var(--danger); color: #fff; transform: scale(1.05); }

/* ─── Sidebar ─────────────────────────────────────────────────*/
.app-sidebar {
    width: var(--sidebar-w) !important;
    background: var(--sidebar-bg) !important;
    border: none !important;
}
.sidebar-header {
    padding: 1.1rem 1.4rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex; align-items: center; gap: 0.75rem;
}
.sidebar-logo {
    width: 38px; height: 38px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 1.1rem; flex-shrink: 0;
}
.sidebar-title { font-size: 0.95rem; font-weight: 700; color: #fff; line-height: 1.3; }
.sidebar-subtitle { font-size: 0.72rem; color: rgba(255, 255, 255, 0.3); }

.sidebar-body {
    padding: 0.75rem 0; overflow-y: auto;
    height: calc(100% - 72px);
    display: flex; flex-direction: column;
}
.sidebar-section {
    padding: 0.9rem 1.25rem 0.3rem;
    font-size: 0.67rem; font-weight: 700;
    letter-spacing: 0.1em; text-transform: uppercase;
    color: rgba(255, 255, 255, 0.22);
}
.sidebar-link {
    display: flex; align-items: center; gap: 0.65rem;
    padding: 0.6rem 0.75rem;
    color: rgba(255, 255, 255, 0.55);
    text-decoration: none; font-size: 0.875rem; font-weight: 500;
    transition: all var(--transition);
    margin: 1px 0.6rem;
    border-radius: var(--radius-sm);
    position: relative; border: none; background: transparent;
    width: calc(100% - 1.2rem); text-align: right; cursor: pointer;
}
.sidebar-link .link-icon {
    width: 30px; height: 30px; border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.9rem; flex-shrink: 0;
    background: rgba(255, 255, 255, 0.06);
    transition: all var(--transition);
}
.sidebar-link-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-link:hover { color: #fff; background: rgba(255, 255, 255, 0.07); }
.sidebar-link:hover .link-icon { background: rgba(255, 255, 255, 0.12); }
.sidebar-link.active { color: #fff; background: rgba(99, 102, 241, 0.18); }
.sidebar-link.active .link-icon { background: var(--primary) !important; color: #fff !important; box-shadow: 0 4px 12px rgba(99, 102, 241, 0.45); }
.sidebar-link.active::after {
    content: ''; position: absolute; right: 0; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 55%;
    background: var(--primary);
    border-radius: 999px 0 0 999px;
}
.sidebar-divider { height: 1px; background: rgba(255, 255, 255, 0.05); margin: 0.4rem 1.2rem; }
.sidebar-empty-hint {
    margin: .3rem 1rem; padding: .7rem .85rem;
    font-size: .74rem; line-height: 1.5;
    color: rgba(255,255,255,.4);
    background: rgba(255,255,255,.04);
    border-radius: var(--radius-sm);
    display: flex; gap: .5rem; align-items: flex-start;
}
.sidebar-empty-hint i { margin-top: .15rem; }
.sidebar-link.link-danger { color: rgba(248, 113, 113, 0.65); }
.sidebar-link.link-danger .link-icon { background: rgba(239, 68, 68, 0.1); color: #f87171; }
.sidebar-link.link-danger:hover { color: #fff; background: rgba(239, 68, 68, 0.15); }
.sidebar-link.link-danger:hover .link-icon { background: var(--danger); color: #fff; }

/* ─── Main ────────────────────────────────────────────────────*/
main { padding: 1.5rem 1.25rem !important; min-height: calc(100vh - var(--navbar-h)); }

/* ─── Page Hero ───────────────────────────────────────────────*/
.page-hero {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border-radius: var(--radius-lg);
    padding: 20px 26px; margin-bottom: 20px;
    display: flex; align-items: center; gap: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, .15);
    position: relative; overflow: hidden;
}
.page-hero::before {
    content: ''; position: absolute; inset: 0; opacity: .06;
    background: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-rule='evenodd'%3E%3Cpath d='M0 40L40 0H20L0 20M40 40V20L20 40'/%3E%3C/g%3E%3C/svg%3E");
}
.page-hero-ico {
    width: 52px; height: 52px; border-radius: 14px;
    background: rgba(255, 255, 255, .15);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; color: #fff; flex-shrink: 0; position: relative;
}
.page-hero-info { position: relative; min-width: 0; flex: 1; }
.page-hero-title { font-size: 1.15rem; font-weight: 800; color: #fff; margin: 0; }
.page-hero-sub { font-size: .78rem; color: rgba(255, 255, 255, .7); margin: 3px 0 0; }
.page-hero-actions { margin-inline-start: auto; position: relative; display: flex; gap: .5rem; flex-shrink: 0; flex-wrap: wrap; }

/* ─── Cards ───────────────────────────────────────────────────*/
.card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
    overflow: hidden;
}
.card:hover { box-shadow: var(--shadow); }
.card-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border-light);
    padding: 0.85rem 1.25rem;
    font-weight: 700; font-size: 0.9rem; color: var(--text-primary);
    display: flex; align-items: center; gap: 0.5rem;
}
.card-body { padding: 1.25rem; }

.data-card {
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}
.data-card-header {
    padding: 1rem 1.4rem;
    border-bottom: 1px solid var(--border-light);
    display: flex; align-items: center; justify-content: space-between;
    gap: .75rem; flex-wrap: wrap;
    background: var(--surface-2);
}
.data-card-title {
    font-size: .95rem; font-weight: 700; color: var(--text-primary);
    display: flex; align-items: center; gap: .5rem;
}
.count-pill {
    background: var(--primary-light); color: var(--primary-dark);
    font-size: .7rem; font-weight: 700;
    padding: .15rem .55rem; border-radius: 999px;
}

/* ─── Stat Cards ──────────────────────────────────────────────*/
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
@media (max-width: 992px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .stat-grid { grid-template-columns: 1fr 1fr; gap: .6rem; } }

.stat-box {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.25rem;
    box-shadow: var(--shadow-sm);
    display: flex; align-items: center; gap: 1rem;
    border: 1px solid var(--border);
    transition: box-shadow var(--transition), transform var(--transition);
}
.stat-box:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-box-icon {
    width: 46px; height: 46px; border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; flex-shrink: 0;
}
.stat-box-val { font-size: 1.5rem; font-weight: 800; line-height: 1; }
.stat-box-lbl { font-size: .75rem; color: var(--text-secondary); margin-top: .2rem; }

/* ─── Page Cards Grid (dashboard) ─────────────────────────────*/
.page-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.page-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    text-decoration: none; color: inherit;
    display: flex; flex-direction: column; gap: .85rem;
    transition: all var(--transition);
    position: relative; overflow: hidden;
}
.page-card::after {
    content: ''; position: absolute; top: -30px; left: -30px;
    width: 90px; height: 90px; border-radius: 50%;
    background: var(--pc-color, var(--primary)); opacity: .07;
    transition: transform var(--transition);
}
.page-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--pc-color, var(--primary)); }
.page-card:hover::after { transform: scale(1.4); }
.page-card-icon {
    width: 52px; height: 52px; border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; position: relative;
}
.page-card-name { font-size: 1rem; font-weight: 700; color: var(--text-primary); position: relative; }
.page-card-desc { font-size: .78rem; color: var(--text-muted); position: relative; flex: 1; }
.page-card-foot {
    display: flex; align-items: center; justify-content: space-between;
    font-size: .78rem; color: var(--text-secondary); position: relative;
    border-top: 1px solid var(--border-light); padding-top: .7rem;
}
.page-card-count { display: inline-flex; align-items: center; gap: .3rem; font-weight: 700; }

/* ─── Tables ──────────────────────────────────────────────────*/
.rec-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.rec-table thead th {
    background: var(--surface-2);
    font-weight: 700; font-size: 0.72rem;
    text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0.8rem 1rem; white-space: nowrap;
    text-align: right; vertical-align: middle;
    position: sticky; top: 0; z-index: 2;
}
.rec-table thead th.col-actions, .rec-table thead th.col-num { text-align: center; }
.rec-table tbody td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle; text-align: right;
    font-size: .85rem;
}
.rec-table tbody td.col-actions, .rec-table tbody td.col-num { text-align: center; }
.rec-table tbody tr { transition: background var(--transition); }
.rec-table tbody tr:hover { background: #f8faff; }
.rec-table tbody tr:last-child td { border-bottom: none; }

.table-scroll { overflow-x: auto; overflow-y: auto; max-height: 72vh; }
.table-scroll .rec-table { margin-bottom: 0; }

/* value renderers inside cells */
.val-empty { color: var(--text-muted); }
.val-link a { color: var(--primary); text-decoration: none; font-weight: 600; display: inline-flex; align-items: center; gap: .3rem; }
.val-link a:hover { text-decoration: underline; }
.val-longtext { max-width: 320px; display: inline-block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.val-copyable { display: inline-flex; align-items: center; gap: .35rem; }

.secret-cell { display: inline-flex; align-items: center; gap: .4rem; }
.secret-dots { font-family: 'Courier New', monospace; letter-spacing: 2px; color: var(--text-secondary); user-select: none; }
.secret-shown { font-family: 'Courier New', monospace; color: var(--text-primary); }

.mini-btn {
    width: 28px; height: 28px; flex-shrink: 0;
    border: none; border-radius: 6px;
    background: var(--surface-2); color: var(--text-secondary);
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: .78rem; transition: all var(--transition);
}
.mini-btn:hover { background: var(--primary-light); color: var(--primary); }
.mini-btn.copied { background: var(--success-light); color: var(--success); }

/* row action buttons */
.tbl-actions { display: inline-flex; gap: .4rem; }
.tbl-btn {
    width: 32px; height: 32px; border-radius: var(--radius-sm);
    border: none; display: flex; align-items: center; justify-content: center;
    font-size: .85rem; cursor: pointer; transition: all var(--transition);
}
.tbl-btn-edit { background: #eff6ff; color: #2563eb; }
.tbl-btn-edit:hover { background: #2563eb; color: #fff; box-shadow: 0 3px 8px rgba(37,99,235,.3); }
.tbl-btn-del { background: #fee2e2; color: #dc2626; }
.tbl-btn-del:hover { background: #dc2626; color: #fff; box-shadow: 0 3px 8px rgba(220,38,38,.3); }
.tbl-btn-move { background: var(--surface-2); color: var(--text-secondary); }
.tbl-btn-move:hover { background: var(--primary-light); color: var(--primary); }
.tbl-btn-move:disabled { opacity: .35; cursor: not-allowed; }

/* ─── Type badge ──────────────────────────────────────────────*/
.type-badge {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .25rem .65rem; border-radius: 999px;
    font-size: .72rem; font-weight: 700;
    background: var(--primary-light); color: var(--primary-dark);
}
.type-badge.enc { background: #fef3c7; color: #92400e; }

/* ─── Badges ──────────────────────────────────────────────────*/
.badge { font-size: 0.72rem; font-weight: 600; padding: 0.28em 0.65em; border-radius: 999px; }
.status-pill { display: inline-flex; align-items: center; gap: .3rem; padding: .28rem .75rem; border-radius: 999px; font-size: .73rem; font-weight: 700; white-space: nowrap; }
.status-pill.active { background: #d1fae5; color: #065f46; }
.status-pill.inactive { background: #fee2e2; color: #991b1b; }

/* ─── Buttons ─────────────────────────────────────────────────*/
.btn {
    font-family: 'Cairo', sans-serif;
    font-weight: 700;
    font-size: 0.875rem;
    line-height: 1.35;
    border-radius: 11px;
    padding: 0.56rem 1.2rem;
    transition: transform var(--transition), box-shadow var(--transition), filter var(--transition), background var(--transition), border-color var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    border: none;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    z-index: 0;
    -webkit-tap-highlight-color: transparent;
}
.btn i { font-size: 0.95em; }

/* ومضة ضوء عابرة (shine) على الأزرار الممتلئة */
.btn-primary::before,
.btn-success::before,
.btn-danger::before,
.btn-warning::before,
.btn-save::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -70%;
    width: 45%;
    z-index: -1;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.38), transparent);
    transform: skewX(-18deg);
    transition: left 0.62s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}
.btn-primary:hover::before,
.btn-success:hover::before,
.btn-danger:hover::before,
.btn-warning:hover::before,
.btn-save:hover::before { left: 135%; }

.btn:active { transform: translateY(0) scale(0.97); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px rgba(99, 102, 241, 0.5); }

.btn-primary {
    background: linear-gradient(135deg, #818cf8 0%, var(--primary) 55%, var(--primary-dark) 100%);
    color: #fff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 4px 12px rgba(99, 102, 241, 0.32);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 9px 22px rgba(99, 102, 241, 0.5);
    color: #fff;
}
.btn-success {
    background: linear-gradient(135deg, #34d399 0%, var(--success) 55%, #059669 100%);
    color: #fff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 4px 12px rgba(16, 185, 129, 0.32);
}
.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 9px 22px rgba(16, 185, 129, 0.5);
    color: #fff;
}
.btn-danger {
    background: linear-gradient(135deg, #f87171 0%, var(--danger) 55%, #dc2626 100%);
    color: #fff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 4px 12px rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 9px 22px rgba(239, 68, 68, 0.45);
    color: #fff;
}
.btn-warning {
    background: linear-gradient(135deg, #fbbf24 0%, var(--warning) 55%, #d97706 100%);
    color: #fff;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 4px 12px rgba(245, 158, 11, 0.32);
}
.btn-warning:hover {
    transform: translateY(-2px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 9px 22px rgba(245, 158, 11, 0.45);
    color: #fff;
}
.btn-light {
    background: var(--surface);
    color: var(--text-primary);
    border: 1.5px solid var(--border);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.btn-light:hover {
    background: var(--surface-2);
    border-color: var(--text-muted);
    transform: translateY(-1px);
    box-shadow: 0 5px 12px rgba(0, 0, 0, 0.08);
}
.btn-outline-primary { border: 1.5px solid var(--primary); color: var(--primary); background: transparent; }
.btn-outline-primary:hover { background: var(--primary-light); color: var(--primary-dark); transform: translateY(-1px); }
.btn-outline-secondary { border: 1.5px solid var(--border); color: var(--text-secondary); background: transparent; }
.btn-outline-secondary:hover { background: var(--bg); color: var(--text-primary); border-color: var(--text-muted); }
.btn-white {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.24);
}
.btn-white:hover { background: rgba(255, 255, 255, 0.28); color: #fff; transform: translateY(-1px); }
.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.8rem; border-radius: 9px; }
.btn-icon { width: 36px; height: 36px; padding: 0 !important; border-radius: 10px; justify-content: center; }

/* ─── Forms ───────────────────────────────────────────────────*/
.form-label { font-weight: 600; font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 0.35rem; }
.form-control, .form-select {
    font-family: 'Cairo', sans-serif; font-size: 0.875rem;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text-primary); background: var(--surface);
    transition: all var(--transition); padding: 0.52rem 0.85rem;
}
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.1); outline: none; }
.form-control::placeholder { color: var(--text-muted); }
.form-control-sm, .form-select-sm { padding: 0.32rem 0.7rem; font-size: 0.82rem; }
.input-group-text { background: var(--surface-2); border: 1.5px solid var(--border); color: var(--text-secondary); font-size: 0.875rem; }
.form-text { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.25rem; }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }

/* ─── Alerts ──────────────────────────────────────────────────*/
.alert { border: none; border-radius: var(--radius); font-size: 0.875rem; font-weight: 500; padding: 0.85rem 1.1rem; }
.alert-success { background: var(--success-light); color: #065f46; }
.alert-danger { background: var(--danger-light); color: #991b1b; }
.alert-warning { background: var(--warning-light); color: #92400e; }
.alert-info { background: var(--info-light); color: #0e7490; }

/* ─── Empty State ─────────────────────────────────────────────*/
.empty-state { text-align: center; padding: 3.5rem 2rem; color: var(--text-muted); }
.empty-state .empty-icon {
    width: 80px; height: 80px; background: var(--primary-light);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 2rem; margin: 0 auto 1.1rem; color: var(--primary);
}
.empty-state h5 { font-weight: 700; color: var(--text-primary); }

/* ─── Modal ───────────────────────────────────────────────────*/
.modal-content { border: none; border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-header-c { padding: 1.2rem 1.5rem; border: none; display: flex; align-items: center; justify-content: space-between; }
.modal-header-add { background: linear-gradient(135deg, #064e3b, #059669); }
.modal-header-edit { background: linear-gradient(135deg, #1e1b4b, #4338ca); }
.modal-header-del { background: linear-gradient(135deg, #7f1d1d, #dc2626); }
.modal-header-c .modal-title { color: #fff; font-weight: 800; font-size: 1rem; margin: 0; }
.modal-header-c .btn-close { filter: invert(1) brightness(2); opacity: .8; }
.modal-title { font-weight: 700; font-size: 1rem; }
.modal-footer { border-top: 1px solid var(--border-light); }
.del-warn-box {
    background: #fff7ed; border: 1.5px solid #fed7aa; border-radius: var(--radius);
    padding: 1rem 1.1rem; display: flex; gap: .75rem; align-items: flex-start;
}
.del-warn-box > i { color: #ea580c; font-size: 1.2rem; flex-shrink: 0; margin-top: .1rem; }

/* ─── Table Search Input ──────────────────────────────────────*/
.tbl-search-wrap { position: relative; flex-shrink: 0; width: 280px; max-width: 100%; }
.tbl-search-wrap .bi-search {
    position: absolute; inset-inline-start: 0.75rem; top: 50%;
    transform: translateY(-50%); color: var(--text-muted); pointer-events: none; font-size: 0.9rem;
}
.tbl-search-input {
    width: 100%; padding: 0.48rem 0.85rem; padding-inline-start: 2.2rem;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    font-family: 'Cairo', sans-serif; font-size: 0.875rem;
    color: var(--text-primary); background: var(--surface); transition: all var(--transition);
}
.tbl-search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }

/* ─── Icon & Color Pickers ────────────────────────────────────*/
.icon-picker { display: grid; grid-template-columns: repeat(8, 1fr); gap: .4rem; max-height: 180px; overflow-y: auto; padding: .25rem; }
.icon-opt { display: none; }
.icon-opt-label {
    aspect-ratio: 1; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; color: var(--text-secondary); cursor: pointer; transition: all var(--transition);
}
.icon-opt-label:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.icon-opt:checked + .icon-opt-label { border-color: var(--primary); background: var(--primary); color: #fff; box-shadow: 0 3px 8px rgba(99,102,241,.35); }

.color-picker { display: flex; flex-wrap: wrap; gap: .5rem; }
.color-opt { display: none; }
.color-opt-label {
    width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
    border: 3px solid transparent; transition: all var(--transition);
    display: block;
}
.color-opt:checked + .color-opt-label { border-color: var(--text-primary); transform: scale(1.12); box-shadow: 0 3px 8px rgba(0,0,0,.2); }

/* ─── Field-type selector cards ───────────────────────────────*/
.type-opts { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.type-opt { display: none; }
.type-opt-label {
    display: flex; align-items: center; gap: .5rem;
    padding: .6rem .75rem; border-radius: var(--radius-sm);
    border: 2px solid var(--border); cursor: pointer; transition: all var(--transition);
    font-size: .82rem; font-weight: 600; color: var(--text-secondary);
}
.type-opt-label:hover { border-color: var(--primary); background: var(--primary-light); }
.type-opt:checked + .type-opt-label { border-color: var(--primary); background: var(--primary-light); color: var(--primary-dark); }
.type-opt-label i { font-size: 1rem; }

/* ─── Assignment checkboxes list ──────────────────────────────*/
.assign-list { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; max-height: 220px; overflow-y: auto; }
.assign-item { display: none; }
.assign-label {
    display: flex; align-items: center; gap: .5rem;
    padding: .55rem .7rem; border-radius: var(--radius-sm);
    border: 1.5px solid var(--border); cursor: pointer; transition: all var(--transition);
    font-size: .82rem; font-weight: 600; color: var(--text-secondary);
}
.assign-label:hover { border-color: var(--primary); }
.assign-item:checked + .assign-label { border-color: var(--primary); background: var(--primary-light); color: var(--primary-dark); }
.assign-label .ai-check { opacity: 0; color: var(--primary); }
.assign-item:checked + .assign-label .ai-check { opacity: 1; }

/* ─── Login ───────────────────────────────────────────────────*/
body.login-body { padding-top: 0; background: #0f172a; }
.login-bg { position: fixed; inset: 0; overflow: hidden; z-index: 0; }
.login-bg::before {
    content: ''; position: absolute; width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(99,102,241,.3) 0%, transparent 70%);
    top: -200px; right: -200px; border-radius: 50%; animation: float1 8s ease-in-out infinite;
}
.login-bg::after {
    content: ''; position: absolute; width: 500px; height: 500px;
    background: radial-gradient(circle, rgba(139,92,246,.2) 0%, transparent 70%);
    bottom: -150px; left: -150px; border-radius: 50%; animation: float2 10s ease-in-out infinite;
}
@keyframes float1 { 0%,100% { transform: translate(0,0); } 50% { transform: translate(-30px,25px); } }
@keyframes float2 { 0%,100% { transform: translate(0,0); } 50% { transform: translate(25px,-20px); } }
.login-wrapper { position: relative; z-index: 1; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.login-card {
    width: 100%; max-width: 420px;
    background: rgba(255,255,255,.05);
    backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: var(--radius-xl); padding: 2.5rem;
    box-shadow: 0 25px 50px rgba(0,0,0,.5); animation: slideUp 0.45s ease;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(28px); } to { opacity: 1; transform: translateY(0); } }
.login-logo-wrap {
    width: 70px; height: 70px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-lg);
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem; color: #fff; margin: 0 auto 1.25rem;
    box-shadow: 0 8px 28px rgba(99,102,241,.5); animation: glow 2.5s ease infinite;
}
@keyframes glow { 0%,100% { box-shadow: 0 8px 28px rgba(99,102,241,.5); } 50% { box-shadow: 0 8px 40px rgba(139,92,246,.7); } }
.login-title { font-size: 1.35rem; font-weight: 800; color: #fff; text-align: center; margin-bottom: 0.25rem; }
.login-subtitle { font-size: 0.83rem; color: rgba(255,255,255,.4); text-align: center; margin-bottom: 2rem; }
.login-card .form-label { color: rgba(255,255,255,.65); font-size: 0.82rem; }
.login-card .form-control { background: rgba(255,255,255,.07); border: 1.5px solid rgba(255,255,255,.1); color: #fff; }
.login-card .form-control::placeholder { color: rgba(255,255,255,.22); }
.login-card .form-control:focus { background: rgba(255,255,255,.11); border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.2); color: #fff; }
.login-card .input-group-text { background: rgba(255,255,255,.06); border: 1.5px solid rgba(255,255,255,.1); color: rgba(255,255,255,.35); }
.btn-login {
    width: 100%; padding: 0.72rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff; border: none; border-radius: var(--radius-sm);
    font-size: 0.95rem; font-weight: 700; font-family: 'Cairo', sans-serif;
    cursor: pointer; transition: all var(--transition);
    box-shadow: 0 8px 22px rgba(99,102,241,.4);
    display: flex; align-items: center; justify-content: center; gap: 0.5rem;
}
.btn-login:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(99,102,241,.55); }

/* ─── Animations ──────────────────────────────────────────────*/
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
.btn-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn-loading::after {
    content: ''; position: absolute; width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,.3); border-top-color: #fff;
    border-radius: 50%; animation: spin 0.7s linear infinite;
    top: 50%; left: 50%; transform: translate(-50%, -50%);
}

/* ─── Utilities ───────────────────────────────────────────────*/
.fw-600 { font-weight: 600; } .fw-700 { font-weight: 700; } .fw-800 { font-weight: 800; }
.text-primary { color: var(--primary) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }

/* ─── Responsive ──────────────────────────────────────────────*/
@media (max-width: 768px) {
    main { padding: 1rem 0.85rem !important; }
    .page-hero { padding: 16px 18px; gap: 12px; flex-wrap: wrap; }
    .page-hero-ico { width: 44px; height: 44px; font-size: 1.3rem; }
    .page-hero-title { font-size: 1rem; }
    .page-hero-actions { width: 100%; }
    .page-hero-actions .btn { flex: 1; justify-content: center; }
    .data-card-header { padding: .85rem 1rem; }
    .tbl-search-wrap { width: 100%; }
    .type-opts, .assign-list { grid-template-columns: 1fr; }
    .icon-picker { grid-template-columns: repeat(6, 1fr); }
}
@media (max-width: 576px) {
    .stat-box { padding: .75rem .85rem; gap: .6rem; }
    .stat-box-icon { width: 38px; height: 38px; font-size: 1.1rem; }
    .stat-box-val { font-size: 1.2rem; }
    .rec-table { min-width: 560px; }
    .table-scroll { border-radius: var(--radius-sm); }
    .login-card { padding: 1.75rem 1.25rem; }
    .icon-picker { grid-template-columns: repeat(5, 1fr); }
}

/* ─── Record Modal (تصميم محسّن — بلون الصفحة) ────────────────*/
.rec-modal .modal-content {
    border: none;
    border-radius: 22px;
    overflow: hidden;
    box-shadow: 0 30px 60px rgba(2, 6, 23, .35);
}

/* الترويسة */
.rec-modal-header {
    position: relative;
    padding: 1.35rem 1.5rem;
    display: flex;
    align-items: center;
    gap: .9rem;
    color: #fff;
    overflow: hidden;
}
.rec-modal-header::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: .10;
    pointer-events: none;
    background: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-rule='evenodd'%3E%3Cpath d='M0 40L40 0H20L0 20M40 40V20L20 40'/%3E%3C/g%3E%3C/svg%3E");
}
.rec-modal-header > * { position: relative; }
.modal-icon-badge {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: rgba(255, 255, 255, .2);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}
.rmh-text { min-width: 0; }
.rec-modal-header .rmh-title { font-size: 1.1rem; font-weight: 800; margin: 0; }
.rec-modal-header .rmh-sub {
    font-size: .77rem;
    opacity: .85;
    margin: 3px 0 0;
    display: flex;
    align-items: center;
    gap: .35rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rec-modal-header .btn-close {
    margin-inline-start: auto;
    filter: invert(1) brightness(2);
    opacity: .85;
    flex-shrink: 0;
}
.rec-modal-header .btn-close:hover { opacity: 1; }

/* عرض النافذة — عمود واحد مضبوط (أضيق من modal-lg) */
.rec-modal .rec-modal-dialog { max-width: 540px; }

/* الجسم */
.rec-modal-body {
    padding: 1.4rem 1.5rem .6rem;
    max-height: 68vh;
    overflow-y: auto;
}

/* مكدّس الحقول — كل حقل في سطر مستقل */
.field-stack {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}
.field-col { width: 100%; min-width: 0; }

/* التسمية */
.iarc-label {
    display: flex;
    align-items: center;
    gap: .35rem;
    font-weight: 700;
    font-size: .815rem;
    color: var(--text-primary);
    margin-bottom: .48rem;
    line-height: 1.4;
}
.iarc-label .lbl-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iarc-req {
    color: var(--danger);
    font-weight: 800;
    font-size: .95rem;
    line-height: 1;
}

/* ارتفاع موحّد ومريح للمدخلات داخل نافذة السجل */
.rec-modal .form-control,
.rec-modal .tel-group {
    min-height: 44px;
    font-size: .9rem;
}
.rec-modal textarea.form-control { min-height: 92px; resize: vertical; }
.rec-modal select.form-control { cursor: pointer; }
.iarc-enc {
    margin-inline-start: auto;
    font-size: .65rem;
    font-weight: 700;
    color: #b45309;
    background: #fef3c7;
    padding: .12rem .5rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: .25rem;
}

/* حقل بأيقونة داخلية */
.iarc-field-input { position: relative; }
.iarc-field-ico {
    position: absolute;
    right: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--field-accent, var(--primary));
    font-size: .95rem;
    z-index: 2;
    pointer-events: none;
    display: flex;
    align-items: center;
    opacity: .85;
    transition: transform var(--transition), opacity var(--transition);
}
.iarc-field-input.is-textarea .iarc-field-ico { top: 16px; transform: none; }
.iarc-has-ico { padding-right: 2.6rem !important; }
.iarc-has-eye { padding-left: 2.7rem !important; }
.iarc-eye {
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.iarc-eye:hover { background: var(--surface-2); color: var(--field-accent, var(--primary)); }

/* التركيز بلون الصفحة */
.rec-modal .form-control:focus {
    border-color: var(--field-accent, var(--primary));
    box-shadow: 0 0 0 3.5px var(--field-accent-soft, rgba(99, 102, 241, .15));
}
.rec-modal .iarc-field-input:focus-within .iarc-field-ico { opacity: 1; transform: translateY(-50%) scale(1.1); }
.rec-modal .iarc-field-input.is-textarea:focus-within .iarc-field-ico { transform: scale(1.1); }

/* التذييل */
.rec-modal-footer {
    display: flex;
    align-items: center;
    gap: .6rem;
    justify-content: flex-end;
    padding: 1rem 1.5rem 1.4rem;
    border-top: 1px solid var(--border-light);
    margin-top: .4rem;
}
.btn-save {
    background: linear-gradient(135deg, var(--field-accent-dark, var(--primary-dark)), var(--field-accent, var(--primary)));
    color: #fff;
    font-weight: 700;
    padding: .62rem 1.7rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), 0 8px 20px var(--field-accent-soft, rgba(99, 102, 241, .35));
}
.btn-save:hover {
    color: #fff;
    transform: translateY(-2px);
    filter: brightness(1.12);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .26), 0 13px 28px var(--field-accent-soft, rgba(99, 102, 241, .5));
}

/* ظهور متدرّج للحقول عند الفتح */
.rec-modal.show .field-col { animation: iarcFieldIn .42s cubic-bezier(.4, 0, .2, 1) both; }
.rec-modal.show .field-col:nth-child(1) { animation-delay: .03s; }
.rec-modal.show .field-col:nth-child(2) { animation-delay: .07s; }
.rec-modal.show .field-col:nth-child(3) { animation-delay: .11s; }
.rec-modal.show .field-col:nth-child(4) { animation-delay: .15s; }
.rec-modal.show .field-col:nth-child(5) { animation-delay: .19s; }
.rec-modal.show .field-col:nth-child(6) { animation-delay: .23s; }
.rec-modal.show .field-col:nth-child(7) { animation-delay: .27s; }
.rec-modal.show .field-col:nth-child(8) { animation-delay: .31s; }
.rec-modal.show .field-col:nth-child(9) { animation-delay: .35s; }
.rec-modal.show .field-col:nth-child(n+10) { animation-delay: .38s; }
@keyframes iarcFieldIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: none; }
}

@media (max-width: 576px) {
    .rec-modal-header { padding: 1.1rem 1.15rem; gap: .7rem; }
    .modal-icon-badge { width: 42px; height: 42px; font-size: 1.2rem; border-radius: 12px; }
    .rec-modal-header .rmh-title { font-size: 1rem; }
    .rec-modal-body { padding: 1.15rem 1.15rem .35rem; max-height: 62vh; }
    .rec-modal-footer { padding: .9rem 1.15rem 1.2rem; flex-direction: column; }
    .rec-modal-footer .btn { width: 100%; justify-content: center; }
}

/* ─── Permission Grid (صلاحيات المشرف لكل صفحة) ───────────────*/
.perm-grid {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden auto;
    max-height: 300px;
}
.perm-grid-head,
.perm-row {
    display: grid;
    grid-template-columns: 1fr repeat(4, 54px);
    align-items: center;
}
.perm-grid-head {
    background: var(--surface-2);
    font-size: .7rem;
    font-weight: 700;
    color: var(--text-secondary);
    padding: .55rem .75rem;
    position: sticky;
    top: 0;
    z-index: 2;
    border-bottom: 1px solid var(--border);
    text-align: center;
}
.perm-grid-head .pg-page { text-align: right; }
.perm-row {
    padding: .3rem .75rem;
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition);
}
.perm-row:last-child { border-bottom: none; }
.perm-row:hover { background: var(--surface-2); }
.pg-page {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .82rem;
    font-weight: 600;
    min-width: 0;
}
.pg-ico { font-size: 1rem; flex-shrink: 0; }
.pg-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.perm-cb { justify-self: center; cursor: pointer; margin: 0; }
.perm-cb input { display: none; }
.perm-cb > span {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1.5px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    background: var(--surface);
    font-size: .78rem;
    transition: all var(--transition);
}
.perm-cb:hover > span { border-color: var(--primary); color: var(--primary); }
.perm-cb.read  input:checked + span { background: #dbeafe; border-color: #3b82f6; color: #2563eb; }
.perm-cb.add   input:checked + span { background: #dcfce7; border-color: #22c55e; color: #16a34a; }
.perm-cb.edit  input:checked + span { background: #fef3c7; border-color: #f59e0b; color: #d97706; }
.perm-cb.del   input:checked + span { background: #fee2e2; border-color: #ef4444; color: #dc2626; }

/* صندوق تلميح */
.assign-hint {
    display: flex;
    gap: .5rem;
    align-items: flex-start;
    background: var(--info-light);
    color: #0e7490;
    border-radius: var(--radius);
    padding: .75rem 1rem;
    font-size: .82rem;
    line-height: 1.6;
}
.assign-hint i { margin-top: .15rem; flex-shrink: 0; }
.assign-hint a { color: #0369a1; font-weight: 700; }

@media (max-width: 576px) {
    .perm-grid-head,
    .perm-row { grid-template-columns: 1fr repeat(4, 40px); }
    .perm-cb > span { width: 26px; height: 26px; font-size: .7rem; }
    .pg-name { font-size: .76rem; }
    .perm-grid-head { font-size: .6rem; }
}

/* ─── قيمة القائمة المنسدلة في الجدول ─────────────────────────*/
.val-chip {
    display: inline-block;
    padding: .2rem .65rem;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-primary);
}
/* حقل القائمة داخل نموذج السجل */
.iarc-field-input .iarc-select { cursor: pointer; }

/* ─── حقل الهاتف (رمز الدولة + الرقم) ─────────────────────────*/
.tel-field .tel-group {
    display: flex;
    align-items: stretch;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    overflow: hidden;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.tel-field .tel-group:focus-within {
    border-color: var(--field-accent, var(--primary));
    box-shadow: 0 0 0 3.5px var(--field-accent-soft, rgba(99, 102, 241, .15));
}
.tel-country {
    flex-shrink: 0;
    max-width: 140px;
    border: none;
    outline: none;
    background: var(--surface-2);
    border-inline-end: 1.5px solid var(--border);
    color: var(--text-primary);
    font-family: 'Cairo', sans-serif;
    font-size: .8rem;
    padding: .5rem .55rem;
    cursor: pointer;
}
.tel-number {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-primary);
    font-family: 'Cairo', sans-serif;
    font-size: .9rem;
    letter-spacing: .5px;
    padding: .52rem .85rem;
}
.tel-number::placeholder { color: var(--text-muted); letter-spacing: normal; }
