/* ==================================================================
   نظام إدارة مهام الموارد البشرية — هوية AdEC
   ================================================================== */

:root {
    --purple-900: #34123A;
    --purple-800: #4A1B50;
    --purple-700: #69256E;
    --purple-600: #832A8A;
    --purple-500: #A24AA9;
    --purple-100: #F4EBF6;
    --purple-050: #FBF7FC;

    --leaf:    #5C9A44;
    --leaf-bg: #EAF3E5;
    --gold:    #C98A1E;
    --gold-bg: #FBF0DC;
    --magenta: #C21C6E;
    --rose-bg: #FBE4EF;

    --ink:     #16131A;
    --muted:   #6B6472;
    --paper:   #FAF8FB;
    --white:   #FFFFFF;
    --line:    #E6E0EA;

    --danger:    #C0392B;
    --danger-bg: #FBE7E4;

    --radius: 8px;
    --shadow: 0 1px 2px rgba(52, 18, 58, .06), 0 4px 16px rgba(52, 18, 58, .06);
    --font: 'Cairo', 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    background: var(--paper);
    color: var(--ink);
    font-size: 15px;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--purple-700); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-weight: 700; line-height: 1.35; margin: 0 0 .6em; color: var(--purple-900); }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }

/* ----------------------------------------------------------------
   الشريط العلوي
   ---------------------------------------------------------------- */
.topbar {
    background: var(--white);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar__inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 22px;
    min-height: 62px;
}
.topbar__brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.topbar__brand img { height: 34px; width: auto; display: block; }
.topbar__brand span {
    font-weight: 700;
    color: var(--purple-800);
    font-size: .95rem;
    white-space: nowrap;
}
.nav { display: flex; align-items: center; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a {
    padding: 7px 12px;
    border-radius: var(--radius);
    color: var(--ink);
    font-weight: 600;
    font-size: .9rem;
}
.nav a:hover { background: var(--purple-050); text-decoration: none; }
.nav a.is-active { background: var(--purple-100); color: var(--purple-800); }

.usermenu { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.usermenu__name { font-size: .85rem; color: var(--muted); }
.usermenu__name b { color: var(--ink); display: block; font-size: .9rem; }

/* ----------------------------------------------------------------
   التخطيط
   ---------------------------------------------------------------- */
.wrap {
    max-width: 1120px;
    margin: 0 auto;
    padding: 26px 20px 60px;
}
.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.page-head h1 { margin: 0; }

.card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 18px;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }

.muted { color: var(--muted); }
.empty {
    text-align: center;
    color: var(--muted);
    padding: 40px 20px;
}

/* ----------------------------------------------------------------
   رسائل flash
   ---------------------------------------------------------------- */
.flashes { max-width: 1120px; margin: 16px auto 0; padding: 0 20px; }
.flash {
    padding: 11px 15px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    font-weight: 600;
    font-size: .9rem;
    border: 1px solid transparent;
}
.flash--success { background: var(--leaf-bg); color: #2f6b1e; border-color: #cfe4c4; }
.flash--error   { background: var(--danger-bg); color: var(--danger); border-color: #f0c9c3; }
.flash--warning { background: var(--gold-bg); color: #8a5e12; border-color: #ecdcb8; }
.flash--info    { background: var(--purple-100); color: var(--purple-800); border-color: #e6d3ec; }

/* ----------------------------------------------------------------
   الأزرار
   ---------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-family: var(--font);
    font-weight: 700;
    font-size: .9rem;
    cursor: pointer;
    transition: transform .12s ease, background .12s ease;
    line-height: 1.2;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--purple-700); color: #fff; }
.btn--primary:hover { background: var(--purple-800); }
.btn--ghost { background: #fff; border-color: var(--line); color: var(--purple-800); }
.btn--ghost:hover { border-color: var(--purple-500); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: #9c2c22; }
.btn--sm { padding: 6px 11px; font-size: .82rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ----------------------------------------------------------------
   النماذج
   ---------------------------------------------------------------- */
.field { margin-bottom: 16px; }
.field label {
    display: block;
    font-weight: 700;
    font-size: .88rem;
    margin-bottom: 6px;
    color: var(--purple-900);
}
.field .hint { font-weight: 400; color: var(--muted); font-size: .82rem; }

input[type=text], input[type=email], input[type=password], input[type=date],
input[type=search], select, textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: .92rem;
    background: #fff;
    color: var(--ink);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--purple-500);
    box-shadow: 0 0 0 3px var(--purple-100);
}
textarea { resize: vertical; min-height: 90px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }

/* ----------------------------------------------------------------
   الفلاتر
   ---------------------------------------------------------------- */
.filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: end;
    margin-bottom: 16px;
}
.filters .field { margin: 0; min-width: 150px; }
.filters .field--search { flex: 1; min-width: 200px; }

/* ----------------------------------------------------------------
   الجداول
   ---------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--line); }
table.data {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    font-size: .9rem;
    min-width: 720px;
}
table.data th, table.data td {
    padding: 11px 14px;
    text-align: right;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
table.data th {
    background: var(--purple-050);
    font-weight: 700;
    color: var(--purple-800);
    white-space: nowrap;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--purple-050); }
table.data td .task-title { font-weight: 700; color: var(--purple-900); }
table.data td .task-title:hover { color: var(--purple-700); }
.row-overdue { background: #fdf1ef; }
.row-overdue:hover { background: #fbe9e6 !important; }

/* ----------------------------------------------------------------
   الشارات
   ---------------------------------------------------------------- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 700;
    white-space: nowrap;
    border: 1px solid transparent;
}
.st-new              { background: #eee9f0; color: #574a5e; }
.st-in-progress      { background: var(--gold-bg); color: #8a5e12; }
.st-waiting-external { background: #e7eef6; color: #2f567e; }
.st-handed-over      { background: var(--purple-100); color: var(--purple-800); }
.st-completed        { background: var(--leaf-bg); color: #2f6b1e; }

.pr-urgent { background: var(--rose-bg); color: var(--magenta); }
.pr-medium { background: var(--gold-bg); color: #8a5e12; }
.pr-low    { background: #edf0ee; color: #566; }

.badge--overdue { background: var(--danger-bg); color: var(--danger); border-color: #f0c9c3; }

/* ----------------------------------------------------------------
   لوحة المعلومات
   ---------------------------------------------------------------- */
.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}
.tile {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px 18px;
    box-shadow: var(--shadow);
}
.tile .num { font-size: 1.9rem; font-weight: 700; color: var(--purple-800); line-height: 1.1; }
.tile .lbl { color: var(--muted); font-size: .85rem; font-weight: 600; }
.tile--alert .num { color: var(--danger); }
.tile--ok .num { color: var(--leaf); }

/* ----------------------------------------------------------------
   تفاصيل المهمة
   ---------------------------------------------------------------- */
.task-layout { display: grid; grid-template-columns: 1fr 320px; gap: 18px; align-items: start; }
.meta-list { list-style: none; margin: 0; padding: 0; }
.meta-list li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px dashed var(--line);
    font-size: .9rem;
}
.meta-list li:last-child { border-bottom: 0; }
.meta-list .k { color: var(--muted); font-weight: 600; }
.meta-list .v { font-weight: 700; text-align: left; }
.desc-box { white-space: pre-wrap; background: var(--purple-050); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 14px; font-size: .92rem; }

