/* =========================================================
   GLOBAL STYLES (Variables, Reset, Header, Footer)
   ========================================================= */
:root {
  --primary: #0f172a; --secondary: #334155; --muted: #64748b;
  --bg: #f8fafc; --white: #ffffff; --border: #e2e8f0;
  --blue: #1d4ed8; --blue-2: #2563eb; --blue-light: #38bdf8;
  --green: #16a34a; --danger: #dc2626; --gold: #f59e0b;
  --shadow-sm: 0 6px 18px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 14px 32px rgba(15, 23, 42, 0.10);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.16);
  /* Navy Brand */
  --sanay3i-navy: #061A3D; --sanay3i-navy-2: #082052; --sanay3i-navy-3: #0B2A66;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; background-color: #061A3D; }
@media (display-mode: standalone) { html { background-color: #061A3D; } }

body {
  margin: 0; font-family: "Cairo", sans-serif;
  background: radial-gradient(circle at top right, rgba(56, 189, 248, 0.18), transparent 35%),
              radial-gradient(circle at bottom left, rgba(245, 158, 11, 0.12), transparent 30%),
              linear-gradient(135deg, #f8fafc 0%, #eef6ff 100%);
  color: var(--primary); direction: rtl;
}

a { text-decoration: none; color: inherit; }
button, input, select, textarea { font-family: inherit; }
.container { width: min(1180px, calc(100% - 30px)); margin: auto; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 1000;
  background: linear-gradient(135deg, var(--sanay3i-navy), var(--sanay3i-navy-2) 55%, var(--sanay3i-navy-3)) !important;
  border-bottom: 1px solid rgba(148,163,184,.22) !important;
  box-shadow: 0 18px 45px rgba(2,6,23,.20); backdrop-filter: blur(18px);
}
.header-content { min-height: 84px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.brand { display: flex; align-items: center; gap: 13px; }
.brand-logo-frame {
  width: 58px; height: 58px; border-radius: 20px; padding: 5px;
  background: linear-gradient(145deg, rgba(255,255,255,0.18), rgba(255,255,255,0.06));
  border: 1px solid rgba(255,255,255,0.22); overflow: hidden; color: #fff;
}
.brand-logo-frame img { width: 100%; height: 100%; object-fit: cover; border-radius: 15px; display: block; }
.brand-text h1 { margin: 0; font-size: 23px; font-weight: 900; color: #fff !important; line-height: 1.2; }
.brand-text span { display: block; color: rgba(226,232,240,.84) !important; font-size: 12px; font-weight: 800; margin-top: 4px; }

.main-nav { padding: 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.075); border: 1px solid rgba(255,255,255,.12); display: flex; align-items: center; gap: 8px; }
.main-nav a { color: rgba(241, 245, 249, 0.88) !important; font-weight: 900; font-size: 14px; padding: 10px 13px; border-radius: 999px; transition: 0.25s ease; }
.main-nav a:hover { color: #fff !important; background: rgba(255,255,255,.13) !important; }

.header-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 46px; border-radius: 999px;
  padding: 11px 17px; background: #fff !important; color: var(--sanay3i-navy) !important;
  font-weight: 900; box-shadow: 0 12px 22px rgba(29, 78, 216, 0.18); transition: 0.25s ease;
}
.header-btn:hover { transform: translateY(-2px); box-shadow: 0 16px 26px rgba(29, 78, 216, 0.25); }

.mobile-menu-btn {
  width: 46px; height: 46px; border-radius: 15px; font-size: 18px; display: none; align-items: center; justify-content: center; cursor: pointer;
  background: rgba(255,255,255,.12) !important; color: #fff !important; border: 1px solid rgba(255,255,255,.20) !important;
}
.mobile-nav { display: none; padding: 10px 15px 16px; background: linear-gradient(180deg, var(--sanay3i-navy), var(--sanay3i-navy-2)) !important; }
.mobile-nav.show { display: grid; gap: 8px; }
.mobile-nav a { padding: 12px 14px; border-radius: 14px; color: #fff !important; background: rgba(255,255,255,.08) !important; font-weight: 900; }

/* Footer */
.footer { background: var(--primary); color: #fff; padding: 30px 0; }
.footer-content { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.footer h3 { margin: 0 0 6px; font-weight: 900; }
.footer p { margin: 0; color: rgba(255,255,255,.75); font-weight: 700; }
.footer-links { display: flex; gap: 10px; flex-wrap: wrap; }
.footer-links a { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); padding: 9px 13px; border-radius: 999px; font-weight: 900; color: #fff; }

/* Toast & Loaders */
.copy-toast {
  position: fixed; bottom: 22px; left: 22px; z-index: 3000; background: var(--primary); color: #fff;
  border-radius: 18px; padding: 13px 16px; font-weight: 900; box-shadow: 0 18px 35px rgba(15,23,42,0.22);
  display: none; align-items: center; gap: 9px; max-width: calc(100% - 44px);
}
.copy-toast.show { display: flex; }
.loading-box, .empty-box { background: rgba(255,255,255,.9); border: 1px solid var(--border); border-radius: 26px; padding: 35px 20px; text-align: center; color: var(--muted); font-weight: 800; box-shadow: var(--shadow-sm); }
.loading-box { display: flex; flex-direction: column; align-items: center; }
.spinner { width: 44px; height: 44px; border: 4px solid #dbeafe; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-icon { width: 72px; height: 72px; border-radius: 24px; background: rgba(29,78,216,.09); color: var(--blue); display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; font-size: 30px; }
.empty-box h3 { margin: 0 0 6px; color: var(--primary); font-weight: 900; }

@media (max-width: 850px) {
  .main-nav, .header-btn { display: none; }
  .mobile-menu-btn { display: flex; }
}
@media (max-width: 640px) {
  .footer-content { display: block; text-align: center; }
  .footer-links { justify-content: center; margin-top: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}

/* =========================================================
   تصميم محادثات التطبيق العصري (الصنايعي والإدارة)
   ========================================================= */
.modern-chat-wrapper {
    display: flex;
    flex-direction: column;
    height: 550px;
    background: var(--bg);
    border-radius: 20px;
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* فقاعات المحادثة */
.chat-bubble {
    max-width: 80%;
    padding: 12px 16px;
    font-size: 15px;
    line-height: 1.6;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 2px 4px rgba(15, 23, 42, 0.05);
}

/* رسالة الصنايعي (مرسلة) */
.msg-worker {
    align-self: flex-start;
    background: var(--sanay3i-navy);
    color: var(--white);
    border-radius: 16px 16px 4px 16px;
}

/* رسالة الإدارة (مستقبلة) */
.msg-admin {
    align-self: flex-end;
    background: var(--white);
    color: var(--primary);
    border: 1px solid var(--border);
    border-radius: 16px 16px 16px 4px;
}

/* وقت الرسالة */
.chat-time {
    font-size: 11px;
    display: block;
    margin-top: 6px;
    text-align: left;
}
.msg-worker .chat-time { color: rgba(255,255,255,0.7); }
.msg-admin .chat-time { color: var(--muted); }

/* صورة مرفقة */
.chat-img-attachment {
    max-width: 100%;
    border-radius: 10px;
    margin-top: 8px;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.1);
}

/* منطقة الإدخال */
.chat-input-area {
    background: var(--white);
    padding: 15px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.chat-input-area textarea {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 12px 15px;
    resize: none;
    min-height: 50px;
    max-height: 120px;
    outline: none;
    font-family: inherit;
    font-size: 14px;
    transition: 0.3s;
    background: var(--bg);
    color: var(--primary);
}
.chat-input-area textarea:focus {
    border-color: var(--sanay3i-navy);
    background: var(--white);
}

/* الأزرار */
.chat-action-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: 0.25s ease;
    flex-shrink: 0;
}
.btn-attach {
    background: var(--bg);
    color: var(--muted);
    border: 1px solid var(--border);
}
.btn-attach:hover { background: var(--border); color: var(--primary); }

.btn-send {
    background: var(--green);
    color: var(--white);
}
.btn-send:hover { background: #15803d; transform: translateY(-2px); box-shadow: var(--shadow-sm); }

/* معاينة الصورة */
#chatImagePreviewContainer {
    display: none;
    padding: 10px 20px;
    background: var(--bg);
    border-top: 1px solid var(--border);
    position: relative;
}
#chatImagePreviewContainer img {
    height: 60px;
    border-radius: 8px;
    border: 2px solid var(--border);
}
.remove-img-btn {
    position: absolute;
    top: 5px;
    right: 70px;
    background: var(--danger);
    color: var(--white);
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}