/* =============================================
   Q.Tech ERP - التصميم
   ============================================= */
:root {
  --ink: #023769;        /* كحلي اللوجو - السايدبار */
  --ink-2: #0a4a80;
  --teal: #2ba9dd;       /* أزرق اللوجو السماوي - اللون الأساسي */
  --teal-soft: #e4f4fb;
  --amber: #f2a51a;      /* لون التمييز */
  --bg: #f4f6f8;
  --card: #ffffff;
  --line: #e5eaee;
  --text: #22333d;
  --muted: #7a8a94;
  --green: #1e8e5a;
  --red: #c94040;
}

* { font-family: 'Tajawal', sans-serif; }
body { background: var(--bg); color: var(--text); margin: 0; }

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

/* ---------- القائمة الجانبية ---------- */
.sidebar {
  width: 250px; min-height: 100vh; background: var(--ink);
  color: #cfdde5; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; flex-shrink: 0;
}
.brand { display: flex; align-items: center; justify-content: center; padding: 20px 16px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-logo { width: auto; max-width: 130px; max-height: 95px; object-fit: contain; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px; background: var(--teal);
  color: #fff; font-weight: 800; font-size: 22px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 3px rgba(43,169,221,.25);
}
.brand-name { font-weight: 800; color: #fff; font-size: 16px; }
.brand-sub { font-size: 11px; color: #8fa5b1; }

.nav-menu { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav-menu a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 3px;
  color: #b8cad4; text-decoration: none; border-radius: 8px; font-weight: 500; font-size: 14.5px;
  transition: background .15s, color .15s;
}
.nav-menu a:hover { background: var(--ink-2); color: #fff; }
.nav-menu a.active { background: var(--teal); color: #fff; font-weight: 700; }
.nav-menu a i { font-size: 17px; }

.sidebar-footer { padding: 14px; border-top: 1px solid rgba(255,255,255,.08); }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip i { font-size: 28px; color: var(--amber); }
.u-name { font-weight: 700; color: #fff; font-size: 14px; }
.u-role { font-size: 12px; color: #8fa5b1; }

/* ---------- المحتوى ---------- */
.content { flex: 1; min-width: 0; }
.page-inner { padding: 24px; max-width: 1300px; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--ink); color: #fff; }

.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.page-head h1 { font-size: 22px; font-weight: 800; margin: 0; color: var(--ink); }
.page-head h1 i { color: var(--teal); margin-left: 6px; }

/* ---------- الكروت ---------- */
.card { border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 1px 3px rgba(16,35,46,.05); }
.card-header { background: #fff; border-bottom: 1px solid var(--line); font-weight: 700; border-radius: 12px 12px 0 0 !important; }

.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: flex; align-items: center; gap: 14px; height: 100%; }
.stat-icon { width: 48px; height: 48px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.stat-icon.teal { background: var(--teal-soft); color: var(--teal); }
.stat-icon.amber { background: #fdf1da; color: #c07f08; }
.stat-icon.green { background: #e3f3ec; color: var(--green); }
.stat-icon.red { background: #f9e7e7; color: var(--red); }
.stat-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 21px; font-weight: 800; color: var(--ink); }
.stat-value.small-val { font-size: 17px; }

/* ---------- الجداول ---------- */
.table { font-size: 14px; }
.table thead th { background: #f0f3f5; color: var(--ink); font-weight: 700; border-bottom: 2px solid var(--line); white-space: nowrap; }
.table td { vertical-align: middle; }
.table-hover tbody tr:hover { background: var(--teal-soft); }

.badge-lead { background: #fdf1da; color: #a06a05; }
.badge-active { background: #e3f3ec; color: var(--green); }
.badge-low { background: #f9e7e7; color: var(--red); }

/* ---------- CRM Kanban ---------- */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; }
.kanban-col { min-width: 280px; max-width: 280px; background: #eef2f5; border-radius: 12px; display: flex; flex-direction: column; }
.kanban-col-head { padding: 12px 14px; font-weight: 700; font-size: 14px; border-bottom: 2px solid; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; }
.kanban-col-head .count { background: rgba(0,0,0,.1); border-radius: 20px; padding: 1px 9px; font-size: 12px; }
.kanban-body { padding: 10px; display: flex; flex-direction: column; gap: 9px; min-height: 120px; flex: 1; }
.lead-card { background: #fff; border-radius: 10px; padding: 12px; box-shadow: 0 1px 3px rgba(16,35,46,.08); cursor: grab; border-right: 3px solid var(--teal); transition: box-shadow .15s; }
.lead-card:hover { box-shadow: 0 4px 12px rgba(16,35,46,.15); }
.lead-card.dragging { opacity: .5; }
.lead-card .lead-name { font-weight: 700; font-size: 14px; color: var(--ink); text-decoration: none; }
.lead-card .lead-company { font-size: 12px; color: var(--muted); }
.lead-card .lead-meta { font-size: 11.5px; color: var(--muted); margin-top: 6px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.lead-card .lead-value { color: var(--green); font-weight: 700; }
.lead-card .next-due { padding: 1px 7px; border-radius: 5px; font-size: 11px; }
.next-due.overdue { background: #f9e7e7; color: var(--red); }
.next-due.today { background: #fdf1da; color: #a06a05; }
.next-due.upcoming { background: var(--teal-soft); color: var(--teal); }
.kanban-body.drop-hover { background: #dfeaf0; border-radius: 8px; }
.wa-btn { color: #25D366; font-size: 15px; }

/* ---------- Timeline نشاطات ---------- */
.timeline-item { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.timeline-icon { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; flex-shrink: 0; font-size: 15px; }
.act-tabs .btn { font-size: 13px; }

/* ---------- طباعة الفواتير والعروض ---------- */
.print-logo { max-width: 100px; max-height: 85px; object-fit: contain; height: auto; }

/* ---------- الأزرار ---------- */
.btn-teal { background: var(--teal); color: #fff; font-weight: 600; }
.btn-teal:hover { background: #1f8fc0; color: #fff; }
.btn-amber { background: var(--amber); color: #3d2a00; font-weight: 700; }
.btn-amber:hover { background: #dd950f; color: #3d2a00; }

.form-label { font-weight: 600; font-size: 13.5px; }
.form-control:focus, .form-select:focus { border-color: var(--teal); box-shadow: 0 0 0 .2rem rgba(43,169,221,.15); }

/* ---------- صفحة الدخول ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(145deg, var(--ink) 0%, #0d3742 100%); }
.login-box { background: #fff; border-radius: 16px; padding: 36px; width: 100%; max-width: 400px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.login-logo { width: auto; max-width: 180px; max-height: 115px; object-fit: contain; margin: 0 auto 14px; display: block; }
.login-box .brand-mark { margin: 0 auto 12px; width: 54px; height: 54px; font-size: 28px; border-radius: 14px; }

/* ---------- موبايل ---------- */
@media (max-width: 991px) {
  .sidebar { position: fixed; right: -260px; z-index: 1050; transition: right .25s; height: 100vh; }
  .sidebar.open { right: 0; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .page-inner { padding: 16px; }
}

/* ═══════════ المرفقات (صور التحويلات والإيصالات) ═══════════ */
.attach-gallery { display: flex; flex-wrap: wrap; gap: 10px; }
.attach-item { position: relative; width: 92px; }
.attach-item img { width: 92px; height: 92px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: pointer; transition: transform .15s; }
.attach-item img:hover { transform: scale(1.05); box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.attach-pdf { width: 92px; height: 92px; border-radius: 8px; border: 1px solid var(--line); background: #fdf0f0; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #c94040; text-decoration: none; gap: 4px; }
.attach-pdf i { font-size: 30px; }
.attach-pdf span { font-size: 11px; font-weight: 700; }
.attach-kind { position: absolute; bottom: 4px; right: 4px; left: 4px; background: rgba(2,55,105,.85); color: #fff; font-size: 10px; text-align: center; border-radius: 4px; padding: 1px 4px; }
.attach-del { position: absolute; top: -6px; left: -6px; width: 22px; height: 22px; background: #c94040; color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; text-decoration: none; box-shadow: 0 2px 5px rgba(0,0,0,.2); }
.attach-del:hover { background: #a83232; color: #fff; }
.attach-badge { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; color: var(--teal); }

/* ═══════════ المستندات الرسمية (فاتورة/عرض سعر/طلبات) بهوية Q.Tech ═══════════ */
.qdoc { background:#fff; max-width:800px; margin:0 auto; padding:0; color:#1a2b3a; }
.qdoc-top { height:14px; background:var(--ink); border-radius:6px 6px 0 0; }
.qdoc-head { display:flex; justify-content:space-between; align-items:flex-start; padding:18px 26px 10px; }
.qdoc-logo { max-width:150px; max-height:70px; object-fit:contain; }
.qdoc-date { border:1px solid var(--line); border-radius:6px; padding:6px 14px; font-size:13px; min-width:150px; text-align:center; color:#555; }
.qdoc-date b { color:var(--ink); }
.qdoc-title { text-align:center; margin:6px 0 18px; }
.qdoc-title h2 { color:var(--ink); font-weight:800; font-size:26px; display:inline-block; border-bottom:3px solid var(--teal); padding-bottom:6px; margin:0; }
.qdoc-body { padding:0 26px; }
.qdoc-party { background:#eef2f6; border-radius:6px; padding:10px 16px; margin-bottom:14px; font-weight:600; }
.qdoc-greet { text-align:center; color:#555; margin:12px 0; }
.qdoc table { width:100%; border-collapse:collapse; margin:6px 0 14px; }
.qdoc table thead th { background:var(--ink); color:#fff; padding:11px 10px; font-size:14px; font-weight:700; text-align:center; border:1px solid var(--ink); }
.qdoc table tbody td { padding:10px; border:1px solid #dde3e9; font-size:13.5px; }
.qdoc table tbody tr:nth-child(even) td { background:#f4f7fa; }
.qdoc-total-row td { background:var(--ink) !important; color:#fff; font-weight:800; font-size:15px; }
.qdoc-section { background:var(--ink); color:#fff; font-weight:700; padding:7px 16px; border-radius:5px; display:inline-block; margin:14px 0 8px; font-size:14px; }
.qdoc-info-row { display:flex; border-bottom:1px solid var(--line); }
.qdoc-info-row > div { flex:1; padding:8px 12px; font-size:13.5px; }
.qdoc-info-row .lbl { color:var(--ink); font-weight:700; }
.qdoc-approve-tbl td { border:1px solid #dde3e9; padding:9px 12px; font-size:13px; }
.qdoc-approve-tbl .hdr { background:var(--ink); color:#fff; font-weight:700; text-align:center; }
.qdoc-note { text-align:center; color:#555; margin:16px 0; font-size:14px; }
.qdoc-sign { text-align:center; color:var(--ink); font-weight:700; margin:14px 0; }
.qdoc-foot { display:flex; align-items:center; justify-content:center; gap:20px; padding:16px 26px; margin-top:10px; border-top:1px solid var(--line); font-size:12.5px; color:#555; flex-wrap:wrap; }
.qdoc-foot span { display:inline-flex; align-items:center; gap:5px; }
.qdoc-foot i { color:var(--teal); }

@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .page-inner { padding: 0; max-width: 100%; }
  .card { border: none; box-shadow: none; }
  .qdoc { max-width:100%; box-shadow:none; }
  .qdoc table thead th, .qdoc-total-row td, .qdoc-section, .qdoc-approve-tbl .hdr {
    -webkit-print-color-adjust:exact; print-color-adjust:exact;
  }
  .qdoc-top { -webkit-print-color-adjust:exact; print-color-adjust:exact; }
  @page { margin: 8mm; }
}
