/* ============================================================
   app.css - نظام إدارة طلبات الشراء - دائرة البلدية
   ============================================================ */

:root {
    --primary:    #1565C0;
    --primary-d:  #0D47A1;
    --success:    #2E7D32;
    --warning:    #F57F17;
    --danger:     #C62828;
    --bg:         #F5F7FA;
    --surface:    #FFFFFF;
    --border:     #E0E0E0;
    --text:       #212121;
    --text-muted: #757575;
    --sidebar-w:  260px;
    --topbar-h:   60px;
}

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

body {
    font-family: 'Tajawal', sans-serif;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    text-align: right;
    font-size: 15px;
}

/* ══════════════════════════════════════
   تخطيط التطبيق الرئيسي
   ══════════════════════════════════════ */
.app-layout { display: flex; min-height: 100vh; }

/* ══════════════════════════════════════
   الشريط الجانبي
   ══════════════════════════════════════ */
.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, #0D47A1 0%, #1565C0 60%, #1976D2 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; right: 0;
    height: 100vh;
    z-index: 1000;
    box-shadow: -4px 0 20px rgba(0,0,0,.2);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    overflow-y: auto;
}

.sidebar-logo {
    padding: 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.15);
    text-align: center;
    flex-shrink: 0;
}
.sidebar-logo .logo-icon {
    width: 52px; height: 52px;
    background: rgba(255,255,255,.2);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 8px; font-size: 1.6rem;
}
.sidebar-logo h5 { font-size: .95rem; font-weight: 700; margin: 4px 0 2px; }
.sidebar-logo small { font-size: .72rem; opacity: .8; }

.sidebar-nav { flex: 1; padding: 10px 0; }
.nav-section-title {
    font-size: .67rem; font-weight: 600; letter-spacing: 1px;
    padding: 10px 20px 4px; opacity: .6; text-transform: uppercase;
}
.sidebar-nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 20px;
    color: rgba(255,255,255,.85);
    text-decoration: none;
    border-radius: 0 24px 24px 0;
    margin-left: 8px;
    transition: all .2s;
    font-size: .9rem;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
    background: rgba(255,255,255,.18);
    color: #fff;
}
.sidebar-nav a .nav-icon { font-size: 1.1rem; min-width: 24px; text-align: center; }
.sidebar-nav .badge-count {
    margin-right: auto;
    background: #FF5722; color: #fff;
    font-size: .68rem; padding: 2px 7px;
    border-radius: 10px; font-weight: 700;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,.15);
    font-size: .78rem; opacity: .7; flex-shrink: 0;
}

/* ══════════════════════════════════════
   المحتوى الرئيسي
   ══════════════════════════════════════ */
.main-content {
    margin-right: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}

/* ══════════════════════════════════════
   شريط التطبيق العلوي
   ══════════════════════════════════════ */
.top-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky; top: 0; z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.page-title { font-weight: 700; font-size: 1rem; flex: 1; }
.top-user-info { display: flex; align-items: center; gap: 10px; }
.top-user-text { text-align: right; }

/* زر القائمة - مخفي على الكمبيوتر */
.menu-toggle-btn {
    display: none;
    align-items: center; justify-content: center;
    width: 40px; height: 40px;
    background: var(--primary);
    border: none; border-radius: 8px;
    color: #fff; font-size: 1.3rem;
    cursor: pointer; flex-shrink: 0;
}

.user-avatar {
    width: 36px; height: 36px;
    background: var(--primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: .9rem;
    flex-shrink: 0;
}

/* Overlay الجانبي */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 999;
}

/* ══════════════════════════════════════
   منطقة المحتوى
   ══════════════════════════════════════ */
.content-area { padding: 20px; flex: 1; }

/* ══════════════════════════════════════
   البطاقات
   ══════════════════════════════════════ */
.card {
    background: var(--surface);
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
    margin-bottom: 18px;
    overflow: hidden;
}
.card-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 10px;
    font-weight: 600; font-size: .95rem;
}
.card-body { padding: 18px; }
.p-0 { padding: 0 !important; }

