/* أقسام بوت السستم في لوحة السيرفر — طبقة موحّدة فوق الأنماط القديمة.
   كل القواعد محصورة بـ #guildPage عشان ما تأثر على الصفحة الرئيسية أو بوتات ثانية. */

#guildPage {
    --sys-card: #121313;
    --sys-card-2: #171919;
    --sys-line: rgba(255, 255, 255, 0.07);
    --sys-line-strong: rgba(84, 126, 114, 0.45);
    --sys-accent: #547E72;
    --sys-accent-soft: rgba(84, 126, 114, 0.14);
    --sys-danger: #e5534b;
    --sys-danger-soft: rgba(229, 83, 75, 0.12);
    --sys-radius: 16px;
}

/* ── تباعد موحّد بين بطاقات كل تبويب */
#guildPage .tab-content > .sys-section,
#guildPage .tab-content > .sys-mod-card,
#guildPage .tab-content > section.sys-mod-card {
    padding: 20px 22px;
    margin: 0 0 16px;
    border-radius: var(--sys-radius);
}
#guildPage .sys-section-title,
#guildPage .sys-mod-card h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 6px;
    font-size: 16px;
    font-weight: 800;
    color: #fff;
}
#guildPage .sys-section-title i,
#guildPage .sys-mod-card h3 > i { color: var(--sys-accent); }
#guildPage .sys-mod-hint {
    font-size: 12.5px;
    line-height: 1.7;
    color: var(--text-dim);
    margin: 0 0 14px;
}
#guildPage .sys-mod-hint a { color: var(--primary-light, #7fb3a4); text-decoration: underline; }
#guildPage .sys-subtitle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 18px 0 10px;
    padding-top: 16px;
    border-top: 1px solid var(--sys-line);
    font-size: 13.5px;
    font-weight: 700;
    color: #e6e6e6;
}
#guildPage .sys-subtitle i { color: var(--sys-accent); }

/* ── وضع الطوارئ */
#guildPage .prot-emergency {
    display: grid;
    grid-template-columns: 1fr minmax(260px, 340px);
    gap: 18px;
    align-items: stretch;
    margin: 0 0 22px;
    padding: 20px 22px;
    border-radius: var(--sys-radius);
    border: 1px solid var(--sys-line);
    background:
        radial-gradient(circle at 100% 0, rgba(229, 83, 75, 0.08), transparent 55%),
        var(--sys-card);
}
#guildPage .prot-emergency.is-active {
    border-color: rgba(229, 83, 75, 0.55);
    background:
        radial-gradient(circle at 100% 0, rgba(229, 83, 75, 0.22), transparent 60%),
        var(--sys-card);
    box-shadow: 0 0 0 1px rgba(229, 83, 75, 0.18), 0 14px 40px rgba(229, 83, 75, 0.12);
}
#guildPage .prot-emergency-main { display: flex; gap: 14px; align-items: flex-start; }
#guildPage .prot-emergency-icon {
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    color: var(--sys-danger);
    background: var(--sys-danger-soft);
    border: 1px solid rgba(229, 83, 75, 0.3);
}
#guildPage .prot-emergency-text h3 {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 2px 0 6px;
    font-size: 17px;
    font-weight: 800;
    color: #fff;
}
#guildPage .prot-emergency-text p {
    margin: 0 0 6px;
    font-size: 12.5px;
    line-height: 1.75;
    color: var(--text-dim);
}
#guildPage .prot-emergency-text p b { color: #fff; }
#guildPage .prot-emergency-how i { color: var(--sys-accent); margin-inline-end: 4px; }
#guildPage .prot-emergency-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
    color: #9fb3ad;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--sys-line);
}
#guildPage .prot-emergency.is-active .prot-emergency-badge {
    color: #fff;
    background: var(--sys-danger);
    border-color: transparent;
    animation: sysPulse 1.6s ease-in-out infinite;
}
@keyframes sysPulse { 50% { box-shadow: 0 0 0 6px rgba(229, 83, 75, 0); } 0%, 100% { box-shadow: 0 0 0 0 rgba(229, 83, 75, 0.45); } }
#guildPage .prot-emergency-auto {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid var(--sys-line);
}
#guildPage .prot-emergency-auto strong {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #fff;
    margin-bottom: 4px;
}
#guildPage .prot-emergency-auto strong i { color: var(--sys-accent); }
#guildPage .prot-emergency-auto span { display: block; font-size: 12px; line-height: 1.65; color: var(--text-dim); }
#guildPage .prot-emergency-auto .toggle { flex: 0 0 auto; }

