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

:root {
    --bg-color: #000000;
    --sidebar-bg: rgba(28, 28, 30, 0.75);
    --card-bg: rgba(35, 35, 38, 0.6);
    --text-primary: #f5f5f7;
    --text-secondary: #86868b;
    --accent-color: #0a84ff;
    --accent-hover: #0071e3;
    --danger-color: #ff453a;
    --success-color: #32d74b;
    --warning-color: #ffd60a;
    --border-color: rgba(255, 255, 255, 0.18);
    --glass-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

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

body {
    font-family: 'Cairo', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #000;
    background-image: 
        linear-gradient(160deg, #13151a 0%, #000000 100%),
        radial-gradient(circle at 15% 15%, rgba(10, 132, 255, 0.15), transparent 40%),
        radial-gradient(circle at 85% 85%, rgba(191, 90, 242, 0.12), transparent 40%);
    background-attachment: fixed;
    color: var(--text-primary);
    display: flex;
    height: 100vh; /* Fallback for older browsers */
    height: 100dvh; /* Fix for iOS Safari bottom bar issue */
    overflow: hidden;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background: var(--sidebar-bg);
    backdrop-filter: saturate(180%) blur(25px);
    -webkit-backdrop-filter: saturate(180%) blur(25px);
    border-inline-end: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 100;
}

.sidebar-header {
    padding: 24px 20px;
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    letter-spacing: 1px;
}

.sidebar-menu {
    padding: 20px 10px;
    flex: 1;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s ease;
    font-weight: 500;
    margin-bottom: 4px;
    border-radius: 10px;
    font-size: 15px;
}

.sidebar-menu a i {
    font-size: 20px;
    margin-inline-end: 12px;
}

.sidebar-menu a:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.sidebar-menu a.active {
    background: var(--accent-color);
    color: #fff;
    box-shadow: 0 4px 12px rgba(10, 132, 255, 0.4);
}

/* Main Content */


.main-content {
    flex: 1;
    padding: 30px 40px;
    background: var(--bg-color);
    overflow-y: auto;
    position: relative;
    scroll-behavior: smooth;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.top-bar h2 {
    margin: 0;
}

.lang-btn {
    background: rgba(255,255,255,0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 6px 14px;
    border-radius: 99px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}
.lang-btn:hover {
    background: rgba(255,255,255,0.1);
}

.menu-toggle {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.menu-toggle:hover {
    color: var(--accent-color);
}

.sidebar {
    width: 250px;
    background: var(--sidebar-bg);
    backdrop-filter: saturate(180%) blur(25px);
    -webkit-backdrop-filter: saturate(180%) blur(25px);
    border-inline-end: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 100;
    overflow-x: hidden;
}

.sidebar.collapsed {
    width: 70px !important;
}

.sidebar.collapsed .sidebar-text {
    display: none;
}

.sidebar.collapsed .sidebar-header {
    padding: 24px 0;
}
.sidebar.collapsed .sidebar-header i {
    margin: 0;
}

.sidebar.collapsed .user-profile-sidebar {
    background: transparent !important;
    border: none !important;
    padding: 10px 0 !important;
    margin: 0 0 20px 0 !important;
    justify-content: center;
}

.sidebar.collapsed .sidebar-menu a {
    justify-content: center;
    padding: 12px 0;
}
.sidebar.collapsed .sidebar-menu a i {
    margin: 0;
    font-size: 24px;
}

/* Cards */
.card {
    background: var(--card-bg);
    backdrop-filter: saturate(180%) blur(25px);
    -webkit-backdrop-filter: saturate(180%) blur(25px);
    padding: 24px;
    border-radius: 18px;
    box-shadow: var(--glass-shadow);
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease;
}

.card:hover {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 13px;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 13px;
    color: var(--text-primary);
    transition: all 0.2s ease;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-color);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.3);
}

select.form-control {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230a84ff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left 15px center;
    background-size: 16px;
    padding-left: 40px; /* Space for the arrow */
    color: #0a84ff !important;
    font-weight: 600;
    border: 1px solid rgba(10, 132, 255, 0.3);
    background-color: rgba(10, 132, 255, 0.05) !important;
}

select.form-control option {
    background-color: #1c1c1e; /* Dark matching theme */
    color: #0a84ff;
    padding: 12px;
    font-size: 15px;
    font-weight: 600;
}

select.form-control option:checked,
select.form-control option:hover,
select.form-control option:focus,
select.form-control option:active {
    background-color: #0a84ff !important;
    background: linear-gradient(#0a84ff, #0a84ff) !important;
    box-shadow: inset 0 0 10px 100px #0a84ff !important;
    -webkit-box-shadow: inset 0 0 10px 100px #0a84ff !important;
    color: #ffffff !important;
}

.form-row {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}
.form-row .form-group {
    flex: 1;
    min-width: 200px;
}

/* Buttons */
.btn {
    padding: 8px 18px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    text-align: center;
    letter-spacing: 0.3px;
}

.btn i { font-size: 16px; }

.btn-primary {
    background: var(--accent-color);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: scale(1.02);
}

.btn-danger {
    background: rgba(255, 69, 58, 0.15);
    color: var(--danger-color);
    border: 1px solid rgba(255, 69, 58, 0.3);
}

.btn-danger:hover {
    background: var(--danger-color);
    color: #fff;
}

.btn-success {
    background: rgba(50, 215, 75, 0.15);
    color: var(--success-color);
    border: 1px solid rgba(50, 215, 75, 0.3);
}

.btn-success:hover {
    background: var(--success-color);
    color: #fff;
}

.btn-warning {
    background: rgba(255, 214, 10, 0.15);
    color: var(--warning-color);
    border: 1px solid rgba(255, 214, 10, 0.3);
}

.btn-warning:hover {
    background: var(--warning-color);
    color: #000;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    margin: 0 2px;
    border-radius: 8px;
}

/* Copy Button */
.btn-copy {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    margin-inline-start: 6px;
}
.btn-copy:hover {
    background: rgba(255,255,255,0.2);
}

/* List Items (Modern alternatives to tables) */
.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    margin-bottom: 12px;
    transition: background 0.2s;
}
.list-item:hover {
    background: rgba(255, 255, 255, 0.06);
}
.list-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.list-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}
.list-meta {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}
.list-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.status-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    letter-spacing: 0.2px;
}

.status-active {
    background: rgba(50, 215, 75, 0.15);
    color: var(--success-color);
    border: 1px solid rgba(50, 215, 75, 0.3);
}

.status-banned {
    background: rgba(255, 69, 58, 0.15);
    color: var(--danger-color);
    border: 1px solid rgba(255, 69, 58, 0.3);
}

.code-box {
    font-family: 'SF Mono', Consolas, monospace;
    background: rgba(255, 255, 255, 0.08);
    padding: 4px 8px;
    border-radius: 6px;
    color: #5e5ce6;
    border: 1px solid var(--border-color);
    font-size: 12px;
    display: inline-block;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.table th, .table td {
    padding: 12px 15px;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 14px;
}

.table th {
    font-weight: 600;
    color: var(--text-secondary);
}

html[dir="ltr"] .table th, html[dir="ltr"] .table td {
    text-align: left;
}

/* Overview Cards */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.stat-card {
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: 18px;
    background: linear-gradient(145deg, rgba(35, 35, 38, 0.8) 0%, rgba(28, 28, 30, 0.6) 100%);
    backdrop-filter: blur(20px);
    position: relative;
    overflow: hidden;
}

.stat-icon {
    position: absolute;
    bottom: 10px;
    left: 15px;
    font-size: 75px;
    opacity: 1;
    pointer-events: none;
    transform: rotate(-10deg);
}
html[dir="ltr"] .stat-icon {
    left: auto;
    right: 15px;
}

.stat-card h3 {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

.stat-card h1 {
    font-size: 32px;
    margin-top: 8px;
    color: var(--text-primary);
    font-weight: 600;
    letter-spacing: -1px;
}

/* Mobile Responsiveness */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 99;
}

@media (max-width: 768px) {
    /* Main Content Adjustments */
    body {
        flex-direction: column;
    }
    
    .main-content {
        flex: 1;
        padding: 15px 15px 95px 15px; /* مسافة إضافية في الأسفل لضمان عدم تغطية المحتوى */
        overflow-y: auto;
    }

    /* Transform Sidebar into Bottom Nav */
    .sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        width: 100% !important;
        height: 60px; /* تقليل الارتفاع ليتناسب مع الأيقونات المصغرة */
        padding-bottom: env(safe-area-inset-bottom, 0px); /* مهم جداً للآيفون (حافة الشاشة) */
        flex-shrink: 0;
        flex-direction: row;
        border-inline-end: none;
        border-top: 1px solid var(--border-color);
        z-index: 1000;
        background: rgba(28, 28, 30, 0.95);
        backdrop-filter: saturate(180%) blur(25px);
        -webkit-backdrop-filter: saturate(180%) blur(25px);
        overflow: hidden;
    }

    .sidebar-header {
        display: none;
    }
    
    .user-profile-sidebar {
        display: none !important;
    }

    .sidebar-menu {
        display: flex;
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
        padding: 0;
        width: 100%;
        margin: 0;
        overflow-x: auto;
    }

    /* إخفاء الفواصل في الجوال */
    .sidebar-menu div {
        display: none !important;
    }

    .sidebar-text {
        display: none !important;
    }

    .sidebar-menu a {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        padding: 4px;
        margin: 0;
        border-radius: 10px;
        min-width: 55px;
        text-align: center;
        color: var(--text-secondary);
    }

    .sidebar-menu a i {
        margin: 0 !important;
        font-size: 28px !important; /* تكبير الأيقونات بعد إخفاء النص */
    }

    .sidebar-menu a.active {
        background: transparent !important;
        color: var(--accent-color) !important;
        box-shadow: none !important;
    }
    
    .sidebar-menu a.active i {
        color: var(--accent-color) !important;
    }

    .menu-toggle {
        display: none !important;
    }

    .overlay {
        display: none !important;
    }
    
    .stats-container {
        grid-template-columns: 1fr 1fr;
        gap: 10px; /* تقليل المسافة بين المربعات */
    }
    
    .stat-card {
        padding: 12px; /* تقليل الحشو الداخلي */
        border-radius: 12px; /* تقليل استدارة الزوايا لتناسب الحجم الصغير */
    }

    .stat-card h3 {
        font-size: 11px; /* تصغير عنوان الإحصائية */
        gap: 4px;
    }

    .stat-card h1 {
        font-size: 22px; /* تصغير الرقم الكبير */
        margin-top: 4px;
    }

    .stat-icon {
        font-size: 45px; /* تصغير الأيقونة الكبيرة في الخلفية */
        bottom: 5px;
        opacity: 0.6; /* تقليل الشفافية قليلاً كي لا تزعج القراءة في الحجم الصغير */
    }

    .card {
        padding: 15px; /* تصغير الحشو الداخلي للبطاقات العامة */
        border-radius: 14px;
        margin-bottom: 15px;
    }

    /* Table Adjustments for Mobile */
    .table th, .table td {
        padding: 8px; /* تقليل المسافات في الجداول بشكل أكبر */
        font-size: 11px; /* تصغير خط الجداول أكثر */
    }
    
    .top-bar h2 {
        font-size: 18px; /* تصغير عنوان الصفحة */
    }
}

@media (max-width: 600px) {
    .list-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    .list-actions {
        width: 100%;
        justify-content: flex-start;
    }
    .stats-container {
        grid-template-columns: 1fr;
    }
}