/* ══════════════════════════════════════
   بطاقات الإحصاءات
   ══════════════════════════════════════ */
.stat-card {
    background: var(--surface);
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 18px;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
    transition: transform .2s, box-shadow .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.1); }
.stat-card .stat-icon {
    width: 44px; height: 44px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; margin-bottom: 10px;
}
.stat-card .stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1.1; }
.stat-card .stat-label { color: var(--text-muted); font-size: .82rem; margin-top: 4px; }

/* ══════════════════════════════════════
   الأزرار
   ══════════════════════════════════════ */
.btn {
    padding: 8px 18px; border-radius: 8px;
    font-family: 'Tajawal', sans-serif;
    font-weight: 500; cursor: pointer;
    border: none; transition: all .2s;
    display: inline-flex; align-items: center; gap: 6px;
    font-size: .9rem; white-space: nowrap;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary   { background: var(--primary);  color: #fff; }
.btn-primary:hover:not(:disabled)   { background: var(--primary-d); transform: translateY(-1px); }
.btn-success   { background: #2E7D32; color: #fff; }
.btn-success:hover:not(:disabled)   { background: #1B5E20; }
.btn-danger    { background: #C62828; color: #fff; }
.btn-danger:hover:not(:disabled)    { background: #B71C1C; }
.btn-warning   { background: #F57F17; color: #fff; }
.btn-secondary { background: #ECEFF1; color: #546E7A; }
.btn-secondary:hover:not(:disabled) { background: #CFD8DC; }
.btn-outline   { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-sm  { padding: 5px 12px; font-size: .82rem; }
.btn-lg  { padding: 11px 26px; font-size: .95rem; }

/* ══════════════════════════════════════
   حقول الإدخال
   ══════════════════════════════════════ */
.form-group { margin-bottom: 14px; }
.form-label { font-weight: 500; font-size: .88rem; margin-bottom: 5px; display: block; }
.form-control {
    width: 100%; padding: 9px 12px;
    border: 1.5px solid var(--border); border-radius: 8px;
    font-family: 'Tajawal', sans-serif; font-size: 15px;
    background: var(--surface); transition: border-color .2s, box-shadow .2s;
    direction: rtl; color: var(--text);
}
.form-control:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(21,101,192,.12);
}
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ══════════════════════════════════════
   الجداول
   ══════════════════════════════════════ */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th {
    background: #F5F7FA; padding: 11px 14px;
    font-weight: 600; color: #546E7A;
    border-bottom: 2px solid var(--border);
    white-space: nowrap; text-align: right;
}
tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
tbody tr:hover { background: #FAFBFC; }
tbody tr:last-child td { border-bottom: none; }

/* ══════════════════════════════════════
   الشارات
   ══════════════════════════════════════ */
.badge {
    padding: 3px 10px; border-radius: 20px;
    font-size: .74rem; font-weight: 600;
    display: inline-block; white-space: nowrap;
}
.badge-primary   { background: #E3F2FD; color: #1565C0; }
.badge-success   { background: #E8F5E9; color: #2E7D32; }
.badge-danger    { background: #FFEBEE; color: #C62828; }
.badge-warning   { background: #FFF3E0; color: #E65100; }
.badge-info      { background: #E1F5FE; color: #0277BD; }
.badge-secondary { background: #ECEFF1; color: #546E7A; }

/* ══════════════════════════════════════
   شريط التقدم (مراحل الطلب)
   ══════════════════════════════════════ */
.steps-bar {
    display: flex; align-items: flex-start;
    overflow-x: auto; padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
}
.step-item {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    position: relative; min-width: 90px;
}
.step-item:not(:last-child)::after {
    content: ''; position: absolute;
    top: 17px; left: -50%; width: 100%; height: 2px;
    background: #E0E0E0; z-index: 0;
}
.step-item.done::after  { background: var(--success); }
.step-item.active::after { background: var(--primary); }
.step-circle {
    width: 34px; height: 34px; border-radius: 50%;
    border: 2px solid #E0E0E0; background: #fff; z-index: 1;
    display: flex; align-items: center; justify-content: center;
    font-size: .82rem; font-weight: 700;
}
.step-item.done  .step-circle { background: var(--success); border-color: var(--success); color: #fff; }
.step-item.active .step-circle {
    background: var(--primary); border-color: var(--primary); color: #fff;
    box-shadow: 0 0 0 4px rgba(21,101,192,.2);
}
.step-label { font-size: .68rem; margin-top: 6px; text-align: center; color: var(--text-muted); }
.step-item.active .step-label { color: var(--primary); font-weight: 600; }
.step-item.done  .step-label  { color: var(--success); }

/* ══════════════════════════════════════
   Timeline (سجل الموافقات)
   ══════════════════════════════════════ */
.timeline { position: relative; padding: 8px 0; }
.timeline::before {
    content: ''; position: absolute;
    right: 17px; top: 0; bottom: 0; width: 2px;
    background: var(--border);
}
.timeline-item { display: flex; gap: 14px; margin-bottom: 18px; position: relative; }
.timeline-icon {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; z-index: 1; font-size: .85rem;
}
.timeline-body {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 10px 14px; flex: 1; min-width: 0;
}
.timeline-body .meta { font-size: .76rem; color: var(--text-muted); margin-bottom: 3px; }

/* ══════════════════════════════════════
   الإشعارات
   ══════════════════════════════════════ */
.notification-item {
    padding: 12px 16px; border-bottom: 1px solid var(--border);
    cursor: pointer; transition: background .15s;
    display: flex; gap: 12px; align-items: flex-start;
}
.notification-item:hover { background: #F9FAFB; }
.notification-item.unread { background: #F0F4FF; border-right: 3px solid var(--primary); }
.notif-icon {
    width: 36px; height: 36px; border-radius: 50%;
    background: #EEF2FF; color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; font-size: .95rem;
}

/* ══════════════════════════════════════
   صفحة تسجيل الدخول
   ══════════════════════════════════════ */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #0D47A1 0%, #1976D2 50%, #42A5F5 100%);
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}
.login-card {
    background: #fff; border-radius: 18px;
    padding: 36px 32px; width: 100%; max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo .logo-circle {
    width: 76px; height: 76px; border-radius: 50%;
    background: linear-gradient(135deg, #1565C0, #42A5F5);
    margin: 0 auto 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem;
}
.login-logo h4 { font-weight: 700; color: var(--primary); font-size: 1.2rem; }
.login-logo p  { color: var(--text-muted); font-size: .84rem; margin-top: 4px; }

/* ══════════════════════════════════════
   إضافة عنصر للشبكة
   ══════════════════════════════════════ */
.row { display: flex; flex-wrap: wrap; margin: 0 -8px; }
.row.g-2 { gap: 8px; margin: 0; }
.row.g-3 { gap: 12px; margin: 0; }
.col-6   { flex: 0 0 calc(50% - 6px); }
.col-12  { flex: 0 0 100%; }
.col-md-1, .col-md-2, .col-md-3, .col-md-4,
.col-md-6, .col-lg-5, .col-lg-6, .col-lg-7 { flex: 0 0 100%; }

/* ══════════════════════════════════════
   Animations
   ══════════════════════════════════════ */
@keyframes fadeIn { from { opacity:0; transform:translateY(6px) } to { opacity:1; transform:none } }
.fade-in { animation: fadeIn .25s ease; }

/* ══════════════════════════════════════
   Scrollbar
   ══════════════════════════════════════ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: #F5F7FA; }
::-webkit-scrollbar-thumb { background: #BDBDBD; border-radius: 3px; }

/* ══════════════════════════════════════
   طباعة
   ══════════════════════════════════════ */
@media print {
    .sidebar, .top-bar, .no-print, .menu-toggle-btn { display: none !important; }
    .main-content { margin: 0 !important; }
    .card { box-shadow: none; border: 1px solid #ccc; }
}

/* ══════════════════════════════════════
   شاشات كبيرة (Desktop) - md breakpoint
   ══════════════════════════════════════ */
@media (min-width: 769px) {
    .menu-toggle-btn { display: none !important; }
    .sidebar-overlay { display: none !important; }

    .col-md-1 { flex: 0 0 calc(8.33% - 6px); }
    .col-md-2 { flex: 0 0 calc(16.66% - 6px); }
    .col-md-3 { flex: 0 0 calc(25% - 6px); }
    .col-md-4 { flex: 0 0 calc(33.33% - 6px); }
    .col-md-6 { flex: 0 0 calc(50% - 6px); }
}

@media (min-width: 992px) {
    .col-lg-5 { flex: 0 0 calc(41.66% - 6px); }
    .col-lg-6 { flex: 0 0 calc(50% - 6px); }
    .col-lg-7 { flex: 0 0 calc(58.33% - 6px); }
}

/* ══════════════════════════════════════
   موبايل (Mobile) - max 768px
   ══════════════════════════════════════ */
@media (max-width: 768px) {
    /* إخفاء الشريط الجانبي وإزاحة المحتوى */
    .sidebar {
        transform: translateX(100%);
        width: 280px;
        z-index: 2000;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: -8px 0 40px rgba(0,0,0,.4);
    }
    .sidebar-overlay { z-index: 1999; }

    .main-content { margin-right: 0 !important; }

    /* إظهار زر القائمة */
    .menu-toggle-btn { display: flex !important; }

    /* ضبط شريط التطبيق */
    .top-bar { padding: 0 12px; gap: 10px; height: 54px; }
    .page-title { font-size: .88rem; }
    .top-user-text { display: none; }

    /* منطقة المحتوى */
    .content-area { padding: 10px; }

    /* البطاقات */
    .card-body { padding: 12px; }
    .card-header { padding: 11px 14px; font-size: .88rem; }

    /* بطاقات الإحصاءات */
    .stat-card { padding: 14px 12px; }
    .stat-card .stat-value { font-size: 1.5rem; }
    .stat-card .stat-icon { width: 38px; height: 38px; font-size: 1.1rem; }

    /* الشبكة على الموبايل */
    .row.g-3 > .col-md-2,
    .row.g-3 > .col-md-3,
    .row.g-3 > .col-md-4,
    .row.g-3 > .col-md-6,
    .row.g-3 > .col-lg-5,
    .row.g-3 > .col-lg-6,
    .row.g-3 > .col-lg-7 { flex: 0 0 100%; }

    /* الجداول */
    thead th { padding: 9px 10px; font-size: .8rem; }
    tbody td  { padding: 9px 10px; font-size: .82rem; }

    /* إخفاء أعمدة غير ضرورية في الموبايل */
    .hide-mobile { display: none !important; }

    /* أزرار */
    .btn { font-size: .85rem; padding: 8px 14px; }
    .btn-lg { padding: 10px 20px; font-size: .92rem; }

    /* نموذج تسجيل الدخول */
    .login-card { padding: 28px 18px; border-radius: 14px; }
    .login-logo .logo-circle { width: 64px; height: 64px; font-size: 1.7rem; }

    /* حقول الإدخال - منع zoom في iOS */
    .form-control { font-size: 16px !important; }

    /* شريط التقدم */
    .step-item { min-width: 72px; }
    .step-circle { width: 30px; height: 30px; font-size: .76rem; }
    .step-label { font-size: .62rem; }

    /* التطبيق عند إضافته للشاشة الرئيسية */
    @media (display-mode: standalone) {
        .top-bar { padding-top: env(safe-area-inset-top, 0); }
    }
}

@media (max-width: 400px) {
    .content-area { padding: 8px; }
    .stat-card .stat-value { font-size: 1.3rem; }
    .page-title { font-size: .82rem; }
}