/* السجل الزمني */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
    position: relative;
    padding: 0 22px 18px;
    border-right: 2px solid var(--line);
    margin-right: 6px;
}
.timeline li:last-child { border-right-color: transparent; padding-bottom: 0; }
.timeline li::before {
    content: '';
    position: absolute;
    right: -7px;
    top: 3px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--purple-500);
    border: 2px solid #fff;
}
.timeline .t-when { color: var(--muted); font-size: .8rem; }
.timeline .t-what { font-size: .9rem; }
.timeline .t-note {
    margin-top: 5px;
    background: var(--purple-050);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 8px 11px;
    font-size: .88rem;
    white-space: pre-wrap;
}

/* الإجراءات الجانبية */
.action-box { background: var(--purple-050); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 14px; margin-bottom: 14px; }
.action-box h3 { margin: 0 0 10px; font-size: .95rem; }

/* ----------------------------------------------------------------
   الإحصائيات
   ---------------------------------------------------------------- */
.bar-track { background: var(--purple-100); border-radius: 999px; height: 10px; overflow: hidden; min-width: 90px; }
.bar-fill { background: var(--purple-600); height: 100%; border-radius: 999px; }
.bar-fill--ok { background: var(--leaf); }
.bar-fill--warn { background: var(--gold); }
.bar-fill--bad { background: var(--danger); }

/* ----------------------------------------------------------------
   صفحة الدخول
   ---------------------------------------------------------------- */
.auth {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(160deg, var(--purple-800), var(--purple-900));
}
.auth__card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
    padding: 34px 30px;
    width: 100%;
    max-width: 380px;
}
.auth__logo { text-align: center; margin-bottom: 18px; }
.auth__logo img { height: 46px; }
.auth__card h1 { text-align: center; font-size: 1.15rem; margin-bottom: 20px; }

/* ----------------------------------------------------------------
   التذييل
   ---------------------------------------------------------------- */
.footer {
    text-align: center;
    color: var(--muted);
    font-size: .82rem;
    padding: 26px 20px 40px;
}

/* ----------------------------------------------------------------
   استجابة الجوال
   ---------------------------------------------------------------- */
@media (max-width: 860px) {
    .task-layout { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
    .topbar__inner { flex-wrap: wrap; min-height: 0; padding: 10px 16px; gap: 10px; }
    .nav { order: 3; width: 100%; }
    .grid-2 { grid-template-columns: 1fr; }
    .topbar__brand span { display: none; }
    .usermenu { margin-inline-start: auto; }
}
