/* ==========================================================================
   maliya-faraid.css — Стили калькулятора наследства (الفرائض)
   Дополнение к maliya-calculator.css
   ========================================================================== */

/* --- Исламское открытие --- */
.faraid-bismillah {
  text-align: center;
  margin: 16px 0 14px;
  padding: 10px 0;
  border-top: 1px solid #e5e7eb;
  border-bottom: 1px solid #e5e7eb;
}
.faraid-bismillah-ar {
  font-family: 'Amiri', serif;
  direction: rtl;
  font-size: 18px;
  color: #047857;
  line-height: 1.8;
}

/* --- Преамбула фетвы --- */
.faraid-preamble {
  font-size: 13.5px;
  line-height: 1.65;
  color: #374151;
  background: #f9fafb;
  border-inline-start: 3px solid #059669;
  padding: 12px 16px;
  border-radius: 0 8px 8px 0;
  margin-bottom: 16px;
  text-align: justify;
}

/* --- Итоговая строка таблицы --- */
.faraid-results-table tfoot .faraid-total-row td {
  background: #f0fdf4;
  border-top: 2px solid #059669;
  border-bottom: none;
  color: #065f46;
  padding: 12px;
}

/* --- Остаток --- */
.faraid-residue-note {
  margin-top: 14px;
  padding: 12px 16px;
  background: #fefce8;
  border-inline-start: 3px solid #eab308;
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  line-height: 1.6;
  color: #854d0e;
}

/* --- Заключение (والله أعلم) --- */
.faraid-closing {
  text-align: center;
  margin: 24px 0 12px;
  padding: 14px 0;
  border-top: 1px solid #e5e7eb;
}
.faraid-closing-text {
  font-size: 13px;
  color: #4b5563;
  font-style: italic;
  margin-bottom: 6px;
}
.faraid-closing-ar {
  font-family: 'Amiri', serif;
  direction: rtl;
  font-size: 18px;
  color: #047857;
}

