:root {
    --bg: #f8f7f4;
    --bg-alt: #f0ede5;
    --surface: #ffffff;
    --text: #2c3531;
    --muted: #7a827e;
    --green: #4f6d5c;
    --green-light: #60806e;
    --gold: #c3a367;
    --gold-soft: #f4efe2;
    --border: rgba(79, 109, 92, 0.08);
    --shadow: 0 12px 30px rgba(37, 56, 46, 0.06);
    --radius: 16px; /* زوايا أنعم وأجمل */
    --font: 'IBM Plex Sans Arabic', system-ui, sans-serif;
    --transition: all 0.2s ease-in-out;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #121614;
        --bg-alt: #1a211d;
        --surface: #1e2622;
        --text: #e4e7e5;
        --muted: #87918b;
        --green: #8cb89f;
        --green-light: #a3cbb5;
        --gold: #d4b785;
        --gold-soft: #29332d;
        --border: rgba(140, 184, 159, 0.12);
        --shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    }
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background var(--transition), color var(--transition);
}

main {
    flex: 1;
}

a {
    color: var(--green-light);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--gold);
}

.bg-pattern {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 5% 5%, rgba(195, 163, 103, 0.02), transparent 30%),
        radial-gradient(circle at 95% 95%, rgba(79, 109, 92, 0.02), transparent 30%);
    pointer-events: none;
    z-index: -1;
}

.container {
    width: 100%;
    max-width: 1140px;
    margin: 0 auto;
    padding: 0 24px;
}

.narrow {
    max-width: 640px;
    margin-left: auto;
    margin-right: auto;
}

/* القائمة العلوية */
.navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: color-mix(in srgb, var(--surface) 90%, transparent);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 4px 20px rgba(0,0,0,0.02);
}

.nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 68px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 700;
    font-size: 1.2rem;
}

.logo-mark {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--green);
    color: var(--gold-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.nav-links {
    display: flex;
    gap: 8px;
    list-style: none;
    align-items: center;
}

.nav-links a {
    color: var(--muted);
    font-weight: 500;
    font-size: 0.9rem;
    padding: 6px 12px;
    border-radius: 8px;
}

.nav-links a.active, .nav-links a:hover {
    color: var(--green);
    background: var(--bg-alt);
}

.menu-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
}

/* قسم الهيرو الرئيسي */
.hero {
    padding: 60px 0;
}

.hero-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 48px;
    align-items: center;
}

.hero-content h1 {
    font-size: clamp(2.2rem, 5vw, 3rem);
    font-weight: 800;
    color: var(--text);
    margin: 16px 0;
    letter-spacing: -0.5px;
}

.hero-lead {
    color: var(--muted);
    font-size: 1.15rem;
    line-height: 1.8;
    margin-bottom: 32px;
    max-width: 580px;
}

.hero-actions {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

/* المشغل الصغير في الهوم */
.hero-card {
    background: linear-gradient(145deg, var(--surface), rgba(255, 255, 255, 0.02));
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hero-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12);
}

.mini-player {
    padding: 32px;
}

.mini-player h3 {
    color: var(--text);
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.mini-controls span {
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
}

.mini-controls .player-btn:hover {
    color: var(--text) !important;
    transform: scale(1.1);
}

#play-trigger-btn:hover {
    transform: scale(1.15) !important;
}

/* الأزرار العامة */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 28px;
    border-radius: 12px;
    border: none;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: var(--green);
    color: #ffffff !important;
    box-shadow: 0 8px 20px rgba(79, 109, 92, 0.2);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(79, 109, 92, 0.3);
    opacity: 0.95;
}

.btn-ghost {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-ghost:hover {
    background: var(--bg-alt);
    border-color: rgba(255, 255, 255, 0.15);
}

.btn-danger {
    background: #d96459;
    color: #ffffff !important;
}

.btn-danger:hover {
    background: #c35349;
}

.btn-sm { padding: 8px 16px; font-size: 0.85rem; border-radius: 8px; }
.btn-xs { padding: 4px 8px; font-size: 0.76rem; border-radius: 4px; }
.btn.full { width: 100%; }

/* قسم الإحصائيات (الهوم والدشبرود) */
.home-stats-grid, .stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 24px;
    margin-top: 40px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: none;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    border-color: rgba(79, 109, 92, 0.3);
}

.stat-icon {
    font-size: 1.8rem;
    color: var(--green);
    background: rgba(79, 109, 92, 0.08);
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
}

/* الروم الصوتي الشغال المتفاعل */
.voice-active-card {
    border: 1px solid rgba(74, 144, 226, 0.2) !important;
    background: linear-gradient(145deg, var(--surface), rgba(74, 144, 226, 0.02)) !important;
}

.voice-active-card .stat-icon {
    color: #4a90e2;
    background: rgba(74, 144, 226, 0.1);
    animation: voicePulse 2s infinite ease-in-out;
}

@keyframes voicePulse {
    0% { box-shadow: 0 0 0 0 rgba(74, 144, 226, 0.3); }
    70% { box-shadow: 0 0 0 10px rgba(74, 144, 226, 0); }
    100% { box-shadow: 0 0 0 0 rgba(74, 144, 226, 0); }
}