/* ── مجموعات الحماية */
#guildPage .prot-groups { display: flex; flex-direction: column; gap: 18px; margin-bottom: 18px; }
#guildPage .prot-group {
    padding: 18px 20px 20px;
    border-radius: var(--sys-radius);
    border: 1px solid var(--sys-line);
    background: var(--sys-card);
}
#guildPage .prot-group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 4px;
}
#guildPage .prot-group-head h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 16px;
    font-weight: 800;
    color: #fff;
}
#guildPage .prot-group-head h3 i { color: var(--sys-accent); }
#guildPage .prot-group-count {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--primary-light, #7fb3a4);
    background: var(--sys-accent-soft);
    border: 1px solid rgba(84, 126, 114, 0.3);
    padding: 3px 10px;
    border-radius: 999px;
    white-space: nowrap;
}
#guildPage .prot-group .sys-mod-hint { margin: 2px 0 14px; }
#guildPage .prot-group .prot-toggles-grid {
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 12px;
    margin: 0;
}
#guildPage .prot-group:not(:has(.sys-mod-hint)) .prot-toggles-grid { margin-top: 14px; }

/* بطاقة حماية: العنوان + الزر بنفس السطر، والبطاقة المفعّلة لها حد ملوّن */
#guildPage .prot-toggle-card {
    display: flex;
    flex-direction: column;
    padding: 14px 15px;
    border-radius: 14px;
    background: var(--sys-card-2) !important;
    border: 1px solid var(--sys-line) !important;
    transition: border-color .2s ease, background .2s ease, transform .2s ease;
}
#guildPage .prot-toggle-card:hover { transform: translateY(-1px); border-color: rgba(84, 126, 114, 0.3) !important; box-shadow: none; }
#guildPage .prot-toggle-card.is-on {
    border-color: var(--sys-line-strong) !important;
    background: linear-gradient(180deg, rgba(84, 126, 114, 0.09), rgba(84, 126, 114, 0.02)), var(--sys-card-2) !important;
}
#guildPage .prot-toggle-head { gap: 10px; margin-bottom: 8px; }
#guildPage .prot-toggle-head i {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    font-size: 13px;
    color: #8aa59d;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--sys-line);
}
#guildPage .prot-toggle-card.is-on .prot-toggle-head i {
    color: var(--primary-light, #7fb3a4);
    background: var(--sys-accent-soft);
    border-color: rgba(84, 126, 114, 0.35);
}
#guildPage .prot-toggle-head span { font-size: 13.5px; line-height: 1.4; }
#guildPage .prot-toggle-head .toggle { flex: 0 0 auto; margin: 0; }
#guildPage .prot-toggle-card p { margin: 0; font-size: 12px; line-height: 1.65; }
#guildPage .prot-new {
    display: inline-block;
    margin-inline-start: 6px;
    padding: 1px 7px;
    border-radius: 999px;
    font-style: normal;
    font-size: 10px;
    font-weight: 800;
    color: #0c1311;
    background: #7fd1b9;
    vertical-align: middle;
}
#guildPage .prot-toggle-card--wide { grid-column: span 2; }
#guildPage .prot-card-extra { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--sys-line); }
#guildPage .prot-card-extra > span,
#guildPage .prot-card-extra .bot-field > span { font-size: 12px; color: #cfd8d5; }
#guildPage .prot-card-extra textarea { min-height: 62px; resize: vertical; font-size: 12.5px; }
#guildPage .prot-card-extra small { display: block; margin-top: 6px; font-size: 11px; color: var(--text-dim); }
#guildPage .prot-card-extra code,
#guildPage .sys-welcome-vars code {
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    color: #cfe5de;
}
#guildPage .prot-newvoice-fields { display: grid; grid-template-columns: 160px 1fr; gap: 12px; align-items: start; }
#guildPage .prot-chips { display: flex; flex-wrap: wrap; gap: 6px; }
#guildPage .prot-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    color: #d7dedc;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--sys-line);
    cursor: pointer;
    user-select: none;
}
#guildPage .prot-chip:has(input:checked) { border-color: var(--sys-line-strong); background: var(--sys-accent-soft); color: #fff; }
#guildPage .prot-chip input { accent-color: var(--sys-accent); margin: 0; }

