/**
 * تنسيقات الواجهة الأمامية - نظام التذاكر مداد الشرقية
 */

@import url('https://fonts.googleapis.com/css2?family=Almarai:wght@400;700;800&display=swap');

:root {
  /* Theme tokens for frontend */
  --medad-color-primary: #deae72;
  --medad-color-primary-700: #7a552a;
  --color-elevated: #ffffff;
  --color-surface: #f6f7fb;
  --color-border: #e5e7eb;
  --color-text: #111827;
  --radius-sm: 8px;
  --radius-md: 12px;
  --shadow-sm: none;
  --shadow-md: none;
  --medad--color--primary: var(--medad-color-primary);
}

/* الإعدادات العامة */
.madad-ticket-form-container,
.madad-client-dashboard,
.madad-ticket-view,
.madad-tickets-page {
    font-family: 'Almarai', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
    direction: rtl;
    text-align: right;
    position: relative;
    /* Isolate stacking context to avoid theme overlays affecting form controls */
    isolation: isolate;
    /* allow dropdowns/menus to render fully */
    overflow: visible;
    box-sizing: border-box;
}

/* Limit box-sizing to plugin containers to avoid impacting theme layout */
.madad-client-dashboard *,
.madad-ticket-form-container *,
.madad-ticket-view *,
.madad-tickets-page * {
    box-sizing: border-box;
}


/* حاوي الرسائل */
#madad-form-messages {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    max-width: 400px;
}

.madad-message {
    padding: 15px 20px;
    margin-bottom: 10px;
    border-radius: 6px;
    font-weight: 500;
    box-shadow: none;
}

.madad-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.madad-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* نموذج إنشاء التذكرة */
.madad-ticket-form-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.madad-form-header {
    text-align: center;
    margin-bottom: 40px;
}

.madad-form-header h2 {
    color: #333;
    margin-bottom: 10px;
    font-size: 28px;
}

.madad-form-description {
    color: #666;
    font-size: 16px;
}

/* أقسام النموذج */
.madad-form-section {
    margin-bottom: 40px;
    padding: 25px;
    background: #fff;
    border-radius: 10px;
    box-shadow: none;
    border: 1px solid var(--color-border);
    overflow: visible;
}

.madad-section-title {
    color: #333;
    margin-bottom: 20px;
    font-size: 20px;
    font-weight: 600;
}

.madad-section-title input[type="checkbox"] {
    margin-left: 10px;
}

/* حقول النموذج */
.madad-field, .madad-form-group {
    margin-bottom: 25px;
}

.madad-field label, .madad-form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
    /* Responsive label sizing for better readability across breakpoints */
    font-size: clamp(13px, 1.6vw, 16px);
}

.madad-field input,
.madad-field select,
.madad-field textarea,
.madad-form-group input,
.madad-form-group select,
.madad-form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: #fff;
}

.madad-field input:focus,
.madad-field textarea:focus,
.madad-form-group input:focus,
.madad-form-group textarea:focus {
    outline: 2px solid rgba(0, 124, 186, 0.25);
    outline-offset: 1px;
    border-color: var(--medad-color-primary);
    box-shadow: none;
}

/* تركيز بسيط للـ select بدون ظلال */
.madad-field select:focus,
.madad-form-group select:focus {
    outline: none;
    border-color: var(--medad-color-primary);
    box-shadow: none;
}

/* Safari/iOS: ensure native selects open and render correctly */
.madad-field select,
.madad-form-group select {
    -webkit-appearance: menulist;
    appearance: menulist;
    background-image: none;
    background-color: #fff;
    pointer-events: auto;
    position: relative;
    z-index: 100;
    opacity: 1;
    visibility: visible;
}

/* Simple native select for Safari with strong overrides (only when custom is NOT active) */
.madad-ticket-form-container:not(.madad-enhanced-selects) .madad-field select,
.madad-ticket-form-container:not(.madad-enhanced-selects) .madad-form-group select {
    -webkit-appearance: menulist !important;
    appearance: menulist !important;
    background: #fff !important;
    border: 1px solid var(--color-border) !important;
    padding: 10px 12px !important;
    height: auto !important;
    line-height: normal !important;
    width: 100% !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    position: relative !important;
    z-index: 100 !important;
}

