/* ==========================================================================
   main.css - التنسيقات العامة والهوية البصرية لمنظومة المنشآت والوثائق
   مؤسسة اللؤلؤة العقارية - PEARL REAL ESTATE (PRE)
   ========================================================================== */

:root {
  /* الهوية الرسمية (العنابي الملكي، الذهبي، واللؤلؤي) */
  --primary-burgundy: #7b1123;
  --primary-burgundy-hover: #93172c;
  --primary-burgundy-dark: #500a16;
  --primary-burgundy-deep: #38070f;
  --primary-burgundy-soft: rgba(123, 17, 35, 0.08);
  --primary-burgundy-glow: rgba(123, 17, 35, 0.22);
  --primary-gradient: linear-gradient(135deg, #7b1123 0%, #500a16 100%);
  --primary-gradient-subtle: linear-gradient(145deg, #881428 0%, #5c0b1a 100%);

  --accent-gold: #c58d60;
  --accent-gold-light: #e5b892;
  --accent-gold-soft: rgba(197, 141, 96, 0.15);
  --accent-gold-gradient: linear-gradient(135deg, #dfa97b 0%, #b87c4c 100%);

  /* ألوان حالات الوثائق الأربعة المعتمدة */
  --doc-valid-green: #10b981;
  --doc-valid-bg: rgba(16, 185, 129, 0.1);
  --doc-valid-border: rgba(16, 185, 129, 0.3);

  --doc-expiring-orange: #f59e0b;
  --doc-expiring-bg: rgba(245, 158, 11, 0.12);
  --doc-expiring-border: rgba(245, 158, 11, 0.35);

  --doc-expired-red: #ef4444;
  --doc-expired-bg: rgba(239, 68, 68, 0.12);
  --doc-expired-border: rgba(239, 68, 68, 0.35);

  --doc-renewal-blue: #3b82f6;
  --doc-renewal-bg: rgba(59, 130, 246, 0.12);
  --doc-renewal-border: rgba(59, 130, 246, 0.35);

  /* الألوان الوظيفية */
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --info: #0ea5e9;
  --info-bg: #f0f9ff;
  --purple: #8b5cf6;
  --purple-bg: #f5f3ff;

  /* الخلفيات والنصوص */
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --border-subtle: #e2e8f0;
  --border-focus: #7b1123;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-white: #ffffff;

  /* الظلال والزوايا */
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 30px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 20px -4px rgba(0, 0, 0, 0.06), 0 4px 8px -4px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 20px 30px -8px rgba(123, 17, 35, 0.1), 0 8px 12px -6px rgba(0, 0, 0, 0.04);
  --shadow-hover: 0 16px 32px -6px rgba(123, 17, 35, 0.18);

  --font-main: 'Cairo', 'Tajawal', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-num: 'Cairo', -apple-system, sans-serif;
  --transition-fast: 0.18s ease;
  --transition-smooth: 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-page);
  color: var(--text-primary);
  direction: rtl;
  text-align: right;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ================== شارات حالات الوثائق (Status Badges) ================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
}

.badge-green {
  background: var(--doc-valid-bg);
  color: #047857;
  border: 1px solid var(--doc-valid-border);
}

.badge-orange {
  background: var(--doc-expiring-bg);
  color: #b45309;
  border: 1px solid var(--doc-expiring-border);
}

.badge-red {
  background: var(--doc-expired-bg);
  color: #b91c1c;
  border: 1px solid var(--doc-expired-border);
  animation: pulseBadge 2.5s infinite;
}

.badge-blue {
  background: var(--doc-renewal-bg);
  color: #1d4ed8;
  border: 1px solid var(--doc-renewal-border);
}

.badge-burgundy {
  background: var(--primary-burgundy-soft);
  color: var(--primary-burgundy);
  border: 1px solid rgba(123, 17, 35, 0.25);
}

.badge-gold {
  background: var(--accent-gold-soft);
  color: #96633b;
  border: 1px solid rgba(197, 141, 96, 0.4);
}

.badge-purple {
  background: var(--purple-bg);
  color: #6d28d9;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

@keyframes pulseBadge {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ================== الأزرار الرسمية (Buttons) ================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all var(--transition-fast);
  line-height: 1;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary-gradient);
  color: var(--text-white);
  box-shadow: 0 4px 12px rgba(123, 17, 35, 0.25);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #93172c 0%, #680e1e 100%);
  box-shadow: 0 6px 18px rgba(123, 17, 35, 0.35);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--accent-gold-gradient);
  color: var(--text-white);
  box-shadow: 0 4px 12px rgba(197, 141, 96, 0.25);
}
.btn-secondary:hover {
  background: linear-gradient(135deg, #eaab78 0%, #a46a3b 100%);
  transform: translateY(-1px);
}

.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: var(--text-white);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}
.btn-success:hover {
  background: linear-gradient(135deg, #34d399 0%, #047857 100%);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border-subtle);
  color: var(--text-primary);
}
.btn-outline:hover {
  background: var(--bg-subtle);
  border-color: var(--text-muted);
}

.btn-outline-primary {
  background: transparent;
  border: 1.5px solid var(--primary-burgundy);
  color: var(--primary-burgundy);
}
.btn-outline-primary:hover {
  background: var(--primary-burgundy-soft);
}

.btn-danger {
  background: var(--danger);
  color: var(--text-white);
}
.btn-danger:hover {
  background: #dc2626;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-xs);
}

.btn-lg {
  padding: 14px 26px;
  font-size: 1.05rem;
  border-radius: var(--radius-md);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ================== عناصر النماذج (Forms & Inputs) ================== */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-label .required {
  color: var(--danger);
  margin-right: 2px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  font-family: var(--font-main);
  font-size: 0.9rem;
  color: var(--text-primary);
  background-color: #ffffff;
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  outline: none;
}

.form-control:focus {
  border-color: var(--primary-burgundy);
  box-shadow: 0 0 0 3.5px var(--primary-burgundy-soft);
}

.form-control::placeholder {
  color: var(--text-muted);
}

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

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-left: 36px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* ================== شريط رأس الصفحة (Page Header) ================== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-title-box h1 {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-title-box p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ================== الفلاتر وأدوات التحكم (Toolbar) ================== */
.toolbar-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.toolbar-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-input-box {
  position: relative;
  min-width: 260px;
}

.search-input-box input {
  padding-right: 38px;
}

.search-input-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* ================== الجداول الرسمية (Tables) ================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
}

.custom-table th {
  background: var(--bg-subtle);
  padding: 14px 16px;
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-secondary);
  border-bottom: 1.5px solid var(--border-subtle);
  white-space: nowrap;
}

.custom-table td {
  padding: 14px 16px;
  font-size: 0.88rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.custom-table tbody tr:hover {
  background-color: rgba(123, 17, 35, 0.02);
}

.custom-table tbody tr:last-child td {
  border-bottom: none;
}

/* ================== الإشعارات والتنبيهات الاحترافية (Luxury Toasts) ================== */
.toast-container {
  position: fixed;
  top: 24px;
  left: 24px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.toast-item {
  pointer-events: auto;
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  box-shadow: 0 16px 36px -6px rgba(0, 0, 0, 0.16), 0 4px 12px rgba(0, 0, 0, 0.06);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-width: 320px;
  max-width: 440px;
  position: relative;
  overflow: hidden;
  animation: slideToastIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  transition: all 0.3s ease;
}

.toast-item.toast-hiding {
  animation: slideToastOut 0.3s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes slideToastIn {
  from { transform: translateX(-100%) scale(0.9); opacity: 0; }
  to { transform: translateX(0) scale(1); opacity: 1; }
}

@keyframes slideToastOut {
  from { transform: translateX(0) scale(1); opacity: 1; }
  to { transform: translateX(-100%) scale(0.85); opacity: 0; }
}

.toast-icon-box {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.toast-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toast-title {
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.2;
}

.toast-message {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.toast-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 0.85rem;
  line-height: 1;
  transition: color var(--transition-fast);
}
.toast-close-btn:hover {
  color: var(--text-primary);
}

/* شريط التوقيت المتحرك أسفل الإشعار */
.toast-timer-bar {
  position: absolute;
  bottom: 0;
  right: 0;
  left: 0;
  height: 3.5px;
  background: currentColor;
  opacity: 0.35;
  animation: toastTimer 4.5s linear forwards;
}

@keyframes toastTimer {
  from { width: 100%; }
  to { width: 0%; }
}

/* سمات ألوان الإشعارات */
.toast-item.toast-success {
  border-right: 5px solid #10b981;
  background: linear-gradient(145deg, #ffffff 0%, #f0fdf4 100%);
}
.toast-item.toast-success .toast-icon-box {
  background: #10b981;
  color: #ffffff;
}
.toast-item.toast-success .toast-title {
  color: #065f46;
}
.toast-item.toast-success .toast-timer-bar {
  background: #10b981;
}

.toast-item.toast-danger {
  border-right: 5px solid #ef4444;
  background: linear-gradient(145deg, #ffffff 0%, #fef2f2 100%);
}
.toast-item.toast-danger .toast-icon-box {
  background: #ef4444;
  color: #ffffff;
}
.toast-item.toast-danger .toast-title {
  color: #991b1b;
}
.toast-item.toast-danger .toast-timer-bar {
  background: #ef4444;
}

.toast-item.toast-warning {
  border-right: 5px solid #f59e0b;
  background: linear-gradient(145deg, #ffffff 0%, #fffbeb 100%);
}
.toast-item.toast-warning .toast-icon-box {
  background: #f59e0b;
  color: #ffffff;
}
.toast-item.toast-warning .toast-title {
  color: #92400e;
}
.toast-item.toast-warning .toast-timer-bar {
  background: #f59e0b;
}

.toast-item.toast-info {
  border-right: 5px solid #7b1123;
  background: linear-gradient(145deg, #ffffff 0%, #fdf2f4 100%);
}
.toast-item.toast-info .toast-icon-box {
  background: linear-gradient(135deg, #7b1123, #500a16);
  color: #ffffff;
}
.toast-item.toast-info .toast-title {
  color: #7b1123;
}
.toast-item.toast-info .toast-timer-bar {
  background: #7b1123;
}

/* ================== استجابة الشاشات (Responsive) ================== */
@media (max-width: 768px) {
  .toast-container {
    top: 12px;
    left: 12px;
    right: 12px;
  }
  .toast-item {
    min-width: auto;
    max-width: 100%;
  }
  .form-grid-2, .form-grid-3 {
    grid-template-columns: 1fr;
  }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .page-actions {
    width: 100%;
  }
  .toolbar-card {
    flex-direction: column;
    align-items: stretch;
  }
  .search-input-box {
    min-width: 100%;
  }
}