/* ── الألوان */
#guildPage .sys-mod-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
#guildPage .sys-mod-card-head h3 { margin: 0; }
#guildPage .sys-inline-toggle { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #cfd8d5; }
#guildPage .sys-mod-card-head + .sys-mod-hint { margin-top: 8px; }
#guildPage .sys-check { flex-direction: row !important; align-items: center; gap: 8px; align-self: end; padding-bottom: 12px; font-size: 13px; color: #cfd8d5; }
#guildPage .sys-check input { accent-color: var(--sys-accent); width: 16px; height: 16px; }
#guildPage .sys-color-roles {
    margin-top: 14px;
    padding: 14px;
    border-radius: 14px;
    border: 1px solid var(--sys-line);
    background: rgba(255, 255, 255, 0.02);
}
#guildPage .sys-color-roles-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; font-size: 12.5px; color: #cfd8d5; }
#guildPage .sys-color-roles-head select { max-width: 240px; }
#guildPage .sys-color-roles-list { display: flex; flex-wrap: wrap; gap: 8px; }
#guildPage .sys-color-role {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px 6px 10px;
    border-radius: 10px;
    font-size: 12.5px;
    color: #fff;
    background: var(--sys-card-2);
    border: 1px solid var(--sys-line);
}
#guildPage .sys-color-role b {
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    background: rgba(255, 255, 255, 0.08);
}
#guildPage .sys-color-role i { width: 12px; height: 12px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35); }
#guildPage .sys-color-role button {
    border: 0;
    background: none;
    color: var(--text-dim);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
}
#guildPage .sys-color-role button:hover { color: var(--sys-danger); }

/* ── الترحيب */
#guildPage .sys-welcome-vars { margin: -2px 0 14px; line-height: 2; }

/* ── مركز الطوارئ (ضد الرييد) — كانت الكلاسات بدون أنماط تخطيط */
#guildPage .anti-raid-alert-banner {
    position: relative;
    display: flex;
    align-items: center;
    padding: 18px 20px;
    border-radius: var(--sys-radius);
    border: 1px solid rgba(84, 126, 114, 0.35);
    background: linear-gradient(90deg, rgba(84, 126, 114, 0.14), rgba(84, 126, 114, 0.03));
    overflow: hidden;
}
#guildPage .anti-raid-alert-banner.attack { border-color: rgba(229, 83, 75, 0.6); background: linear-gradient(90deg, rgba(229, 83, 75, 0.2), rgba(229, 83, 75, 0.04)); }
#guildPage .anti-raid-alert-banner.lockdown { border-color: rgba(255, 159, 67, 0.55); background: linear-gradient(90deg, rgba(255, 159, 67, 0.16), rgba(255, 159, 67, 0.03)); }
#guildPage .anti-raid-alert-banner .status-indicator-glow { display: none; }
#guildPage .status-alert-content { display: flex; align-items: center; gap: 12px; }
#guildPage .status-alert-content .status-icon { font-size: 22px; color: var(--sys-accent); }
#guildPage .anti-raid-alert-banner.attack .status-icon { color: var(--sys-danger); }
#guildPage .anti-raid-alert-banner.lockdown .status-icon { color: #ff9f43; }
#guildPage .status-alert-content h3 { margin: 0; font-size: 16px; font-weight: 800; color: #fff; }
#guildPage .anti-raid-note { margin: 10px 2px 16px; }
#guildPage .anti-raid-metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
#guildPage .anti-raid-metric-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--sys-line);
    background: var(--sys-card);
}
#guildPage .anti-raid-metric-card .metric-icon {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--sys-line);
}
#guildPage .anti-raid-metric-card .metric-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
#guildPage .anti-raid-metric-card .metric-label { font-size: 11.5px; color: var(--text-dim); }
#guildPage .anti-raid-metric-card .metric-value { font-size: 17px; font-weight: 800; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#guildPage .anti-raid-metric-card .text-glow-red { color: var(--sys-danger); }
#guildPage .anti-raid-metric-card .text-glow-green { color: #7fd1b9; }