/* الصفوف والأعمدة */
.madad-row, .madad-form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.madad-row .madad-field, .madad-form-row .madad-field, .madad-form-row .madad-form-group {
    flex: 1;
    min-width: 0;
}

.madad-col-6 {
    flex: 1;
}

@media (max-width: 768px) {
    .madad-row, .madad-form-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .madad-ticket-form-container {
        padding: 15px;
    }
    
    .madad-form-section {
        padding: 20px;
    }
}

/* رفع الملفات */
.madad-file-upload {
    position: relative;
    border: 2px dashed #e1e5e9;
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    transition: all 0.3s;
    background: #f8f9fa;
}

.madad-file-upload:hover {
    border-color: #444444;
    background: #f5f5f5;
}

.madad-file-upload input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.madad-upload-btn {
    display: inline-block;
    cursor: pointer;
    color: #666;
    font-size: 16px;
}

.madad-upload-btn i {
    font-size: 24px;
    margin-left: 10px;
    color: #444444;
}

.madad-file-list {
    margin-top: 15px;
    text-align: right;
}

.madad-file-item {
    background: #f5f5f5;
    padding: 10px 15px;
    margin: 5px 0;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* الأزرار - aligned with shared theme tokens */
.madad-btn {
    display: inline-block;
    padding: 12px 24px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--medad-color-primary);
    color: #fff;
    box-shadow: none;
    transition: all 0.2s ease;
}

.madad-btn:hover {
    background: #fff;
    transform: translateY(-1px);
    color: var(--medad-color-primary);
    box-shadow: none;
    transition: all 0.2s ease;
    border: 1px solid var(--medad-color-primary);
}

.madad-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* رسائل النجاح والخطأ */
#madad-form-messages {
    margin-top: 20px;
}

.madad-message {
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 10px;
}

