/* ===== الخطوط ===== */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', 'Tahoma', sans-serif;
    background: #f0f2f5;
    color: #333;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== القائمة الجانبية (في الكمبيوتر) ===== */
.sidebar {
    width: 260px;
    background: #1a2332;
    color: #fff;
    height: 100vh;
    position: fixed;
    right: 0;
    top: 0;
    overflow-y: auto;
    padding: 0;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    z-index: 1000;
    transition: all 0.3s ease;
}

/* ===== تنسيق اللوجو (مكبر جداً 200px) ===== */
.sidebar .logo {
    text-align: center;
    padding: 6px 15px 4px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.sidebar .logo img {
    max-width: 200px;
    width: 200px;
    height: auto;
    border-radius: 12px;
    display: block;
}

.sidebar .logo h2 {
    font-size: 20px;
    font-weight: 700;
    color: #f5b041;
    margin: 0;
}

.sidebar .logo p {
    font-size: 12px;
    color: #8899aa;
    margin: 0;
}

/* ===== القائمة (رفعها للأعلى) ===== */
.sidebar nav {
    padding: 4px 10px 15px;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 16px;
    color: #b0bec5;
    text-decoration: none;
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.3s;
    margin: 1px 0;
}

.sidebar nav a:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.sidebar nav a i {
    width: 20px;
    text-align: center;
}

.sidebar nav a.active {
    background: #2d8c3c;
    color: #fff;
}

/* ===== المحتوى الرئيسي (في الكمبيوتر) ===== */
.main-content {
    margin-right: 260px;
    flex: 1;
    padding: 25px 30px;
    min-height: 100vh;
    width: calc(100% - 260px);
}

/* ===== باقي التنسيقات ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    position: relative;
    transition: all 0.3s;
    border-right: 4px solid #2d8c3c;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.08);
}

.stat-card .label {
    font-size: 14px;
    color: #8899aa;
    font-weight: 600;
}

.stat-card .value {
    font-size: 28px;
    font-weight: 700;
    color: #1a2332;
    margin: 8px 0;
}

.stat-card .sub {
    font-size: 12px;
    color: #8899aa;
    background: #f0f2f5;
    padding: 3px 12px;
    border-radius: 20px;
    display: inline-block;
    cursor: pointer;
}

.stat-card .icon {
    position: absolute;
    left: 15px;
    top: 15px;
    font-size: 30px;
    opacity: 0.10;
}

.stat-card.green { border-right-color: #2d8c3c; }
.stat-card.blue { border-right-color: #2980b9; }
.stat-card.orange { border-right-color: #f5b041; }
.stat-card.red { border-right-color: #e74c3c; }
.stat-card.purple { border-right-color: #8e44ad; }

.btn {
    display: inline-block;
    padding: 10px 22px;
    border: none;
    border-radius: 8px;
    font-family: 'Cairo', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s;
}

.btn-primary { background: #2980b9; color: #fff; }
.btn-primary:hover { background: #1f618d; transform: scale(1.03); }

.btn-success { background: #2d8c3c; color: #fff; }
.btn-success:hover { background: #1e6b2b; transform: scale(1.03); }

.btn-danger { background: #e74c3c; color: #fff; }
.btn-danger:hover { background: #c0392b; transform: scale(1.03); }

.btn-warning { background: #f5b041; color: #fff; }
.btn-warning:hover { background: #d68910; transform: scale(1.03); }

.btn-outline { background: transparent; color: #1a2332; border: 2px solid #ddd; }
.btn-outline:hover { background: #f5f5f5; border-color: #aaa; }

.btn-sm { 
    padding: 6px 14px; 
    font-size: 12px; 
    border-radius: 6px;
    min-width: unset;
    width: auto;
}

/* ===== تنسيق الأزرار الصغيرة في الموبايل ===== */
@media (max-width: 768px) {
    .btn-sm {
        padding: 4px 10px !important;
        font-size: 11px !important;
        border-radius: 5px !important;
        min-width: unset !important;
        width: auto !important;
        display: inline-block !important;
        margin: 2px !important;
    }
    
    /* الأزرار في عمود الإجراءات */
    table td .btn-sm {
        padding: 4px 8px !important;
        font-size: 10px !important;
        border-radius: 4px !important;
        margin: 1px 2px !important;
    }
    
    /* صف الأزرار في الموبايل */
    table td div {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 3px !important;
        justify-content: center !important;
        align-items: center !important;
    }
}

@media (max-width: 480px) {
    .btn-sm {
        padding: 3px 7px !important;
        font-size: 9px !important;
        border-radius: 4px !important;
    }
    
    table td .btn-sm {
        padding: 3px 6px !important;
        font-size: 9px !important;
    }
}

.table-container {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    overflow-x: auto;
    margin-top: 25px;
}

.table-container h3 {
    margin-bottom: 15px;
    color: #1a2332;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 600px;
}

table thead {
    background: #f8f9fa;
}

table th {
    padding: 12px 16px;
    text-align: center;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid #eee;
}

table td {
    padding: 12px 16px;
    text-align: center;
    border-bottom: 1px solid #f0f0f0;
}

table tbody tr:hover {
    background: #f8f9fa;
}

.alert {
    padding: 14px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.alert-success {
    background: #e8f5e9;
    color: #1e6b2b;
    border-right: 4px solid #2d8c3c;
}

.alert-danger {
    background: #fdecea;
    color: #a93226;
    border-right: 4px solid #e74c3c;
}

.filter-form {
    background: #fff;
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 20px;
}

.filter-form input,
.filter-form select {
    padding: 8px 14px;
    border: 2px solid #e8ecf0;
    border-radius: 8px;
    font-family: 'Cairo', sans-serif;
    font-size: 14px;
    background: #fafbfc;
}

.filter-form input:focus,
.filter-form select:focus {
    outline: none;
    border-color: #2d8c3c;
}

.download-box {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 2px dashed #ddd;
    margin: 20px 0;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.page-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: #1a2332;
}

/* =================================================
   تنسيق الموبايل (المعدل - مع تكبير اللوجو)
   ================================================= */
@media (max-width: 768px) {
    /* ===== إلغاء الفلكس القديم ===== */
    body {
        display: block;
        flex-direction: unset;
    }

    /* ===== السايد بار ===== */
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        padding: 6px 10px;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        box-shadow: 0 2px 10px rgba(0,0,0,0.15);
        border-radius: 0;
        overflow-y: visible;
    }

    /* ===== تنسيق اللوجو في الموبايل (مكبر) ===== */
    .sidebar .logo {
        flex-direction: row;
        gap: 8px;
        padding: 0;
        border-bottom: none;
        width: auto;
    }

    .sidebar .logo img {
        max-width: 90px !important;
        width: 90px !important;
        height: auto;
    }

    .sidebar .logo h2 {
        font-size: 18px;
        margin: 0;
    }

    .sidebar .logo p {
        display: none;
    }

    .sidebar nav {
        padding: 4px 0 0 0;
        display: flex;
        flex-wrap: wrap;
        gap: 3px;
        justify-content: flex-start;
        width: 100%;
        border-top: 1px solid rgba(255,255,255,0.05);
        margin-top: 4px;
    }

    .sidebar nav a {
        padding: 5px 10px;
        font-size: 12px;
        margin: 1px;
        border-radius: 20px;
        background: rgba(255,255,255,0.05);
        gap: 5px;
        flex: 0 0 auto;
    }

    .sidebar nav a i {
        font-size: 14px;
        width: auto;
    }

    .sidebar nav a span {
        font-size: 11px;
        display: inline-block;
    }

    .sidebar nav a.active {
        background: #2d8c3c;
    }

    /* ===== المحتوى ===== */
    .main-content {
        margin-right: 0;
        padding: 12px;
        width: 100%;
        display: block;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .stat-card {
        padding: 12px;
    }

    .stat-card .value {
        font-size: 18px;
    }

    .stat-card .icon {
        font-size: 20px;
        opacity: 0.08;
    }

    .filter-form {
        flex-direction: column;
        align-items: stretch;
        padding: 12px;
    }

    .filter-form input,
    .filter-form select {
        width: 100% !important;
        min-width: unset;
    }

    .table-container {
        padding: 8px;
        overflow-x: auto;
    }

    table {
        font-size: 11px;
        min-width: 450px;
    }

    table th,
    table td {
        padding: 6px 8px;
    }

    .download-box {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }

    .btn {
        padding: 6px 14px;
        font-size: 12px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .page-header .btn {
        width: auto;
    }
}

@media (max-width: 480px) {
    .sidebar {
        padding: 4px 6px;
    }

    .sidebar .logo img {
        max-width: 70px !important;
        width: 70px !important;
    }

    .sidebar .logo h2 {
        font-size: 15px;
    }

    .sidebar nav a {
        padding: 4px 7px;
        font-size: 10px;
        gap: 3px;
    }

    .sidebar nav a span {
        font-size: 9px;
    }

    .sidebar nav a i {
        font-size: 12px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .main-content {
        padding: 8px;
    }

    table {
        font-size: 10px;
        min-width: 300px;
    }

    table th,
    table td {
        padding: 4px 6px;
    }

    .btn {
        padding: 5px 10px;
        font-size: 11px;
    }

    .stat-card .value {
        font-size: 16px;
    }

    .filter-form {
        padding: 8px;
    }
}