/* ============================================================
   منصة مطابقة المرشّحين — Stylesheet
   RTL · Tajawal · Sidebar layout
   ============================================================ */

:root {
  --primary: #1a3a52;
  --primary-600: #234c6a;
  --primary-700: #142f44;
  --accent: #2e86ab;
  --accent-soft: #e3f0f6;

  --bg: #f0f4f8;
  --surface: #ffffff;
  --surface-alt: #f7fafc;

  --text: #1d2733;
  --text-soft: #5a6b7b;
  --text-faint: #8a99a8;
  --border: #e1e8ee;

  --ok: #0a7c4b;
  --ok-soft: #e4f3ec;
  --warn: #b9690a;
  --warn-soft: #fbeede;
  --muted: #6b7785;
  --muted-soft: #eceff2;
  --danger: #9b1c1c;
  --danger-soft: #f7e7e7;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(20, 47, 68, .06);
  --shadow: 0 4px 16px rgba(20, 47, 68, .08);
  --sidebar-w: 248px;

  --font: 'Tajawal', system-ui, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 { color: var(--primary); margin: 0 0 .5em; font-weight: 700; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }

/* ============================================================
   Layout — Sidebar + Main
   ============================================================ */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--primary);
  color: #dbe6ef;
  display: flex;
  flex-direction: column;
  z-index: 50;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: 1.4rem 1.4rem 1.1rem;
  font-size: 1.12rem;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.1);
  text-decoration: none;
}
.sidebar .brand:hover { text-decoration: none; }
.sidebar .brand i { font-size: 1.5rem; color: var(--accent); }

.sidebar-nav {
  flex: 1;
  padding: 1rem .75rem;
  display: flex;
  flex-direction: column;
  gap: .25rem;
  overflow-y: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .7rem .85rem;
  border-radius: var(--radius-sm);
  color: #c2d2e0;
  font-weight: 500;
  font-size: .97rem;
  transition: background .15s, color .15s;
  text-decoration: none;
}
.nav-link i { font-size: 1.25rem; opacity: .9; }
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--accent); color: #fff; }
.nav-link.active i { opacity: 1; }

.sidebar-foot {
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,.1);
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.sidebar-foot .user-name {
  display: flex; align-items: center; gap: .5rem;
  font-weight: 500; color: #fff; font-size: .95rem;
}
.sidebar-foot .user-name i { color: var(--accent); font-size: 1.2rem; }

