:root {
  --bg: #F7F3ED;
  --surface: #FFFFFF;
  --text-primary: #2B2140;
  --text-secondary: #8A8378;
  --accent: #6E4FE0;
  --accent-soft: #EFE9FB;
  --border: #E7E1D6;
  --shadow: 0 1px 3px rgba(43, 33, 64, 0.06), 0 8px 24px rgba(43, 33, 64, 0.04);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'IBM Plex Sans Arabic', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
}

/* ===== الهيكل العام: Sidebar (يسار) + محتوى + لوحة يمين ===== */
.app-shell {
  direction: ltr; /* يثبت ترتيب الأعمدة بصريًا مثل الصورة المرجعية */
  display: flex;
  min-height: 100vh;
}

.sidebar {
  direction: rtl;
  width: 230px;
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar .brand {
  font-weight: 700;
  font-size: 18px;
  color: var(--accent);
  padding: 0 8px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 10px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.15s ease;
}

.sidebar-link:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.sidebar-link.active {
  background: var(--accent);
  color: #fff;
}

.sidebar-icon {
  font-size: 16px;
}

.right-panel {
  direction: rtl;
  width: 280px;
  flex-shrink: 0;
  padding: 24px 20px;
  border-right: 1px solid var(--border);
}

@media (max-width: 960px) {
  .sidebar, .right-panel { display: none; }
}

.workspace {
  direction: rtl;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 24px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.section-title {
  width: 100%;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.hero {
  text-align: center;
  margin-bottom: 40px;
}

.hero h1 {
  font-size: 34px;
  font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}

.datetime {
  font-size: 15px;
  color: var(--text-secondary);
  font-weight: 500;
}

.capture {
  width: 100%;
  margin-bottom: 20px;
}

#entryInput {
  width: 100%;
  padding: 20px 24px;
  font-size: 17px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: var(--shadow);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#entryInput::placeholder {
  color: var(--text-secondary);
}

#entryInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow);
}

/* ===== أزرار صغيرة عامة (تستخدم بالمعادلات وزر الحفظ) ===== */
.tool-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tool-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* ===== قائمة الوحدات المستقلة (الحاسبات، ملاحظات/بريد لاحقًا) ===== */
.modules-row {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start; /* بـ RTL هذا يعني محاذاة لليمين */
  gap: 4px;
  margin-bottom: 20px;
}

.module-nav-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  text-decoration: none;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  transition: all 0.15s ease;
}

.module-nav-item:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.module-nav-icon {
  font-size: 15px;
}

/* ===== بطاقات الداشبورد الذكية ===== */
.dashboard-cards {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 32px;
}

.dash-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 12px;
  text-decoration: none;
  color: var(--text-primary);
  cursor: pointer;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  text-align: center;
  transition: all 0.15s ease;
  box-shadow: var(--shadow);
  flex: 1 1 130px;
  min-width: 110px;
}

.dash-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.dash-card-icon {
  font-size: 24px;
}

.dash-card-edit {
  flex: 0 0 auto;
  min-width: 0;
  width: 52px;
  padding: 20px 8px;
  border-style: dashed;
  color: var(--text-secondary);
}

.dash-card-edit .dash-card-icon {
  font-size: 18px;
}

.dash-card-edit span:last-child {
  display: none; /* نخفي النص، أيقونة فقط لتوفير مساحة الصف */
}

.dash-card-edit:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ===== قائمة اختيار الحاسبات المثبتة ===== */
.picker-category {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin: 14px 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.picker-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.picker-item:hover {
  background: var(--bg);
}

.picker-item input {
  cursor: pointer;
}

.picker-item.disabled {
  opacity: 0.35;
  pointer-events: none;
}

.entries {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-state {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  padding: 8px 0;
}

.entry-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 15px;
  animation: fadeIn 0.2s ease;
}

.entry-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.entry-text {
  flex: 1;
}

.entry-delete {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.15s ease, color 0.15s ease;
}

.entry-delete:hover {
  background: #FBEAEA;
  color: #C0392B;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== النوافذ المنبثقة (Modals) ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(43, 33, 64, 0.35);
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--surface);
  border-radius: 18px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 50px rgba(43, 33, 64, 0.2);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 17px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.modal-close:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.modal-body {
  padding: 20px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 10px;
}

.modal-input {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text-primary);
  outline: none;
}

.modal-input:focus {
  border-color: var(--accent);
}

.modal-input.small {
  width: 100%;
}

.date-select-row {
  display: grid;
  grid-template-columns: 1fr 1.6fr 1.2fr;
  gap: 8px;
  margin-bottom: 4px;
}

.date-select {
  width: 100%;
  padding: 12px 10px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
  text-align: center;
}

.date-select:focus {
  border-color: var(--accent);
}

.segmented {
  display: flex;
  background: var(--bg);
  border-radius: 10px;
  padding: 4px;
  gap: 4px;
}

.seg-btn {
  flex: 1;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 9px;
  border-radius: 8px;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow);
}

.result-box {
  margin-top: 16px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  font-size: 15px;
  padding: 14px 16px;
  border-radius: 10px;
  text-align: center;
  min-height: 20px;
}

.result-details {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modal-label input[type="checkbox"] {
  margin-left: 6px;
  vertical-align: middle;
}

@media (max-width: 600px) {
  .hero h1 { font-size: 24px; }
  #entryInput { padding: 16px 18px; font-size: 15px; }
}

/* ===== تقويم اللوحة اليمنى ===== */
.calendar-widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-weight: 700;
  font-size: 14px;
}

.cal-nav-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 6px;
}
.cal-nav-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
}

.cal-day-name {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 600;
  padding-bottom: 6px;
}

.cal-date {
  font-size: 12.5px;
  padding: 6px 0;
  border-radius: 8px;
  color: var(--text-primary);
}

.cal-date.muted {
  color: var(--border);
}

.cal-date.today {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}
