/* ===== الخطوط ===== */
@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: #faf6f0;
    color: #3a2a1e;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== القائمة الجانبية ===== */
.sidebar {
    width: 260px;
    background: #2b1d14;
    color: #e0d5c5;
    height: 100vh;
    position: fixed;
    right: 0;
    top: 0;
    overflow-y: auto;
    padding: 0;
    box-shadow: 2px 0 10px rgba(0,0,0,0.2);
    z-index: 1000;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar .logo {
    text-align: center;
    padding: 10px 15px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.sidebar .logo img {
    max-width: 180px;
    width: 180px;
    height: auto;
    border-radius: 12px;
    display: block;
}

.sidebar .logo h2 {
    font-size: 18px;
    font-weight: 700;
    color: #e8d5b7;
    margin: 0;
}

.sidebar .logo p {
    font-size: 12px;
    color: #a8917a;
    margin: 0;
}

.sidebar nav {
    padding: 4px 10px 15px;
    flex: 1;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 16px;
    color: #d4c4b0;
    text-decoration: none;
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.3s;
    margin: 1px 0;
}

.sidebar nav a:hover {
    background: rgba(232,213,183,0.15);
    color: #fff;
}

.sidebar nav a i {
    width: 20px;
    text-align: center;
}

.sidebar nav a.active {
    background: #8b5e3c;
    color: #fff;
}

/* ===== بيانات المستخدم ===== */
.user-box {
    padding: 12px 15px;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #e8d5b7;
    font-size: 14px;
    font-weight: 600;
}

.user-info i {
    font-size: 20px;
    color: #e8d5b7;
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    background: #8e5749;
    color: #fff;
    padding: 6px 12px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.3s;
}

.logout-btn:hover {
    background: #a86a5c;
}

/* ===== بيانات المطور ===== */
.dev-credit {
    padding: 12px 15px;
    text-align: center;
    color: #a8917a;
    font-size: 12px;
    line-height: 1.7;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.dev-credit strong {
    color: #e8d5b7;
}

/* ===== المحتوى الرئيسي ===== */
.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: #fffdf9;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(139,94,60,0.08);
    position: relative;
    transition: all 0.3s;
    border-right: 4px solid #8b5e3c;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(139,94,60,0.15);
}

.stat-card .label {
    font-size: 14px;
    color: #a8917a;
    font-weight: 600;
}

.stat-card .value {
    font-size: 28px;
    font-weight: 700;
    color: #2b1d14;
    margin: 8px 0;
}

.stat-card .sub {
    font-size: 12px;
    color: #a8917a;
    background: #f5f0e8;
    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;
    color: #2b1d14;
}

.stat-card.green { border-right-color: #a67c52; }
.stat-card.blue { border-right-color: #6b8299; }
.stat-card.orange { border-right-color: #d4a24a; }
.stat-card.red { border-right-color: #8e5749; }
.stat-card.purple { border-right-color: #8b5e3c; }

/* ===== الأزرار ===== */
.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: #8b5e3c; color: #fff; }
.btn-primary:hover { background: #6f4e37; transform: scale(1.03); }

/* حفظ / إضافة - بني غامق دافي */
.btn-success { background: #a67c52; color: #fff; }
.btn-success:hover { background: #8b6540; transform: scale(1.03); }

/* حذف - تراكوتا غامق */
.btn-danger { background: #8e5749; color: #fff; }
.btn-danger:hover { background: #a86a5c; transform: scale(1.03); }

/* تعديل - بيج فاتح جداً مع نص بني غامق */
.btn-warning { background: #e8d5b7; color: #2b1d14; }
.btn-warning:hover { background: #d9c19a; transform: scale(1.03); }

/* إلغاء - فاضي بحدود */
.btn-outline { background: transparent; color: #2b1d14; border: 2px solid #d4c4b0; }
.btn-outline:hover { background: #f5f0e8; border-color: #8b5e3c; }

.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: #fffdf9;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(139,94,60,0.08);
    overflow-x: auto;
    margin-top: 25px;
}

.table-container h3 {
    margin-bottom: 15px;
    color: #2b1d14;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 600px;
}

table thead {
    background: #f5f0e8;
}

table th {
    padding: 12px 16px;
    text-align: center;
    font-weight: 600;
    color: #4a3424;
    border-bottom: 2px solid #e0d5c5;
}

table td {
    padding: 12px 16px;
    text-align: center;
    border-bottom: 1px solid #f0e8dc;
    color: #3a2a1e;
}

table tbody tr:hover {
    background: #faf6f0;
}

/* ===== التنبيهات ===== */
.alert {
    padding: 14px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.alert-success {
    background: #faf3e8;
    color: #8b6540;
    border-right: 4px solid #a67c52;
}

.alert-danger {
    background: #f5ece9;
    color: #8e5749;
    border-right: 4px solid #8e5749;
}

/* ===== الفلاتر ===== */
.filter-form {
    background: #fffdf9;
    padding: 15px 20px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(139,94,60,0.08);
    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 #e0d5c5;
    border-radius: 8px;
    font-family: 'Cairo', sans-serif;
    font-size: 14px;
    background: #faf6f0;
    color: #3a2a1e;
}

.filter-form input:focus,
.filter-form select:focus {
    outline: none;
    border-color: #8b5e3c;
    background: #fffdf9;
}

/* ===== صندوق التحميل ===== */
.download-box {
    background: #fffdf9;
    padding: 20px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 2px dashed #d4c4b0;
    margin: 20px 0;
    color: #4a3424;
}

/* ===== رأس الصفحة ===== */
.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: #2b1d14;
}

/* =================================================
   تنسيق الموبايل
   ================================================= */
@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.2);
        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: 80px !important;
        width: 80px !important;
        height: auto;
    }

    .sidebar .logo h2 {
        font-size: 16px;
        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(232,213,183,0.1);
        gap: 5px;
        flex: 0 0 auto;
        color: #d4c4b0;
    }

    .sidebar nav a i {
        font-size: 14px;
        width: auto;
    }

    .sidebar nav a span {
        font-size: 11px;
        display: inline-block;
    }

    .sidebar nav a.active {
        background: #8b5e3c;
        color: #fff;
    }

    .user-box {
        width: 100%;
        justify-content: center;
        border-top: 1px solid rgba(255,255,255,0.08);
        padding: 8px 10px;
    }

    .dev-credit {
        width: 100%;
        padding: 8px 10px;
        font-size: 11px;
    }

    .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: 65px !important;
        width: 65px !important;
    }

    .sidebar .logo h2 {
        font-size: 14px;
    }

    .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;
    }

    .user-info {
        font-size: 12px;
    }

    .logout-btn {
        padding: 5px 10px;
        font-size: 11px;
    }
}