/* =====================================================
   EngBank — Main Stylesheet
   Font: Tajawal (Arabic) + Inter (Latin/Numbers)
   Palette: Deep Navy · Steel Blue · Emerald · Gold
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800;900&family=Inter:wght@300;400;500;600;700&display=swap');

/* ── CSS Variables ─────────────────────────────────── */
:root {
  --navy:        #0a1f3c;
  --navy-mid:    #0d2d58;
  --blue:        #0b5ea8;
  --blue-light:  #1a7fd4;
  --sky:         #e8f4fd;
  --emerald:     #0b9966;
  --emerald-lt:  #e6f7f1;
  --gold:        #c9962a;
  --gold-lt:     #fdf4e3;
  --red:         #c0392b;
  --red-lt:      #fdf2f2;
  --white:       #ffffff;
  --gray-50:     #f8fafc;
  --gray-100:    #f1f5f9;
  --gray-200:    #e2eaf4;
  --gray-400:    #94a3b8;
  --gray-600:    #475569;
  --gray-800:    #1e293b;
  --text:        #1a2840;
  --text-muted:  #5a7293;

  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   16px;
  --radius-xl:   24px;

  --shadow-sm:   0 2px 8px rgba(10,31,60,0.06);
  --shadow-md:   0 6px 24px rgba(10,31,60,0.10);
  --shadow-lg:   0 16px 48px rgba(10,31,60,0.14);

  --transition:  0.22s cubic-bezier(0.4,0,0.2,1);
}

/* ── Reset & Base ───────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  direction: rtl;
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Tajawal', 'Inter', sans-serif;
  background: var(--gray-50);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
}

a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-light); }
img { max-width: 100%; height: auto; }

/* ── Scrollbar ──────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: var(--gray-400); border-radius: 99px; }

/* ── Layout Wrapper ────────────────────────────────── */
.eb-wrapper {
  max-width: 1260px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ── HEADER ────────────────────────────────────────── */
.eb-header {
  background: var(--navy);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 16px rgba(0,0,0,0.2);
}

.eb-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  max-width: 1260px;
  margin: 0 auto;
  flex-wrap: wrap;
}

/* Logo */
.eb-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.eb-logo-img {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  object-fit: contain;
  background: var(--navy-mid);
  border: 2px solid rgba(255,255,255,0.12);
}

.eb-logo-fallback {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #1a7fd4, #0b5ea8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 20px;
  color: #fff;
  border: 2px solid rgba(255,255,255,0.15);
  letter-spacing: -1px;
  flex-shrink: 0;
}

.eb-logo-text {
  display: flex;
  flex-direction: column;
}

.eb-logo-title {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.eb-logo-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  font-weight: 400;
}

/* Nav */
.eb-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.eb-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.75);
  font-size: 14px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  border: 1px solid transparent;
}

.eb-nav-link:hover,
.eb-nav-link.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
  border-color: rgba(255,255,255,0.12);
}

.eb-nav-link.active {
  background: var(--blue);
}

/* Header Actions */
.eb-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.eb-user-chip {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.85);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
}

/* ── BUTTONS ────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: 'Tajawal', sans-serif;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}

.btn-primary   { background: var(--blue);    color: #fff; }
.btn-primary:hover { background: var(--blue-light); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(11,94,168,0.35); }

.btn-success   { background: var(--emerald); color: #fff; }
.btn-success:hover { background: #0baa72; transform: translateY(-1px); }

.btn-gold      { background: var(--gold);    color: #fff; }
.btn-gold:hover { background: #d4a430; transform: translateY(-1px); }

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

.btn-ghost     { background: transparent; color: var(--blue); border: 1.5px solid var(--blue); }
.btn-ghost:hover { background: var(--blue); color: #fff; }

.btn-light     { background: var(--gray-100); color: var(--gray-800); border: 1px solid var(--gray-200); }
.btn-light:hover { background: var(--gray-200); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }
.btn-block { width: 100%; }

/* ── CARDS ──────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}

.card:hover { box-shadow: var(--shadow-md); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--gray-200);
}

.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
}

/* Tender Card */
.tender-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.tender-card::before {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--blue);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.tender-card.type-mazayada::before { background: var(--gold); }
.tender-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.tender-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-munaqasa { background: var(--sky); color: var(--blue); }
.badge-mazayada { background: var(--gold-lt); color: var(--gold); }
.badge-pending  { background: var(--gold-lt); color: var(--gold); }
.badge-accepted { background: var(--emerald-lt); color: var(--emerald); }
.badge-rejected { background: var(--red-lt); color: var(--red); }
.badge-admin    { background: #3b0d8a22; color: #6b21a8; }
.badge-freelancer { background: var(--sky); color: var(--blue); }

/* Freelancer Card */
.freelancer-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: 18px;
  text-align: center;
  transition: all var(--transition);
}