.stat-num {
    display: block;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.stat-lbl { 
    font-size: 0.9rem; 
    color: var(--muted); 
}

/* الأقسام والميزات */
.section {
    padding: 80px 0 40px 0;
}

.section-alt {
    background: var(--bg-alt);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-6px);
    border-color: var(--green);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.1);
}

.section-heading {
    font-size: 2rem;
    color: var(--text);
    margin-bottom: 48px;
    font-weight: 800;
    text-align: center;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
}

.feature-icon {
    font-size: 2rem;
    margin-bottom: 20px;
    display: inline-block;
    color: var(--green);
}

.feature h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text);
}

.feature p {
    color: var(--muted);
    line-height: 1.6;
    font-size: 0.95rem;
}

/* الحقول والنماذج */
.inline-form {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.inline-form input {
    flex: 1;
    min-width: 160px;
}

input[type="text"], input[type="number"], select, input[type="file"] {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.95rem;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: var(--transition);
}

input:focus, select:focus {
    border-color: var(--green);
    background: var(--surface);
}

/* التنبيهات */
.pill {
    padding: 6px 16px;
    font-weight: 600;
    font-size: 0.85rem;
    background: rgba(79, 109, 92, 0.1);
    color: var(--green);
    border-radius: 50px;
    display: inline-block;
    border: 1px solid rgba(79, 109, 92, 0.15);
}

.live-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #d96459;
}

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 8px;
}
.alert.ok { background: rgba(98, 168, 124, 0.12); color: #437c57; border: 1px solid rgba(98, 168, 124, 0.15); }
.alert.err { background: rgba(217, 100, 89, 0.12); color: #a6443b; border: 1px solid rgba(217, 100, 89, 0.15); }

/* مودال النوافذ المنبثقة (شروط وسياسة) */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-box {
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 40px;
    border-radius: 24px;
    max-width: 650px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.2);
}

.modal-close {
    position: absolute;
    top: 24px; left: 24px;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 50%;
    width: 36px; height: 36px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #d96459;
    color: #fff;
    border-color: #d96459;
}

/* الفوتر ومكان دعم الخادم المدمج */
.policy-links-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    margin-top: 60px;
    padding: 24px 0;
    border-top: 1px solid var(--border);
    font-size: 0.95rem;
    flex-wrap: wrap;
}

.policy-link-btn {
    color: var(--muted);
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s ease;
}

.policy-link-btn:hover {
    color: var(--green);
}

.donate-inline-btn {
    background: rgba(0, 121, 193, 0.08) !important;
    border: 1px solid rgba(0, 121, 193, 0.15) !important;
    color: #0079C1 !important;
    box-shadow: none !important;
    padding: 8px 18px !important;
    font-size: 0.85rem !important;
    border-radius: 8px !important;
}

.donate-inline-btn:hover {
    background: #0079C1 !important;
    color: #fff !important;
    border-color: #0079C1 !important;
}

/* باقي كلاسات لوحة التحكم التابعة للجداول والمجموعات */
.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: 8px;
    max-width: 300px;
    width: 100%;
}

.search-box input {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
}

.dash-header { padding: 24px 0 12px; }
.dash-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 16px;
}
.dash-top h1 { font-size: 1.4rem; font-weight: 600; color: var(--green); }

.admin-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 32px;
}
.stack-form .field { margin-bottom: 12px; }
.stack-form label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--text); margin-bottom: 4px; }

.guild-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
}
.guild-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
}
.guild-icon {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg-alt);
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    min-width: 450px;
}
th, td {
    padding: 10px 14px;
    text-align: right;
    border-bottom: 1px solid var(--border);
}
th {
    color: var(--text);
    font-weight: 600;
    background: var(--bg-alt);
}
tr:last-child td { border-bottom: none; }

.footer {
    margin-top: auto;
    padding: 24px 0;
    text-align: center;
    border-top: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-size: 0.82rem;
}

/* التجاوب مع الشاشات المختلفة */
@media (max-width: 992px) {
    .hero-grid {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 40px;
    }
    .hero-lead {
        margin-left: auto;
        margin-right: auto;
    }
    .hero-actions {
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .menu-toggle { display: block; }
    .nav-links {
        position: absolute;
        top: 68px; left: 0; right: 0;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        flex-direction: column;
        padding: 16px;
        gap: 8px;
        box-shadow: var(--shadow);
        display: none;
    }
    .nav-links.open { display: flex; }
    .nav-links a { width: 100%; text-align: center; }
    .admin-split { grid-template-columns: 1fr; }
    .home-stats-grid, .stats-row { grid-template-columns: repeat(2, 1fr); gap: 16px; }
    .policy-links-footer { gap: 16px; }
}

@media (max-width: 480px) {
    .home-stats-grid, .stats-row { grid-template-columns: 1fr; }
    .dash-top { flex-direction: column; align-items: flex-start; }
    .search-box { max-width: 100%; }
}