:root {
  --bg: #f4f5f7;
  --sidebar-bg: #111827;
  --sidebar-hover: #1f2937;
  --primary: #2563eb;
  --primary-soft: rgba(37, 99, 235, 0.08);
  --danger: #dc2626;
  --warning: #f59e0b;
  --success: #16a34a;
  --text-main: #111827;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --card-bg: #ffffff;
  --radius-lg: 16px;
  --radius-md: 10px;
}

/* نضمن ضبط البوكس داخل الحاوية */
.ews-shell,
.ews-shell * {
  box-sizing: border-box;
}

/* الحاوية العامة لصفحات EWS داخل لوحة التحكم */
.ews-shell {
  height: 100%;
  min-height: 100vh;
  display: flex;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, sans-serif;
  font-size: 15px; /* تكبير بسيط */
  background: var(--bg);
  color: var(--text-main);
  direction: rtl;
}


/* ===== Sidebar ===== */
.ews-shell .sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  color: #f9fafb;
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
}

.ews-shell .sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px 20px;
  border-bottom: 1px solid rgba(55, 65, 81, 0.9);
  margin-bottom: 16px;
}

.ews-shell .logo-badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #2563eb, #22c55e);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
}

.ews-shell .sidebar-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ews-shell .sidebar-title-main {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.ews-shell .sidebar-title-sub {
  font-size: 11px;
  color: #9ca3af;
}

.ews-shell .nav-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #6b7280;
  padding: 8px 8px 4px;
  margin-top: 8px;
}

.ews-shell .nav-list {
  list-style: none;
  margin-top: 4px;
}

.ews-shell .nav-item {
  margin-bottom: 4px;
}

.ews-shell .nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 10px;
  font-size: 13px;
  color: #e5e7eb;
  text-decoration: none;
  transition: background 0.2s, color 0.2s, transform 0.1s;
}

.ews-shell .nav-link span.icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.ews-shell .nav-link.active {
  background: rgba(37, 99, 235, 0.2);
  color: #f9fafb;
}

.ews-shell .nav-link:hover {
  background: var(--sidebar-hover);
  transform: translateX(-2px);
}

.ews-shell .sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(55, 65, 81, 0.9);
  font-size: 11px;
  color: #6b7280;
}

.ews-shell .sidebar-footer strong {
  color: #e5e7eb;
  font-weight: 500;
}

/* ===== Main layout ===== */
.ews-shell .main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ===== Topbar ===== */
.ews-shell .topbar {
  height: 60px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ews-shell .topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.ews-shell .page-title {
  font-size: 18px;
  font-weight: 600;
}

.ews-shell .page-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.ews-shell .breadcrumbs {
  font-size: 11px;
  color: var(--text-muted);
}

.ews-shell .breadcrumbs span {
  margin: 0 4px;
}

.ews-shell .topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ews-shell .badge-pill {
  background: var(--primary-soft);
  color: var(--primary);
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
}

.ews-shell .user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f3f4f6;
  font-size: 12px;
}

.ews-shell .user-avatar {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: linear-gradient(135deg, #22c55e, #2dd4bf);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: #064e3b;
}

/* ===== Content ===== */
.ews-shell .content {
  padding: 18px 20px 24px;
  overflow-y: auto;
}

.ews-shell .grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.ews-shell .card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 14px 14px 16px;
  border: 1px solid var(--border);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.03);
}

.ews-shell .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.ews-shell .card-title {
  font-size: 14px;
  font-weight: 600;
}

.ews-shell .card-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.ews-shell .card-tag {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f3f4f6;
  color: var(--text-muted);
}

.ews-shell .metric-main {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}

.ews-shell .metric-label {
  font-size: 12px;
  color: var(--text-muted);
}

.ews-shell .metric-trend {
  margin-top: 6px;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
}

.ews-shell .metric-trend.up {
  background: rgba(22, 163, 74, 0.08);
  color: var(--success);
}

.ews-shell .metric-trend.down {
  background: rgba(220, 38, 38, 0.08);
  color: var(--danger);
}

.ews-shell .metric-trend.neutral {
  background: #f3f4f6;
  color: var(--text-muted);
}

.ews-shell .pill-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
}

.ews-shell .pill-status.safe {
  background: rgba(22, 163, 74, 0.08);
  color: var(--success);
}

.ews-shell .pill-status.watch {
  background: rgba(245, 158, 11, 0.08);
  color: var(--warning);
}

.ews-shell .pill-status.danger {
  background: rgba(220, 38, 38, 0.08);
  color: var(--danger);
}

.ews-shell .pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
}

/* ===== Table ===== */
.ews-shell table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.ews-shell th,
.ews-shell td {
  padding: 8px 6px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.ews-shell th {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 11px;
}

.ews-shell tr:hover td {
  background: #f9fafb;
}

.ews-shell .chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
}

.ews-shell .chip-safe {
  background: rgba(22, 163, 74, 0.08);
  color: var(--success);
}

