/* =====================================================
   منصة إدارة الشركات - التصميم الرئيسي
   هوية: كحلي عميق + ذهبي + رمادي ناعم | RTL
   ===================================================== */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;800&display=swap');

:root {
    --navy:        #0f2942;
    --navy-light:  #1b3a5c;
    --navy-dark:   #0a1e30;
    --gold:        #c9a227;
    --gold-light:  #e0bd45;
    --bg:          #f4f6f9;
    --surface:     #ffffff;
    --border:      #e2e8f0;
    --text:        #1a202c;
    --text-muted:  #64748b;
    --success:     #16a34a;
    --warning:     #d97706;
    --danger:      #dc2626;
    --radius:      14px;
    --shadow:      0 1px 3px rgba(15,41,66,.08), 0 8px 24px rgba(15,41,66,.06);
    --shadow-lg:   0 12px 40px rgba(15,41,66,.12);
}

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

body {
    font-family: 'Tajawal', sans-serif;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ===== التخطيط ===== */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 270px;
    background: linear-gradient(180deg, var(--navy) 0%, var(--navy-dark) 100%);
    color: #cbd5e1;
    position: fixed;
    top: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar-brand {
    padding: 26px 24px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    gap: 12px;
}
.sidebar-brand .logo {
    width: 42px; height: 42px;
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    border-radius: 11px;
    display: grid; place-items: center;
    font-weight: 800; color: var(--navy-dark);
    font-size: 20px;
}
.sidebar-brand h1 { font-size: 17px; color: #fff; font-weight: 700; }
.sidebar-brand span { font-size: 11px; color: var(--gold-light); }

.nav { padding: 16px 12px; flex: 1; overflow-y: auto; }
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; border-radius: 10px;
    color: #94a3b8; font-weight: 500; font-size: 15px;
    margin-bottom: 4px; transition: all .18s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--gold); color: var(--navy-dark); font-weight: 700; }
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,.08);
    font-size: 13px;
}
.sidebar-footer a { color: var(--gold-light); }

.main {
    margin-right: 270px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky; top: 0; z-index: 50;
}
.topbar h2 { font-size: 20px; font-weight: 700; color: var(--navy); }
.topbar-user { display: flex; align-items: center; gap: 14px; font-size: 14px; }
.topbar-user .avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--navy); color: #fff;
    display: grid; place-items: center; font-weight: 700;
}

.content { padding: 32px; flex: 1; }