.logout-form { margin: 0; }
.link-button {
  display: flex; align-items: center; gap: .5rem;
  width: 100%;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.14);
  color: #c2d2e0;
  padding: .55rem .85rem;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .9rem;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.link-button:hover { background: rgba(255,255,255,.12); color: #fff; }

.main {
  flex: 1;
  margin-right: var(--sidebar-w);
  min-width: 0;
}

.topbar {
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.6rem;
  position: sticky; top: 0; z-index: 40;
}
.topbar .page-title { font-size: 1.05rem; font-weight: 700; color: var(--primary); margin: 0; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.8rem 1.6rem 3rem;
}

/* ============================================================
   Flash messages
   ============================================================ */

.flash-list {
  position: sticky;
  top: 70px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  margin-bottom: 1.4rem;
}
.flash {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .8rem 1rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  font-weight: 500;
  border: 1px solid transparent;
}
.flash i { font-size: 1.25rem; flex-shrink: 0; }
.flash .flash-text { flex: 1; }
.flash .flash-close {
  background: none; border: none; cursor: pointer;
  color: inherit; opacity: .6; font-size: 1.2rem; line-height: 1;
  padding: 0; display: flex;
}
.flash .flash-close:hover { opacity: 1; }
.flash-success { background: var(--ok-soft); color: var(--ok); border-color: #bfe3ce; }
.flash-danger, .flash-error { background: var(--danger-soft); color: var(--danger); border-color: #ecc7c7; }
.flash-warning { background: var(--warn-soft); color: var(--warn); border-color: #f2d8b3; }
.flash-info { background: var(--accent-soft); color: var(--accent); border-color: #c4dfeb; }

/* ============================================================
   Cards / surfaces
   ============================================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.4rem;
}
.card + .card { margin-top: 1.2rem; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.1rem;
}
.card-header h2, .card-header h3 { margin: 0; }

.section-title {
  display: flex; align-items: center; gap: .5rem;
  font-size: 1.1rem; color: var(--primary); font-weight: 700;
  margin: 0 0 1rem;
}
.section-title i { color: var(--accent); }

.divider { height: 1px; background: var(--border); border: 0; margin: 1.6rem 0; }

/* ============================================================
   Buttons
   ============================================================ */

.btn, button.btn, .btn-primary, .btn-secondary, .btn-danger, .btn-accent, .btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .6rem 1.15rem;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .95rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, box-shadow .15s;
  text-decoration: none;
}
.btn:hover, .btn-primary:hover, .btn-secondary:hover, .btn-danger:hover { text-decoration: none; }
.btn i { font-size: 1.15rem; }

.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-600); color: #fff; }

.btn-secondary { background: var(--surface); color: var(--primary); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-alt); color: var(--primary); }

.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-accent:hover { background: #25768c; color: #fff; }

.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #851818; color: #fff; }

.btn-ghost { background: transparent; color: var(--text-soft); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-alt); }

.btn-sm { padding: .4rem .8rem; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: .7rem; flex-wrap: wrap; align-items: center; }

/* ============================================================
   Forms
   ============================================================ */

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.1rem 1.4rem;
}
.form-field, .field { display: flex; flex-direction: column; gap: .4rem; }
.form-field.full, .field.full { grid-column: 1 / -1; }

label, .form-field label, .field label {
  font-weight: 500;
  font-size: .9rem;
  color: var(--text-soft);
}

.input, input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="tel"], input[type="date"], input[type="file"],
select, textarea {
  width: 100%;
  padding: .6rem .8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .95rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus, .input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { min-height: 96px; resize: vertical; }

.input-small {
  padding: .35rem .6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: .85rem;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
}

.field-error { color: var(--danger); font-size: .82rem; }
.field-hint  { color: var(--text-faint); font-size: .82rem; }

.sensitive-block {
  background: var(--surface-alt);
  border: 1px dashed #cdd9e3;
  border-radius: var(--radius);
  padding: 1.2rem 1.3rem;
}
.sensitive-note {
  display: flex; align-items: center; gap: .45rem;
  color: var(--warn); font-size: .85rem; font-weight: 500; margin-bottom: .9rem;
}

/* ============================================================
   Filters bar
   ============================================================ */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: .9rem;
  align-items: flex-end;
}
.filters .form-field, .filters .field { flex: 1 1 160px; }
.filter-actions { display: flex; gap: .5rem; align-self: flex-end; padding-bottom: .05rem; }

/* ============================================================
   Badges — status & generic
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .25rem .65rem;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
}
.badge i { font-size: .9rem; }

.badge-available { background: var(--ok-soft);   color: var(--ok); }
.badge-reserved  { background: var(--warn-soft);  color: var(--warn); }
.badge-hired     { background: var(--muted-soft); color: var(--muted); }
.badge-accent    { background: var(--accent-soft); color: var(--accent); }
.badge-neutral   { background: var(--muted-soft); color: var(--text-soft); }

/* ============================================================
   Candidate cards (list)
   ============================================================ */

.candidate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.1rem;
}
.candidate-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: .9rem;
  transition: box-shadow .15s, border-color .15s;
}
.candidate-card:hover { box-shadow: var(--shadow); border-color: #cfdbe6; }
.candidate-card .cc-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: .8rem;
}
.candidate-card .cc-name {
  font-weight: 700; font-size: 1.08rem; color: var(--primary);
  text-decoration: none;
}
.candidate-card .cc-name:hover { text-decoration: underline; }
.candidate-card .cc-meta {
  display: flex; flex-direction: column; gap: .45rem;
  color: var(--text-soft); font-size: .92rem;
}
.candidate-card .cc-meta .mi { display: flex; align-items: center; gap: .5rem; }
.candidate-card .cc-meta .mi i { color: var(--accent); font-size: 1.05rem; width: 1.2rem; text-align: center; }
.candidate-card .cc-foot {
  display: flex; gap: .6rem; align-items: center; flex-wrap: wrap;
  border-top: 1px solid var(--border); padding-top: .9rem;
}

/* ============================================================
   Pagination
   ============================================================ */