/* تحسين واجهة الرد للعميل */
.madad-reply-form-container {
    background: #fff;
    border: 1px solid #e6e6e6;
    border-radius: 10px;
    padding: 16px;
    margin-top: 18px;
    box-shadow: none;
}
.madad-reply-form { display:flex; flex-wrap:wrap; gap:10px; align-items:flex-start; }
.madad-reply-form textarea { flex: 1 1 auto; min-height: 100px; padding:12px; border:2px solid #e1e5e9; border-radius:8px; }
.madad-reply-form .madad-reply-actions { display:flex; align-items:center; }
.madad-reply-form .madad-btn-primary { height:42px; padding:0 18px; border-radius:8px; }

/* جعل التخطيط على صف واحد عند الشاشات الواسعة */
.madad-chat-card { padding:16px; }
.madad-chat-thread { display:flex; flex-direction:column; gap:10px; }
.madad-chat-msg { display:flex; }
.madad-chat-me { justify-content:flex-end; }
.madad-chat-them { justify-content:flex-start; }
.madad-chat-bubble { max-width: 80%; padding:10px 12px; border-radius: 14px; border: 1px solid var(--color-border); background:#f9fafb; }
.madad-chat-me .madad-chat-bubble { background:#e8f1fb; border-color:#d6e6f7; }
.madad-chat-content { color:#111827; font-size:14px; }
.madad-chat-meta { display:flex; align-items:center; gap:8px; margin-top:6px; font-size:12px; color:#6b7280; }
.madad-chat-meta .label { background:#ffefc1; color:#7a5200; padding:2px 6px; border-radius:999px; font-size:11px; }
.madad-chat-compose { margin-top:12px; }
.madad-chat-compose .madad-reply-form { display:flex; gap:8px; }
.madad-chat-compose textarea { flex:1; height:24px; min-height:24px; max-height:160px; padding:10px 12px; border:2px solid #e1e5e9; border-radius:8px; resize:none; overflow:auto; }
.madad-chat-compose .madad-btn { flex:0 0 auto; }

@media (min-width: 860px) {
  .madad-reply-form textarea { min-height: 80px; }
  .madad-reply-form { flex-wrap: nowrap; }
  .madad-reply-form .madad-reply-actions { flex: 0 0 160px; justify-content: flex-start; }
}

/* تحسين قائمة الردود للعميل */
.madad-replies-list { display:flex; flex-direction:column; gap:10px; }
.madad-reply-item { background:#f9f9f9; border:1px solid #e0e0e0; border-radius:8px; padding:12px; }
.madad-reply-header { display:flex; gap:8px; align-items:center; font-size:13px; color:#333; }
.madad-reply-date { color:#777; font-size:12px; }
.madad-reply-label { background:#ffefc1; color:#7a5200; padding:2px 8px; border-radius:12px; font-size:11px; }

.madad-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.madad-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* لوحة تحكم العميل */
.madad-client-dashboard {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    gap: 30px;
}

.madad-dashboard-main { flex: 1; display:flex; flex-direction: column; gap: 12px; }

/* بطاقات واجهة حديثة (light theme only, no toggler) */
.madad-card {
  background: var(--color-elevated);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: none;
  padding: 16px;
}
.madad-card__header { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; row-gap:8px; }
.madad-card__header .madad-toolbar { flex: 0 0 auto; }
.madad-card__title { flex: 1 1 auto; min-width: 240px; }
.madad-card__title { font-weight:700; font-size:18px; }
.madad-card__title,
.madad-card h3,
.madad-form-header h2,
.madad-section-title,
.madad-ticket-title h2 {
  font-family: 'Almarai', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
}
.madad-card__sub { opacity:0.8; font-size:13px; margin-bottom: 10px; }

/* شريط أدوات بسيط */
.madad-toolbar { display:flex; align-items:center; gap:10px; }
.madad-input { width:100%; max-width:260px; padding:8px 10px; border:1px solid var(--color-border); border-radius: var(--radius-sm); background:#fff; }
.madad-select { padding:8px 10px; border:1px solid var(--color-border); border-radius: var(--radius-sm); background:#fff; }

/* أزرار عامة موحدة */
.madad-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--color-text);
  font-weight: 600;
  font-size: 14px;
  min-height: 44px;
  cursor: pointer;
  text-decoration: none;
  box-shadow: none;
  transition: transform 0.06s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.madad-btn:hover { transform: translateY(-1px); box-shadow: none; }
.madad-btn:focus { outline: 2px solid rgba(0,124,186,0.25); outline-offset: 1px; border-color: var(--medad-color-primary); box-shadow: none; }
.madad-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* تباينات الأزرار الشائعة */
.madad-btn.is-primary { background: var(--medad-color-primary); border-color: var(--medad-color-primary); color:#fff; }
.madad-btn.is-ghost { background: transparent; color: var(--color-text); border-color: var(--color-border); }

/* أسماء قديمة كـ alias للتوافق */
.madad-btn-primary { background: var(--medad-color-primary); border-color: var(--medad-color-primary); color:#fff; }
.madad-btn-secondary { background: var(--color-surface); color: var(--color-text); }

/* إجراءات البحث وتخطيط مصغر للأوتار */
.madad-search-actions { text-align:center; margin-top: 20px; }
.madad-search-actions .madad-btn { margin: 0 8px; }

/* Remove underline from buttons */
.madad-btn,
.madad-btn:hover,
.madad-btn:focus,
.madad-btn:active { text-decoration: none; }

/* صفحة المصادقة (تسجيل/دخول) حاوية بسيطة */
.madad-auth { max-width: 520px; margin: 40px auto; padding: 16px; }

.madad-auth-required { max-width: 540px; margin: 40px auto; padding: 20px; background:#fff; border:1px solid var(--color-border); border-radius:8px; text-align:center; }
.madad-auth-required .madad-auth-message { margin-bottom: 12px; font-weight: 700; color: #111827; }
.madad-auth-actions { display:flex; flex-direction:column; gap:10px; }
.madad-auth-actions .madad-btn { width:100%; }

/* صفحة تسجيل الدخول - تحسينات التصميم */
.madad-login-header { text-align: center; margin-bottom: 16px; }
.madad-login-header h2 { margin: 0; font-size: 22px; font-weight: 700; color: #111827; }
.madad-login-subtitle { margin-top: 6px; color: #6b7280; font-size: 14px; }

.madad-login-error { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid #f5c6cb; background: #f8d7da; color: #721c24; border-radius: 8px; margin-bottom: 12px; }
.madad-login-error i { color: #dc3545; }

.madad-login-form { margin-top: 10px; }
.madad-form-group { margin-bottom: 16px; }
.madad-form-group label { display: block; margin-bottom: 8px; font-weight: 600; color: #374151; font-size: clamp(13px, 1.6vw, 16px); }

.madad-input-icon { position: relative; }
.madad-input-icon i { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); color: #9ca3af; font-size: 16px; }
.madad-input-icon input { width: 100%; padding: 12px 14px; padding-inline-start: 40px; border: 2px solid #e1e5e9; border-radius: 8px; background: #fff; color: #111827; font-size: 16px; line-height: 1.4; }
.madad-input-icon input:focus { outline: 2px solid rgba(0,124,186,0.25); outline-offset: 1px; border-color: #007cba; }

.madad-form-row { display: flex; align-items: center; justify-content: space-between; margin: 6px 0 16px; }
.madad-remember { display: inline-flex; align-items: center; gap: 8px; color: #374151; }
.madad-forgot { color: var(--medad-color-primary); text-decoration: none; }
.madad-forgot:hover { text-decoration: underline; }

.madad-actions { margin-top: 6px; }

.madad-login-footer { text-align: center; margin-top: 14px; color: #6b7280; }
.madad-login-footer .madad-link { color: var(--medad-color-primary); font-weight: 600; text-decoration: none; }
.madad-login-footer .madad-link:hover { text-decoration: underline; }

/* مكون القائمة المنسدلة المخصص */
.madad-dropdown { position: relative; }
.madad-dropdown__toggle {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: #fff;
  color: var(--color-text);
  font-size: 16px;
  cursor: pointer;
  min-height: 40px;
  line-height: 1.4;
}
.madad-dropdown__toggle:focus { outline: 2px solid rgba(0, 124, 186, 0.25); outline-offset: 1px; border-color: #007cba; box-shadow: none; }
.madad-dropdown__caret { margin-inline-start: 8px; opacity: 0.7; }
.madad-dropdown__menu {
  position: absolute;
  inset-inline-start: 0;
  inset-inline-end: 0;
  margin-top: 6px;
  list-style: none; /* remove default bullet dots */
  padding: 6px 0;   /* reset ul padding for clean list */
  margin-inline: 0; /* unify with inputs spacing */
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  box-shadow: none;
  max-height: 220px;
  overflow: auto;
  display: none;
}
.madad-dropdown,
.madad-dropdown__menu { z-index: auto !important; box-shadow: none !important; }
/* Ensure custom dropdown overlays native selects when open (Safari-specific enhancement) */
.madad-ticket-form-container.madad-enhanced-selects .madad-dropdown.open .madad-dropdown__menu { z-index: 200 !important; }
.madad-dropdown.open .madad-dropdown__menu { display: block; }
.madad-dropdown__option { padding: 10px 12px; cursor: pointer; font-size: 14px; list-style: none; }
.madad-dropdown__option:hover { background: #f5f7fa; }
.madad-dropdown__option.is-selected { background: #eef6ff; color: #0b63b6; }
.madad-ticket-form-container.madad-enhanced-selects .madad-dropdown__option.is-selected { background: transparent !important; color: inherit !important; }
.madad-ticket-form-container.madad-enhanced-selects .madad-native-select { display: none !important; opacity: 0 !important; pointer-events: none !important; }
.madad-native-select { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
/* Ensure native selects are visible in ticket form (Safari fix) */
.madad-ticket-form-container:not(.madad-enhanced-selects) .madad-native-select {
  position: static;
  opacity: 1;
  pointer-events: auto;
  width: auto;
  height: auto;
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* شارة (badge) عامة مع خرائط الحالة/الأولوية الحالية */
.madad-badge { display:inline-block; padding:4px 10px; border-radius:999px; font-size:12px; font-weight:600; border:1px solid var(--color-border); }
.madad-status-open { background: rgba(16,185,129,.20); color: #10b981; }
.madad-status-in_progress { background: rgba(245,158,11,.20); color: #f59e0b; }
.madad-status-waiting_customer { background: rgba(239,68,68,.20); color: #ef4444; }
.madad-status-closed { background: rgba(156,163,175,.25); color: #9ca3af; }
.madad-priority-low { background: rgba(147,197,253,.25); color:#2563eb; }
.madad-priority-normal { background: rgba(203,213,225,.45); color:#334155; }
.madad-priority-high { background: rgba(245,158,11,.20); color:#b45309; }
.madad-priority-urgent { background: rgba(239,68,68,.20); color:#b91c1c; }

/* تحسين الجداول الموحدة */
.madad-table { width: 100%; border-collapse: collapse; }
.madad-table-wrap { width: 100%; overflow-x: auto; }
.madad-table thead th { text-align: right; padding: 10px; border-bottom: 1px solid var(--color-border); color: var(--color-text); background: var(--color-surface); }
.madad-table tbody td { padding: 10px; border-bottom: 1px solid #f3f4f6; }
.madad-table tbody tr:hover { background: #fafafa; }
.cell-actions { width: 160px; text-align: left; }
.muted { color:#6b7280; font-size:12px; }

/* شريط التنقل */
.madad-dashboard-nav {
    width: 250px;
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: none;
    height: fit-content;
}

/* تحسين رأس لوحة التنقل وتوافقه مع الشاشات الصغيرة */
.madad-nav-header { display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.madad-nav-header h2 { font-size: 20px; margin: 0; }
.madad-nav-header .madad-welcome { margin: 0; }
.madad-notifications { position: relative; }

.madad-nav-header h2 {
    color: #333;
    margin-bottom: 5px;
}

.madad-user-hello { margin-bottom: 16px; }
.madad-user-name { font-size: 20px; font-weight: 800; color:#111827; }
.madad-user-meta { color:#6b7280; font-size: 13px; margin-top: 4px; }

.madad-nav-separator { border-top: 1px solid var(--color-border); margin: 12px 0 16px; }

.madad-nav-menu {
    list-style: none;
    padding: 0;
}
.madad-nav-toggle { display:none; align-items:center; gap:8px; padding:8px 10px; border:1px solid var(--color-border); border-radius:6px; background:#fff; color:#111827; font-weight:600; cursor:pointer; }
.madad-nav-select-container { display:none; }
.madad-nav-select-container .madad-select { width:100%; }
.madad-link { color: var(--medad-color-primary); text-decoration: none; font-weight: 600; }
.madad-link:hover { text-decoration: underline; }

.madad-nav-item {
    display: block;
    padding: 12px 15px;
    color: #666;
    text-decoration: none;
    border-radius: 4px;
    margin-bottom: 5px;
    transition: all 0.3s ease;
}

.madad-nav-item:hover,
.madad-nav-item.active {
    background: var(--medad-color-primary);
    color: white;
}

.madad-nav-item i {
    margin-left: 10px;
    font-size: 16px;
}

/* محتوى لوحة التحكم */
.madad-dashboard-content {
    flex: 1;
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: none;
}

.madad-dashboard-topbar { display:flex; align-items:center; justify-content:flex-end; gap:12px; margin-bottom:0; }
.madad-dashboard-topbar .madad-btn.is-ghost { min-height: 36px; }

.madad-ticket-view .madad-card { margin-bottom: 16px; }
.madad-ticket-view .madad-card:last-child { margin-bottom: 0; }

/* إحصائيات التذاكر */
.madad-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.madad-stat-card {
    background: var(--color-elevated);
    color: var(--color-text);
    padding: 20px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: none;
}


.madad-stat-icon i {
    font-size: 28px;
    color: var(--medad-color-primary);
}

.madad-stat-content h3 {
    font-size: 32px;
    margin: 0;
    font-weight: 700;
}

.madad-stat-content p {
    margin: 5px 0 0 0;
    opacity: 0.9;
}

/* قائمة التذاكر */
.madad-tickets-list {
    space-y: 15px;
}

.madad-ticket-item {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 15px;
    transition: transform 0.3s ease;
}

.madad-ticket-item:hover {
    transform: translateY(-1px);
}

.madad-ticket-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    row-gap: 8px;
    margin-bottom: 16px;
}

.madad-ticket-header h4 {
    margin: 0;
}

.madad-ticket-header a {
    color: var(--medad-color-primary);
    text-decoration: none;
    font-weight: 600;
}

.madad-ticket-status {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.madad-status-open { background: rgba(16,185,129,.20); color: #10b981; }
.madad-status-in_progress { background: rgba(245,158,11,.20); color: #f59e0b; }
.madad-status-waiting_customer { background: rgba(239,68,68,.20); color: #ef4444; }
.madad-status-closed { background: rgba(156,163,175,.25); color: #9ca3af; }

.madad-ticket-title {
    font-weight: 600;
    color: #333;
}
.madad-ticket-title h2 { margin: 0; font-size: 22px; }
.madad-ticket-subject { margin: 4px 0 0; color:#374151; font-size: 14px; }


.madad-ticket-meta { display:flex; align-items:center; gap:8px; flex-wrap:wrap; font-size:13px; color:#666; }
.madad-ticket-date { color:#6b7280; }
.madad-ticket-project { color:#6b7280; }

/* Badges: ensure pill shape and consistent spacing */
.madad-badge { display:inline-flex; align-items:center; padding:4px 10px; border-radius:999px; font-size:12px; font-weight:600; border:1px solid var(--color-border); }
.madad-ticket-status, .madad-ticket-priority { border-radius:999px; }

/* معاينة مرفقات التذكرة (شبكة) */
.madad-attachments-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin-top: 10px;
}

.madad-attachment-item {
    position: relative;
    display: block;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    text-decoration: none;
    color: inherit;
    transition: transform 0.1s ease;
}

.madad-attachment-item:hover {
    box-shadow: none;
    transform: translateY(-1px);
}

.madad-attachment-image img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
}

.madad-attachment-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
}

.madad-attachment-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.madad-attachment-meta {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 8px;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    background: rgba(255,255,255,0.9);
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 12px;
}

.madad-attachment-file .madad-attachment-meta {
    position: static;
    background: transparent;
    padding: 0;
}

.madad-attachment-meta .name {
    font-weight: 600;
    color: #111827;
}

.madad-attachment-meta .who {
    color: #6b7280;
}

/* حالة فارغة */
.madad-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.madad-empty-state i {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.madad-empty-state h3 {
    margin-bottom: 10px;
    color: #333;
}

/* تحميل (Spinner) */
.madad-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: madad-spin 1s ease-in-out infinite;
}

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

/* تصميم متجاوب */
@media (max-width: 768px) {
    .madad-client-dashboard {
        flex-direction: column;
        padding: 10px;
    }

    .madad-dashboard-nav {
        width: 100%;
    }

    .madad-dashboard-content {
        padding: 0;
    }

    .madad-nav-header h2 { font-size: 18px; }
    .madad-nav-header { gap:8px; }

    .madad-nav-toggle { display:none; }
    .madad-nav-select-container { display:block; }
    .madad-dashboard-nav .madad-nav-menu { display: none; }
    .madad-nav-item { white-space: normal; margin-bottom: 6px; }

    .madad-row {
        flex-direction: column;
        gap: 0;
    }

    .madad-stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .madad-dashboard-topbar { justify-content: space-between; flex-wrap: wrap; }
    .madad-card__header { justify-content: flex-start; }
    .madad-card__title { margin-bottom: 6px; }
}

@media (max-width: 480px) {
    .madad-stats-grid {
        grid-template-columns: 1fr;
    }

    .madad-ticket-header { flex-direction: column; align-items: flex-start; gap: 10px; }

    .madad-ticket-meta {
        flex-direction: column;
        gap: 5px;
    }
}

/* تثبيت تخطيط الصفحة ومنع الانزياح عند ظهور/اختفاء شريط التمرير */
html { scrollbar-gutter: stable both-edges; }

/* نمط قائمة إشعارات لوحة التحكم (dropdown) */
.madad-notifications { position: relative; }
.madad-notifications .madad-dropdown {
  position: fixed;
  width: min(320px, 92vw);
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.08);
  z-index: 100000;
}
.madad-dropdown-header { padding: 10px 12px; font-weight: 700; border-bottom: 1px solid var(--color-border); }
.madad-dropdown-list { max-height: 300px; overflow: auto; }
.madad-dropdown-item { padding: 10px 12px; border-bottom: 1px solid #f3f4f6; }
.madad-dropdown-item.unread { background: #f9fafb; }
.madad-dropdown-actions { padding: 8px 12px; text-align: center; border-top: 1px solid var(--color-border); }
.madad-ticket-meta .madad-back-btn { margin-inline-start: auto; }
.madad-back-btn { padding:6px 10px; }
.madad-client-dashboard label,
.madad-ticket-form-container label,
.madad-ticket-view label,
.madad-tickets-page label {
    font-family: 'Almarai', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
}
.madad-btn { font-family: 'Almarai', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif; }