/* ===== البطاقات ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-head {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.card-head h3 { font-size: 17px; font-weight: 700; color: var(--navy); }
.card-body { padding: 24px; }

/* ===== شبكة الإحصائيات ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: ''; position: absolute; top: 0; right: 0;
    width: 4px; height: 100%; background: var(--gold);
}
.stat-card .label { font-size: 14px; color: var(--text-muted); margin-bottom: 8px; }
.stat-card .value { font-size: 32px; font-weight: 800; color: var(--navy); }
.stat-card .sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.stat-card.danger::before  { background: var(--danger); }
.stat-card.warning::before { background: var(--warning); }
.stat-card.success::before { background: var(--success); }

/* ===== الجداول ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
    text-align: right; padding: 14px 16px;
    font-size: 13px; font-weight: 700; color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
td {
    padding: 15px 16px; font-size: 14px;
    border-bottom: 1px solid var(--border);
}
tbody tr { transition: background .15s; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }

/* ===== الشارات ===== */
.badge {
    display: inline-block; padding: 4px 12px;
    border-radius: 20px; font-size: 12px; font-weight: 700;
    white-space: nowrap;
}
.badge-success  { background: #dcfce7; color: #15803d; }
.badge-warning  { background: #fef3c7; color: #b45309; }
.badge-danger   { background: #fee2e2; color: #b91c1c; }
.badge-muted    { background: #f1f5f9; color: #64748b; }
.badge-platinum { background: linear-gradient(135deg,#e2e8f0,#cbd5e1); color: #334155; }
.badge-info     { background: #dbeafe; color: #1d4ed8; }

/* ===== الأزرار ===== */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 11px 22px; border-radius: 10px;
    font-family: inherit; font-size: 14px; font-weight: 700;
    border: none; cursor: pointer; transition: all .18s;
}
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-light); transform: translateY(-1px); }
.btn-gold { background: var(--gold); color: var(--navy-dark); }
.btn-gold:hover { background: var(--gold-light); transform: translateY(-1px); }
.btn-light { background: #f1f5f9; color: var(--navy); }
.btn-light:hover { background: #e2e8f0; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 7px 14px; font-size: 13px; }

/* ===== النماذج ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-group { display: flex; flex-direction: column; gap: 7px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 14px; font-weight: 600; color: var(--navy); }
input, select, textarea {
    font-family: inherit; font-size: 14px;
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px; background: #fff;
    transition: border .18s;
    width: 100%;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(201,162,39,.12);
}
textarea { resize: vertical; min-height: 90px; }

/* ===== خط المراحل (Stepper) ===== */
.stepper { display: flex; gap: 0; margin: 8px 0 28px; }
.step {
    flex: 1; text-align: center; position: relative;
    padding-top: 40px;
}
.step::before {
    content: ''; position: absolute; top: 14px; right: 50%;
    width: 100%; height: 3px; background: var(--border);
}
.step:last-child::before { display: none; }
.step .dot {
    position: absolute; top: 0; right: 50%;
    transform: translateX(50%);
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--border); color: #fff;
    display: grid; place-items: center;
    font-weight: 700; font-size: 14px; z-index: 2;
}
.step.done .dot   { background: var(--success); }
.step.done::before{ background: var(--success); }
.step.current .dot{ background: var(--gold); color: var(--navy-dark); box-shadow: 0 0 0 5px rgba(201,162,39,.2); }
.step .step-label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.step.current .step-label { color: var(--navy); font-weight: 700; }

/* ===== التنبيهات ===== */
.flash {
    padding: 14px 20px; border-radius: 10px;
    margin-bottom: 22px; font-weight: 600; font-size: 14px;
}
.flash-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.flash-error   { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }

.alert-row {
    display: flex; align-items: center; gap: 14px;
    padding: 14px 18px; border-radius: 10px;
    margin-bottom: 10px; background: #fff;
    border: 1px solid var(--border);
    border-right: 4px solid var(--warning);
}
.alert-row.critical { border-right-color: var(--danger); }
.alert-row .alert-icon {
    width: 38px; height: 38px; border-radius: 9px;
    display: grid; place-items: center; flex-shrink: 0;
    background: #fef3c7; color: var(--warning);
}
.alert-row.critical .alert-icon { background: #fee2e2; color: var(--danger); }
.alert-row .alert-body { flex: 1; }
.alert-row .alert-title { font-weight: 700; font-size: 14px; }
.alert-row .alert-meta { font-size: 12px; color: var(--text-muted); }

/* ===== صفحة الدخول ===== */
.login-page {
    min-height: 100vh;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 100%);
    padding: 20px;
}
.login-card {
    background: #fff; border-radius: 20px;
    box-shadow: var(--shadow-lg);
    width: 100%; max-width: 410px;
    padding: 44px 40px;
}
.login-card .logo-big {
    width: 64px; height: 64px; margin: 0 auto 20px;
    background: linear-gradient(135deg, var(--gold), var(--gold-light));
    border-radius: 16px; display: grid; place-items: center;
    font-size: 30px; font-weight: 800; color: var(--navy-dark);
}
.login-card h1 { text-align: center; font-size: 22px; color: var(--navy); margin-bottom: 6px; }
.login-card .subtitle { text-align: center; color: var(--text-muted); font-size: 14px; margin-bottom: 30px; }
.login-card .form-group { margin-bottom: 18px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 8px; }

/* ===== مساعدات ===== */
.flex { display: flex; align-items: center; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.between { justify-content: space-between; }
.mb-0 { margin-bottom: 0; } .mb-20 { margin-bottom: 20px; } .mb-28 { margin-bottom: 28px; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.page-actions { display: flex; gap: 12px; align-items: center; }
.empty {
    text-align: center; padding: 50px 20px; color: var(--text-muted);
}
.empty svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: .4; }

.section-title {
    font-size: 15px; font-weight: 700; color: var(--navy);
    margin: 28px 0 14px; padding-right: 12px;
    border-right: 3px solid var(--gold);
}

@media (max-width: 880px) {
    .sidebar { transform: translateX(100%); transition: transform .3s; }
    .sidebar.open { transform: translateX(0); }
    .main { margin-right: 0; }
    .form-grid { grid-template-columns: 1fr; }
    .content { padding: 18px; }
}