.pagination {
  display: flex; gap: .35rem; justify-content: center; align-items: center;
  margin-top: 1.6rem; flex-wrap: wrap;
}
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 38px; height: 38px; padding: 0 .6rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-soft); font-weight: 500;
  text-decoration: none;
}
.pagination a:hover { background: var(--surface-alt); text-decoration: none; }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .disabled { opacity: .45; pointer-events: none; }
.pagination-info { color: var(--text-soft); font-size: .9rem; }

/* ============================================================
   Stat cards (dashboard)
   ============================================================ */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.1rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.3rem;
  display: flex;
  flex-direction: column;
  gap: .7rem;
}
.stat-card .stat-icon {
  width: 46px; height: 46px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent); font-size: 1.5rem;
}
.stat-card h3 { margin: 0; font-size: 1.05rem; }
.stat-card p { margin: 0; color: var(--text-soft); font-size: .9rem; }
.stat-card .btn, .stat-card .btn-primary { margin-top: .4rem; align-self: flex-start; }

/* ============================================================
   Upload — dropzone & file chips
   ============================================================ */

.dropzone {
  border: 2px dashed #b9cad8;
  border-radius: var(--radius);
  background: var(--surface-alt);
  padding: 2.4rem 1.5rem;
  text-align: center;
  color: var(--text-soft);
  transition: border-color .15s, background .15s;
  cursor: pointer;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone i { font-size: 2.6rem; color: var(--accent); }
.dropzone .dz-title { font-weight: 700; color: var(--primary); margin: .6rem 0 .25rem; font-size: 1.05rem; }
.dropzone .dz-hint { font-size: .85rem; color: var(--text-faint); }

.file-chips { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }
.file-chip {
  display: inline-flex; align-items: center; gap: .55rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: .4rem .55rem .4rem .9rem;
  font-size: .88rem; color: var(--text);
}
.file-chip i.doc { color: var(--accent); font-size: 1.15rem; }
.file-chip .chip-remove {
  background: var(--muted-soft); border: none; cursor: pointer;
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-soft); font-size: 1rem; padding: 0;
}
.file-chip .chip-remove:hover { background: var(--danger-soft); color: var(--danger); }
.file-count-hint { font-size: .88rem; color: var(--text-soft); margin-top: .5rem; }

/* ============================================================
   Match score & score bar
   ============================================================ */

.match-score {
  display: inline-flex; align-items: center; gap: .4rem;
  font-weight: 700; font-size: .9rem;
  padding: .3rem .7rem; border-radius: 999px;
}
.match-high { background: var(--ok-soft);   color: var(--ok); }
.match-mid  { background: var(--warn-soft);  color: var(--warn); }
.match-low  { background: var(--muted-soft); color: var(--muted); }

.score-bar { height: 8px; border-radius: 999px; background: var(--muted-soft); overflow: hidden; margin-top: .5rem; }
.score-bar > span { display: block; height: 100%; border-radius: 999px; }
.score-bar.match-high > span { background: var(--ok); }
.score-bar.match-mid  > span { background: var(--warn); }
.score-bar.match-low  > span { background: var(--muted); }

/* ============================================================
   Detail page — key-value grid
   ============================================================ */

.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem 1.6rem;
}
.kv { display: flex; flex-direction: column; gap: .2rem; }
.kv .k { font-size: .82rem; color: var(--text-faint); display: flex; align-items: center; gap: .4rem; }
.kv .k i { color: var(--accent); }
.kv .v { font-weight: 500; color: var(--text); }

.chip-list { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: .25rem .7rem; font-size: .82rem; font-weight: 500; }

/* ============================================================
   Auth / login
   ============================================================ */

.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--primary-700), var(--primary));
  padding: 1.5rem;
}
.auth-card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0,0,0,.25);
  padding: 2.4rem 2.2rem;
  width: 100%; max-width: 400px;
}
.auth-card .brand {
  display: flex; align-items: center; gap: .55rem;
  font-size: 1.25rem; font-weight: 700; color: var(--primary);
  justify-content: center; margin-bottom: .4rem;
  text-decoration: none;
}
.auth-card .brand i { color: var(--accent); font-size: 1.6rem; }
.auth-card .auth-sub { text-align: center; color: var(--text-soft); font-size: .9rem; margin-bottom: 1.6rem; margin-top: 0; }
.auth-card .form-field { margin-bottom: 1rem; }