.ews-shell .chip-watch {
  background: rgba(245, 158, 11, 0.08);
  color: var(--warning);
}

.ews-shell .chip-danger {
  background: rgba(220, 38, 38, 0.08);
  color: var(--danger);
}

.ews-shell .chip-new {
  background: rgba(37, 99, 235, 0.08);
  color: var(--primary);
}

.ews-shell .text-muted {
  color: var(--text-muted);
}

.ews-shell .text-xs {
  font-size: 11px;
}

.ews-shell .text-sm {
  font-size: 12px;
}

.ews-shell .btn-link {
  border: none;
  background: none;
  padding: 0;
  font-size: 11px;
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline;
}

/* ===== Simple sparkline ===== */
.ews-shell .spark-row {
  display: flex;
  gap: 2px;
  align-items: flex-end;
  height: 40px;
  margin-top: 4px;
}

.ews-shell .spark-bar {
  flex: 1;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.12);
}

.ews-shell .spark-bar.fill-1 { height: 20%; }
.ews-shell .spark-bar.fill-2 { height: 35%; }
.ews-shell .spark-bar.fill-3 { height: 55%; }
.ews-shell .spark-bar.fill-4 { height: 80%; }
.ews-shell .spark-bar.fill-5 { height: 60%; }
.ews-shell .spark-bar.fill-6 { height: 30%; }

/* ===== Responsive ===== */
@media (max-width: 992px) {
  .ews-shell {
    flex-direction: column;
  }
  .ews-shell .sidebar {
    display: none;
  }
  .ews-shell .topbar {
    position: sticky;
    top: 0;
    z-index: 10;
  }
  .ews-shell .content {
    padding: 14px 12px 18px;
  }
  .ews-shell .grid {
    grid-template-columns: repeat(1, minmax(0, 1fr));
  }
}

@media (min-width: 993px) {
  .ews-shell .col-3 { grid-column: span 3 / span 3; }
  .ews-shell .col-4 { grid-column: span 4 / span 4; }
  .ews-shell .col-5 { grid-column: span 5 / span 5; }
  .ews-shell .col-6 { grid-column: span 6 / span 6; }
  .ews-shell .col-7 { grid-column: span 7 / span 7; }
  .ews-shell .col-12 { grid-column: span 12 / span 12; }
}

/* ===== تكبير عرض صفحات EWS داخل الادمن ===== */

body.toplevel_page_ews-dashboard #wpbody-content,
body.ews-dashboard_page_ews-companies #wpbody-content,
body.ews-dashboard_page_ews-company-details #wpbody-content,
body.ews-dashboard_page_ews-zscore #wpbody-content,
body.ews-dashboard_page_ews-sidem #wpbody-content {
  padding: 0; /* نشيل البادينغ الافتراضي للادمن */
}

/* نمد الواجهة لتستفيد من كامل العرض المتاح داخل الادمن */
body.toplevel_page_ews-dashboard .ews-shell,
body.ews-dashboard_page_ews-companies .ews-shell,
body.ews-dashboard_page_ews-company-details .ews-shell {
  min-height: calc(100vh - 32px);
}

/* === إزالة الحواف الخاصة بلوحة التحكم وجعل EWS Full Width === */

body.toplevel_page_ews-dashboard #wpcontent,
body.toplevel_page_ews-dashboard #wpbody-content,
body.ews-dashboard_page_ews-companies #wpcontent,
body.ews-dashboard_page_ews-companies #wpbody-content,
body.ews-dashboard_page_ews-company-details #wpcontent,
body.ews-dashboard_page_ews-company-details #wpbody-content,
body.ews-dashboard_page_ews-zscore #wpcontent,
body.ews-dashboard_page_ews-zscore #wpbody-content,
body.ews-dashboard_page_ews-sidem #wpcontent,
body.ews-dashboard_page_ews-sidem #wpbody-content {
    padding: 0 !important;
    margin: 0 !important;
}

/* تمديد المحتوى على كامل العرض */
body.toplevel_page_ews-dashboard #wpbody,
body.ews-dashboard_page_ews-companies #wpbody,
body.ews-dashboard_page_ews-company-details #wpbody,
body.ews-dashboard_page_ews-zscore #wpbody,
body.ews-dashboard_page_ews-sidem #wpbody {
    max-width: 100% !important;
}

/* إزالة المساحة التي يتركها wordpress على اليمين */
body.folded #wpcontent,
body:not(.auto-fold) #wpcontent {
    margin-right: 0 !important;
}

/* قيم سالبة في حقول فورميدابل
   نستخدم كلاس حاوية مثل negavalue-field في CSS Layout Classes للحقل */
.negavalue-field input[type="number"],
.negavalue-field input {
  color: inherit;
}

/* اذا القيمة تبدأ بسالب نخليها حمراء وثقيلة */
.negavalue-field input[value^="-"] {
  color: #d32f2f !important;
  font-weight: 600;
}