/* ── مركز اللوقات: نفس عرض الأعمدة بكل المجموعات */
#guildPage .sys-logs-table { table-layout: fixed; width: 100%; }
#guildPage .sys-logs-table th:first-child,
#guildPage .sys-logs-table td:first-child { width: 42%; }

/* ── شاشات صغيرة */
@media (max-width: 900px) {
    #guildPage .prot-emergency { grid-template-columns: 1fr; }
    #guildPage .anti-raid-metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    #guildPage .prot-toggle-card--wide { grid-column: auto; }
    #guildPage .prot-newvoice-fields { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
    #guildPage .prot-group { padding: 14px; }
    #guildPage .prot-group .prot-toggles-grid { grid-template-columns: 1fr; }
    #guildPage .anti-raid-metrics-grid { grid-template-columns: 1fr; }
    #guildPage .prot-group-head { flex-wrap: wrap; }
    #guildPage .sys-color-roles-head { flex-direction: column; align-items: stretch; }
    #guildPage .sys-color-roles-head select { max-width: none; }
}

/* ── مفاتيح التشغيل: فرق واضح بين المفعّل والمعطّل */
#guildPage .prot-groups .toggle,
#guildPage .prot-emergency .toggle,
#guildPage .sys-inline-toggle .toggle {
    background: rgba(255, 255, 255, 0.12) !important;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
#guildPage .prot-groups .toggle::after,
#guildPage .prot-emergency .toggle::after,
#guildPage .sys-inline-toggle .toggle::after { background: #9aa5a2 !important; }
#guildPage .prot-groups .toggle.active,
#guildPage .prot-emergency .toggle.active,
#guildPage .sys-inline-toggle .toggle.active {
    background: linear-gradient(180deg, #6fa898, #4c7a6d) !important;
    box-shadow: 0 0 0 3px rgba(84, 126, 114, 0.18);
}
#guildPage .prot-groups .toggle.active::after,
#guildPage .prot-emergency .toggle.active::after,
#guildPage .sys-inline-toggle .toggle.active::after { background: #fff !important; }

/* معاينة خلفية الألوان: بطاقة صغيرة بدل مساحة فاضية بعرض القسم */
#guildPage .sys-mod-color-preview {
    padding: 0;
    border: 0;
    background: none;
    min-height: 0;
    margin-top: 6px;
}
#guildPage .sys-mod-color-preview-mock { max-width: 420px; }
#guildPage .sys-mod-color-preview-bg { min-height: 120px; }

/* أيقونة حالة مركز الطوارئ: قاعدة قديمة تعطيها خلفية بنفس لونها فتطلع مربع */
#guildPage .anti-raid-alert-banner .status-icon { background: none !important; }
#guildPage .anti-raid-alert-banner.secure .status-icon { color: #7fd1b9 !important; }

/* رأس الصفحة (الحماية/الإعدادات…) على الجوال: العنوان سطر كامل وزر الحفظ تحته */
@media (max-width: 700px) {
    #guildPage .bot-settings-hero {
        flex-wrap: wrap;
        gap: 12px;
    }
    #guildPage .bot-settings-hero-title {
        order: -1;
        flex: 1 1 100%;
        min-width: 0;
    }
    #guildPage .bot-settings-hero-title h2 { word-break: normal; white-space: normal; }
    #guildPage .bot-settings-hero .bot-settings-save {
        flex: 1 1 100%;
        width: 100%;
        writing-mode: horizontal-tb;
    }
}
@media (max-width: 700px) {
    #guildPage .bot-settings-hero-text {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start;
        flex: 1 1 auto;
        min-width: 0;
    }
    #guildPage .bot-settings-hero-text h2 { white-space: nowrap; }
}