.freelancer-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.freelancer-avatar {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--blue-light), var(--blue));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  margin: 0 auto 12px;
  color: white;
}

/* Project Card */
.project-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: 18px;
  transition: all var(--transition);
}

.project-card:hover { box-shadow: var(--shadow-md); }

.progress-bar {
  height: 8px;
  background: var(--gray-200);
  border-radius: 99px;
  overflow: hidden;
  margin: 10px 0;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--emerald), var(--blue-light));
  border-radius: 99px;
  transition: width 0.8s ease;
}

/* ── FORMS ──────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-family: 'Tajawal', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(11,94,168,0.12);
}

.form-control::placeholder { color: var(--gray-400); }

textarea.form-control { resize: vertical; min-height: 80px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* ── ALERTS ─────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.alert-success { background: var(--emerald-lt); color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger  { background: var(--red-lt);     color: #991b1b; border: 1px solid #fecaca; }
.alert-info    { background: var(--sky);         color: #1e40af; border: 1px solid #bfdbfe; }
.alert-warning { background: var(--gold-lt);     color: #92400e; border: 1px solid #fde68a; }

/* ── SECTION HERO ───────────────────────────────────── */
.eb-hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 50%, #0b4a82 100%);
  color: white;
  padding: 60px 20px;
  position: relative;
  overflow: hidden;
}

.eb-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}

.eb-hero-inner {
  max-width: 1260px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.eb-hero h1 {
  font-size: clamp(26px, 4vw, 42px);
  font-weight: 900;
  line-height: 1.3;
  margin-bottom: 14px;
}

.eb-hero p {
  font-size: 16px;
  color: rgba(255,255,255,0.75);
  max-width: 560px;
  margin-bottom: 28px;
}

/* ── STATS ──────────────────────────────────────────── */
.stats-bar {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.stat-item {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  text-align: center;
  min-width: 110px;
}

.stat-number {
  font-size: 28px;
  font-weight: 900;
  color: #fff;
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: rgba(255,255,255,0.6);
  margin-top: 4px;
}

/* ── PAGE SECTIONS ──────────────────────────────────── */
.section-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--navy);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title::after {
  content: '';
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, var(--blue), transparent);
  border-radius: 99px;
}

/* ── GRID LAYOUTS ───────────────────────────────────── */
.grid-3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px,1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 16px; }

/* ── TABLE ──────────────────────────────────────────── */
.eb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.eb-table th {
  background: var(--gray-50);
  padding: 12px 14px;
  text-align: right;
  font-weight: 700;
  color: var(--gray-600);
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}

.eb-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--text);
  vertical-align: middle;
}

.eb-table tr:hover td { background: var(--gray-50); }

/* ── MODAL ──────────────────────────────────────────── */
.eb-modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 9000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.eb-modal-overlay.open { display: flex; }

.eb-modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 28px;
  max-width: 540px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.28s ease;
  max-height: 90vh;
  overflow-y: auto;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.94) translateY(16px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.eb-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.eb-modal-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--navy);
}

.eb-modal-close {
  background: var(--gray-100);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  color: var(--gray-600);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}

.eb-modal-close:hover { background: var(--gray-200); }