/* ============================================================
   Card preview page
   ============================================================ */

.card-preview-stage {
  display: flex; flex-direction: column; align-items: center; gap: 1.4rem;
}
.card-preview-stage img {
  max-width: 100%;
  width: min(100%, 720px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

/* ============================================================
   Extraction note (batch review)
   ============================================================ */

.extraction-note {
  display: flex; align-items: flex-start; gap: .6rem;
  background: var(--accent-soft);
  border: 1px solid #c4dfeb;
  border-radius: var(--radius-sm);
  padding: .8rem 1rem;
  font-size: .9rem;
  color: var(--accent);
  margin-bottom: 1.2rem;
}
.extraction-note i { font-size: 1.2rem; flex-shrink: 0; margin-top: .1rem; }

.batch-progress {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .9rem 1rem;
  margin: -0.4rem 0 1.2rem;
  background: var(--surface);
}

.batch-progress-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--primary);
  font-weight: 700;
  font-size: .9rem;
}

.batch-progress-bar {
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--muted-soft);
  margin: .7rem 0;
}

.batch-progress-bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

.batch-progress p {
  color: var(--text-soft);
  font-size: .86rem;
  margin: 0;
}

/* ============================================================
   Musaned manual copy view
   ============================================================ */

.musaned-note { margin-bottom: 1rem; }
.musaned-record { padding: 0; overflow: hidden; }
.musaned-record-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.2rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}
.musaned-record-head h2 {
  margin: .2rem 0 0;
  font-size: 1.1rem;
}
.musaned-record-number {
  color: var(--text-faint);
  font-size: .82rem;
}
.musaned-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.musaned-field {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  padding: .8rem 1rem;
  border-bottom: 1px solid var(--border);
}
.musaned-field:nth-child(odd) { border-left: 1px solid var(--border); }
.musaned-field-content {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.musaned-field-label {
  color: var(--text-faint);
  font-size: .8rem;
}
.musaned-field-value {
  color: var(--text);
  font-weight: 600;
  overflow-wrap: anywhere;
}
.musaned-field.needs-confirmation {
  background: var(--warn-soft);
}
.musaned-field.needs-confirmation .musaned-field-value {
  color: var(--warn);
}
.musaned-warning-badge {
  color: var(--warn);
  font-size: .78rem;
  font-weight: 700;
}
.musaned-manual-badge {
  flex: 0 0 auto;
  padding: .22rem .5rem;
  border-radius: var(--radius-sm);
  background: var(--muted-soft);
  color: var(--text-soft);
  font-size: .78rem;
  font-weight: 700;
}
.icon-btn {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--primary);
  cursor: pointer;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.icon-btn:disabled { cursor: not-allowed; opacity: .55; }
.icon-btn.is-copied { background: var(--ok-soft); color: var(--ok); }

/* ============================================================
   Utilities
   ============================================================ */

.muted { color: var(--text-soft); }
.text-faint { color: var(--text-faint); }
.empty-state {
  text-align: center; padding: 3rem 1.5rem; color: var(--text-faint);
}
.empty-state i { font-size: 3rem; color: #c3d0db; display: block; margin-bottom: .6rem; }
.mt-1 { margin-top: .6rem; }
.mt-2 { margin-top: 1.2rem; }
.mb-2 { margin-bottom: 1.2rem; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.gap { display: flex; gap: .7rem; align-items: center; }

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 880px) {
  .sidebar {
    position: static; width: 100%; flex-direction: row;
    flex-wrap: wrap; align-items: center;
  }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; flex: 1 1 100%; padding: .5rem .75rem; }
  .sidebar-foot { flex-direction: row; align-items: center; flex: 1 1 100%; justify-content: space-between; }
  .main { margin-right: 0; }
  .layout { flex-direction: column; }
  .form-grid { grid-template-columns: 1fr; }
  .form-field.full { grid-column: auto; }
}

@media (max-width: 600px) {
  .container { padding: 1rem .9rem 2rem; }
  .candidate-grid { grid-template-columns: 1fr; }
  .kv-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr; }
  .filters .form-field, .filters .field { flex: 1 1 100%; }
  .musaned-record-head { align-items: stretch; flex-direction: column; }
  .musaned-fields { grid-template-columns: 1fr; }
  .musaned-field:nth-child(odd) { border-left: none; }
}