.night-mode .faraid-bismillah { border-color: #374151; }
.night-mode .faraid-bismillah-ar { color: #34d399; }
.night-mode .faraid-preamble { background: #1f2937; color: #d1d5db; }
.night-mode .faraid-results-table tfoot .faraid-total-row td { background: #064e3b; color: #d1fae5; }
.night-mode .faraid-residue-note { background: #422006; color: #fef9c3; }
.night-mode .faraid-closing { border-color: #374151; }
.night-mode .faraid-closing-text { color: #9ca3af; }
.night-mode .faraid-closing-ar { color: #34d399; }

/* --- Степы формы --- */
.faraid-step { display: none; }
.faraid-step.active { display: block; }

/* --- Блоки вопросов на экране 1 --- */
.faraid-block {
  padding: 14px 16px;
  margin-bottom: 14px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
}
.faraid-block-title {
  font-size: 14px;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 6px;
}
.faraid-info-note {
  font-size: 12px;
  line-height: 1.5;
  color: #6b7280;
  margin: 4px 0 10px;
  padding-inline-start: 10px;
  border-inline-start: 2px solid #d1d5db;
}
.faraid-global-flag-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  color: #1f2937;
}
.faraid-global-flag-label input[type="checkbox"] {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  accent-color: #059669;
  flex-shrink: 0;
}

/* --- Поле ввода суммы на экране 3 --- */
.faraid-estate-input-block {
  padding: 14px 16px;
  margin-bottom: 16px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
}
.faraid-estate-input-block .maliya-input { margin-top: 6px; }

/* --- Условное отображение per-heir флажков --- */
.maliya-calc:not(.show-killer-flags) .faraid-flag-killer-item { display: none; }
.maliya-calc:not(.show-religion-flags) .faraid-flag-religion-item { display: none; }
.maliya-calc:not(.show-mafqud-flags) .faraid-flag-mafqud-item { display: none; }
.maliya-calc:not(.show-khuntha-flags) .faraid-flag-khuntha-item { display: none; }
.maliya-calc:not(.show-killer-flags):not(.show-religion-flags):not(.show-mafqud-flags):not(.show-khuntha-flags) .faraid-heir-flags { display: none !important; }

/* --- Фаза 2: التخارج и موقوف --- */
.faraid-takharuj-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
}
.faraid-takharuj-count {
  width: 64px;
  padding: 4px 8px;
}
.faraid-mawquf-cell { color: #b45309; font-weight: 600; }
.faraid-mawquf-row td { background: #fffbeb; }
.night-mode .faraid-mawquf-cell { color: #fbbf24; }
.night-mode .faraid-mawquf-row td { background: rgba(180, 83, 9, 0.15); }

.night-mode .faraid-block { background: #1f2937; border-color: #374151; }
.night-mode .faraid-block-title { color: #f3f4f6; }
.night-mode .faraid-info-note { color: #9ca3af; border-color: #4b5563; }
.night-mode .faraid-global-flag-label { color: #f3f4f6; }
.night-mode .faraid-estate-input-block { background: #064e3b; border-color: #059669; }

/* --- Памятка (info box) --- */
.faraid-info-box {
  background: #ecfdf5;
  border-inline-start: 3px solid #059669;
  padding: 12px 16px;
  margin-bottom: 16px;
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  line-height: 1.6;
  color: #065f46;
}
.faraid-info-box .faraid-info-ar {
  font-family: 'Amiri', serif;
  direction: rtl;
  display: inline;
}

/* --- Предупреждение --- */
.faraid-warning-box {
  background: #fefce8;
  border-inline-start: 3px solid #eab308;
  padding: 12px 16px;
  margin-top: 12px;
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  color: #854d0e;
}

/* --- Блок завещаний --- */
.faraid-bequest-list { margin-top: 8px; }
.faraid-bequest-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.faraid-bequest-row .maliya-input { flex: 1; }
.faraid-bequest-row .faraid-bequest-desc { flex: 2; }
.faraid-bequest-remove {
  background: none;
  border: none;
  color: #ef4444;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
.faraid-bequest-remove:hover { background: #fef2f2; }
.faraid-add-bequest {
  background: none;
  border: 1px dashed #d1d5db;
  color: #059669;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  margin-top: 4px;
}
.faraid-add-bequest:hover { background: #ecfdf5; border-color: #059669; }

/* --- Строка наследника --- */
.faraid-heir-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid #f3f4f6;
}
.faraid-heir-row:last-child { border-bottom: none; }

.faraid-heir-check {
  width: 18px;
  height: 18px;
  accent-color: #059669;
  cursor: pointer;
  flex-shrink: 0;
}

.faraid-heir-label {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  cursor: pointer;
}
.faraid-heir-label-ru { font-size: 14px; color: #1f2937; }
.faraid-heir-label-ar {
  font-family: 'Amiri', serif;
  direction: rtl;
  text-align: end;
  font-size: 14px;
  color: #6b7280;
}

.faraid-heir-count {
  width: 56px;
  padding: 6px 8px;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  text-align: center;
  font-size: 14px;
  display: none;
}
.faraid-heir-count:focus { border-color: #059669; outline: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--emerald) 15%, transparent); }
.faraid-heir-row.active .faraid-heir-count { display: block; }

/* --- Флажки محروم (убийца, другая религия) --- */
.faraid-heir-flags {
  display: none;
  padding: 4px 0 8px 28px;
  font-size: 13px;
  color: #6b7280;
}
.faraid-heir-flags label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
  cursor: pointer;
}
.faraid-heir-flags input[type="checkbox"] {
  accent-color: #ef4444;
}
.faraid-heir-row.active + .faraid-heir-flags { display: block; }

/* --- Таблица результатов --- */
.faraid-results-wrapper { overflow-x: auto; margin: 16px 0; }

.faraid-results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.faraid-results-table th {
  background: #f9fafb;
  padding: 10px 12px;
  text-align: start;
  font-weight: 600;
  font-size: 13px;
  color: #374151;
  border-bottom: 2px solid #e5e7eb;
  white-space: nowrap;
}
.faraid-results-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f3f4f6;
  color: #1f2937;
}
.faraid-results-table tr:last-child td { border-bottom: none; }
.faraid-results-table .faraid-share-cell {
  font-family: 'Amiri', serif;
  font-size: 16px;
  direction: rtl;
  text-align: center;
  white-space: nowrap;
}
.faraid-results-table .faraid-amount-cell {
  font-weight: 600;
  text-align: end;
  white-space: nowrap;
}
.faraid-results-table .faraid-subrow td {
  background: #fafafa;
  font-size: 13px;
  color: #6b7280;
  border-bottom: 1px dashed #f3f4f6;
}
.faraid-results-table .faraid-subrow .faraid-subrow-name {
  padding-inline-start: 28px;
}
.faraid-results-table .faraid-subrow .faraid-amount-cell {
  font-weight: 500;
  color: #374151;
}
.night-mode .faraid-results-table .faraid-subrow td { background: #111827; color: #9ca3af; border-color: #374151; }
.night-mode .faraid-results-table .faraid-subrow .faraid-amount-cell { color: #d1d5db; }

/* --- Сводка тарики --- */
.faraid-estate-summary {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 20px;
  background: #f9fafb;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}
.faraid-estate-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
}
.faraid-estate-row.total {
  border-top: 2px solid #059669;
  margin-top: 6px;
  padding-top: 8px;
  font-weight: 700;
  font-size: 16px;
  color: #059669;
}
.faraid-estate-row .deduction { color: #ef4444; }

/* --- Бейдж типа масали --- */
.faraid-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}
.faraid-type-badge.adila  { background: #ecfdf5; color: #059669; }
.faraid-type-badge.awl    { background: #fff7ed; color: #ea580c; }
.faraid-type-badge.asaba  { background: #eff6ff; color: #2563eb; }
.faraid-type-badge.radd   { background: #eff6ff; color: #2563eb; }

/* --- Мухарадж / тасхих --- */
.faraid-meta-row {
  display: flex;
  gap: 20px;
  align-items: center;
  margin: 12px 0 16px;
  font-size: 13px;
  color: #6b7280;
}
.faraid-meta-row span { font-weight: 600; color: #374151; }

/* --- Исключённые наследники --- */
.faraid-excluded {
  margin-top: 16px;
  padding: 12px 16px;
  background: #fef2f2;
  border-radius: 8px;
  border: 1px solid #fecaca;
}
.faraid-excluded-title {
  font-weight: 600;
  font-size: 14px;
  color: #991b1b;
  margin-bottom: 8px;
}
.faraid-excluded-item {
  font-size: 13px;
  color: #7f1d1d;
  padding: 4px 0;
}
.faraid-excluded-item .faraid-excluded-ar {
  font-family: 'Amiri', serif;
  direction: rtl;
}

/* --- Пояснения (как рассчитано) --- */
.faraid-explanation {
  margin-top: 20px;
  padding: 16px 20px;
  background: #f9fafb;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}
.faraid-explanation-title {
  font-weight: 600;
  font-size: 14px;
  color: #374151;
  margin-bottom: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.faraid-explanation-title .chevron {
  transition: transform 0.2s;
  font-size: 12px;
}
.faraid-explanation.open .chevron { transform: rotate(90deg); }
.faraid-explanation-body {
  display: none;
  font-size: 13px;
  line-height: 1.8;
  color: #4b5563;
}
.faraid-explanation.open .faraid-explanation-body { display: block; }
.faraid-explanation-item {
  padding: 4px 0;
  border-bottom: 1px solid #f3f4f6;
}
.faraid-explanation-item:last-child { border-bottom: none; }

/* --- Дисклеймер --- */
.faraid-disclaimer {
  font-size: 13px;
  color: #6b7280;
  margin-top: 20px;
  padding: 12px 16px;
  background: #f9fafb;
  border-radius: 8px;
  line-height: 1.6;
}

/* --- Кнопки действий результатов --- */
.faraid-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

/* --- Навигация степов --- */
.faraid-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
}

/* --- Ошибки валидации --- */
.faraid-errors {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
}
.faraid-error-item {
  color: #991b1b;
  font-size: 13px;
  padding: 2px 0;
}

/* --- Спецсообщение (ذوي الأرحام, нет имущества) --- */
.faraid-special-msg {
  text-align: center;
  padding: 40px 20px;
  color: #6b7280;
}
.faraid-special-msg-icon { font-size: 48px; margin-bottom: 12px; }
.faraid-special-msg-text { font-size: 15px; line-height: 1.7; max-width: 480px; margin: 0 auto; }
.faraid-special-msg .faraid-special-ar {
  font-family: 'Amiri', serif;
  direction: rtl;
  font-size: 18px;
  margin-top: 8px;
  color: #374151;
}

/* --- Печать --- */
@media print {
  .maliya-header, .maliya-tabs-bar, .maliya-prices-bar,
  .module-footer, .faraid-nav, .faraid-actions,
  .faraid-step:not(.active) { display: none !important; }
  .faraid-step.active { display: block !important; }
  .maliya-section { display: block !important; }
  .faraid-disclaimer { border: 1px solid #ccc; }
}

/* --- Адаптивность --- */
@media (max-width: 768px) {
  .faraid-results-table { font-size: 13px; }
  .faraid-results-table th,
  .faraid-results-table td { padding: 8px 6px; }
  .faraid-heir-row { flex-wrap: wrap; }
  .faraid-heir-label-ar { text-align: start; }
  .faraid-estate-summary { padding: 12px 14px; }
  .faraid-meta-row { flex-wrap: wrap; gap: 8px; }
  .faraid-bequest-row { flex-wrap: wrap; }
  .faraid-bequest-row .maliya-input,
  .faraid-bequest-row .faraid-bequest-desc { flex: 1 1 100%; }
  .faraid-actions { flex-direction: column; }
  .faraid-actions .maliya-btn { width: 100%; text-align: center; }
}

@media (max-width: 480px) {
  .faraid-heir-count { width: 48px; }
  .faraid-heir-flags { padding-inline-start: 0; }
}

/* --- Тёмная тема --- */
.night-mode .faraid-info-box { background: #064e3b; border-color: #059669; color: #d1fae5; }
.night-mode .faraid-warning-box { background: #422006; border-color: #ca8a04; color: #fef9c3; }
.night-mode .faraid-heir-label-ru { color: #f3f4f6; }
.night-mode .faraid-heir-label-ar { color: #9ca3af; }
.night-mode .faraid-heir-count { background: #1f2937; border-color: #374151; color: #f3f4f6; }
.night-mode .faraid-heir-row { border-color: #374151; }
.night-mode .faraid-heir-flags { color: #9ca3af; }
.night-mode .faraid-results-table th { background: #1f2937; color: #d1d5db; border-color: #374151; }
.night-mode .faraid-results-table td { color: #e5e7eb; border-color: #374151; }
.night-mode .faraid-estate-summary { background: #1f2937; }
.night-mode .faraid-estate-row { color: #d1d5db; }
.night-mode .faraid-excluded { background: #450a0a; border-color: #7f1d1d; }
.night-mode .faraid-excluded-title { color: #fca5a5; }
.night-mode .faraid-excluded-item { color: #fecaca; }
.night-mode .faraid-explanation { background: #1f2937; border-color: #374151; }
.night-mode .faraid-explanation-title { color: #d1d5db; }
.night-mode .faraid-explanation-body { color: #9ca3af; }
.night-mode .faraid-explanation-item { border-color: #374151; }
.night-mode .faraid-disclaimer { background: #1f2937; color: #9ca3af; }
.night-mode .faraid-errors { background: #450a0a; border-color: #7f1d1d; }
.night-mode .faraid-error-item { color: #fca5a5; }
.night-mode .faraid-special-msg { color: #9ca3af; }
.night-mode .faraid-nav { border-color: #374151; }
.night-mode .faraid-add-bequest { border-color: #374151; color: #34d399; }
.night-mode .faraid-add-bequest:hover { background: #064e3b; }
.night-mode .faraid-bequest-remove:hover { background: #450a0a; }