/* ── AI CHAT WIDGET ─────────────────────────────────── */
.ai-widget {
  position: fixed;
  left: 20px;
  bottom: 20px;
  width: 360px;
  max-width: calc(100vw - 40px);
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  z-index: 8000;
  overflow: hidden;
  display: none;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ai-widget-header {
  background: linear-gradient(135deg, var(--navy), var(--blue));
  color: white;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ai-widget-title {
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-widget-body {
  padding: 16px;
  max-height: 400px;
  overflow-y: auto;
}

.ai-history-item {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 10px;
  font-size: 13px;
}

.ai-history-item .ai-total {
  font-size: 16px;
  font-weight: 800;
  color: var(--emerald);
  margin-top: 4px;
}

/* FAB button */
.ai-fab {
  position: fixed;
  left: 20px;
  bottom: 20px;
  width: 54px;
  height: 54px;
  background: linear-gradient(135deg, var(--emerald), #0baa72);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(11,153,102,0.4);
  transition: all var(--transition);
  z-index: 8000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-fab:hover { transform: scale(1.1); box-shadow: 0 8px 24px rgba(11,153,102,0.5); }
.ai-fab.hidden { display: none; }

/* ── SIDEBAR LAYOUT ─────────────────────────────────── */
.eb-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
  padding: 28px 20px;
  max-width: 1260px;
  margin: 0 auto;
}

.eb-layout-wide {
  padding: 28px 20px;
  max-width: 1260px;
  margin: 0 auto;
}

/* ── FILTER BAR ─────────────────────────────────────── */
.filter-bar {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-bar .form-control {
  flex: 1;
  min-width: 150px;
}

/* ── PAGINATION ─────────────────────────────────────── */
.pagination {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 24px;
  flex-wrap: wrap;
}

.page-link {
  min-width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--white);
  border: 1px solid var(--gray-200);
  color: var(--text);
  font-size: 14px;
  transition: all var(--transition);
}

.page-link:hover,
.page-link.active {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}

/* ── FOOTER ─────────────────────────────────────────── */
.eb-footer {
  background: var(--navy);
  color: rgba(255,255,255,0.65);
  text-align: center;
  padding: 24px 20px;
  font-size: 13px;
  margin-top: 40px;
}

.eb-footer a { color: rgba(255,255,255,0.8); }

/* ── ADMIN SIDEBAR ──────────────────────────────────── */
.admin-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
  gap: 0;
}

.admin-sidebar {
  background: var(--navy);
  color: white;
  padding: 24px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.admin-sidebar-logo {
  padding: 0 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 12px;
}

.admin-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.7);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
}

.admin-nav-link:hover,
.admin-nav-link.active {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.admin-nav-link.active {
  background: var(--blue);
  color: #fff;
}

.admin-main {
  background: var(--gray-50);
  padding: 28px;
  overflow-y: auto;
}

/* ── SPINNER ────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── UTILITIES ──────────────────────────────────────── */
.text-muted     { color: var(--text-muted); }
.text-navy      { color: var(--navy); }
.text-blue      { color: var(--blue); }
.text-emerald   { color: var(--emerald); }
.text-gold      { color: var(--gold); }
.text-red       { color: var(--red); }
.text-sm        { font-size: 13px; }
.text-xs        { font-size: 11px; }
.font-bold      { font-weight: 700; }
.font-heavy     { font-weight: 900; }
.mt-2  { margin-top: 8px; }
.mt-3  { margin-top: 12px; }
.mt-4  { margin-top: 16px; }
.mb-2  { margin-bottom: 8px; }
.mb-3  { margin-bottom: 12px; }
.mb-4  { margin-bottom: 16px; }
.p-3   { padding: 12px; }
.p-4   { padding: 16px; }
.flex  { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ── RESPONSIVE ─────────────────────────────────────── */
@media (max-width: 900px) {
  .eb-layout { grid-template-columns: 1fr; }
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar { height: auto; position: relative; }
  .form-row { grid-template-columns: 1fr; }
  .stats-bar { gap: 10px; }
  .stat-item { min-width: 90px; padding: 10px 14px; }
}

@media (max-width: 600px) {
  .eb-header-inner { padding: 10px 14px; gap: 8px; }
  .eb-hero { padding: 36px 16px; }
  .eb-layout-wide { padding: 16px; }
  .grid-3, .grid-2, .grid-4 { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; }
