/* ==========================================================================
   KALKULATOR WARIS FARAIDH - MINIMALIST FLAT MOBILE UI
   No shadows, no gradients, clean 1px borders, crisp typography
   ========================================================================== */

:root {
  --bg-outer: #eceae4;
  --bg-app: #f7f6f2;
  --bg-card: #ffffff;
  --bg-card-alt: #f0f4f1;
  --bg-input: #ffffff;
  --text-primary: #18181b;
  --text-secondary: #3f3f46;
  --text-muted: #71717a;
  --border-color: #e4e2dd;
  --border-strong: #d4d1c9;
  --border-accent: #b8d4c3;
  --emerald-dark: #094223;
  --emerald-main: #0c592f;
  --emerald-light: #0f6e3a;
  --emerald-soft: #eaf3ed;
  --gold-main: #b8943c;
  --gold-light: #e5d196;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --danger-border: #f8d7da;
}

body.dark-mode {
  --bg-outer: #090b0e;
  --bg-app: #111418;
  --bg-card: #181c22;
  --bg-card-alt: #16221c;
  --bg-input: #14181d;
  --text-primary: #f4f4f5;
  --text-secondary: #d4d4d8;
  --text-muted: #9ca3af;
  --border-color: #272c35;
  --border-strong: #343b46;
  --border-accent: #204030;
  --emerald-soft: #15271e;
  --danger-bg: #271416;
  --danger-border: #522126;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-outer);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg-app);
  min-height: 100vh;
  position: relative;
  border-left: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  padding-bottom: 84px;
  overflow-x: hidden;
}

/* ===== HEADER ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--emerald-main);
  padding: 13px 16px;
  border-bottom: 1px solid var(--emerald-dark);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 15px;
}

.brand-title h1 {
  font-size: 15.5px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.2px;
  line-height: 1.2;
}

.brand-title span {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.75);
  font-weight: 400;
  display: block;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-header-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  cursor: pointer;
}

.btn-header-icon:active {
  background: rgba(255, 255, 255, 0.15);
}

.badge-faraid {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  font-size: 11px;
  font-weight: 500;
  padding: 5px 9px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* ===== QUICK SUMMARY BANNER ===== */
.top-summary-bar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 9px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.top-summary-bar .pewaris-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-summary-bar .pewaris-info i {
  color: var(--text-muted);
  font-size: 12px;
}

.top-summary-bar .harta-pill {
  color: var(--emerald-light);
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
}

/* ===== PAGE SECTIONS ===== */
.page-section {
  padding: 16px 16px 24px;
}

.page-section.hidden {
  display: none;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-title i {
  color: var(--text-muted);
  font-size: 12px;
}

/* ===== CARD STYLING (FLAT, NO SHADOW) ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 16px;
}

/* ===== GENDER SELECTOR (PEWARIS) ===== */
.gender-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 6px;
}

.gender-option {
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  border-radius: 6px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
}

.gender-option i {
  font-size: 16px;
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 5px;
  background: var(--bg-app);
  display: flex;
  align-items: center;
  justify-content: center;
}

.gender-option .g-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.gender-option .g-sub {
  font-size: 10.5px;
  color: var(--text-muted);
}

.gender-option.active {
  border-color: var(--emerald-main);
  background: var(--bg-card-alt);
}

.gender-option.active i {
  background: var(--emerald-main);
  color: #ffffff;
}

/* ===== FORM INPUTS ===== */
.form-group {
  margin-bottom: 12px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

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

.form-input:focus, .form-select:focus {
  border-color: var(--emerald-main);
}

.input-prefix-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-prefix-wrap .prefix {
  position: absolute;
  left: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  pointer-events: none;
}

.input-prefix-wrap .form-input {
  padding-left: 36px;
  font-weight: 600;
}

/* ===== AHLI WARIS CATEGORY & GRID ===== */
.aw-group-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.aw-group-header {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.grid-2-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.counter-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 9px;
  border-radius: 6px;
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  min-height: 46px;
}

.counter-wrapper.has-value {
  background: var(--bg-card-alt);
  border-color: var(--emerald-main);
}

.counter-wrapper.disabled-heir {
  opacity: 0.4;
  pointer-events: none;
}

.counter-label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.25;
  padding-right: 4px;
}

.counter-label .arab-sub {
  font-family: 'Tajawal', sans-serif;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}

.counter-control {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.btn-counter {
  width: 25px;
  height: 25px;
  border-radius: 5px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-minus {
  background: var(--bg-card);
  border-color: var(--border-strong);
  color: var(--text-secondary);
}

.btn-plus {
  background: var(--emerald-main);
  color: #ffffff;
}

.btn-counter:active {
  opacity: 0.8;
}

.counter-val {
  min-width: 18px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

/* ===== HARTA ITEMS LIST ===== */
.harta-list-empty {
  text-align: center;
  padding: 20px 12px;
  color: var(--text-muted);
  font-size: 12.5px;
  border: 1px dashed var(--border-strong);
  border-radius: 6px;
  margin-bottom: 12px;
}

.harta-item-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  margin-bottom: 8px;
}

.harta-item-info .h-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.harta-item-info .h-desc {
  font-size: 11.5px;
  color: var(--text-muted);
}

.harta-item-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.harta-item-val {
  font-size: 13px;
  font-weight: 700;
  color: var(--emerald-light);
}

.btn-icon-sm {
  width: 28px;
  height: 28px;
  border-radius: 5px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
}

.btn-icon-sm.delete {
  color: var(--danger);
  border-color: var(--danger-border);
}

/* ===== WARNING BANNER (WASIAT > 1/3) ===== */
.alert-warning-box {
  display: none;
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 12px;
  margin-top: 8px;
  line-height: 1.4;
}

.alert-warning-box.show {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

/* ===== SUMMARY TIRKAH BOX ===== */
.tirkah-summary-box {
  background: var(--bg-card);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 14px;
  border: 1px solid var(--border-strong);
  margin-bottom: 16px;
}

.tirkah-row {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.tirkah-total-divider {
  border-top: 1px solid var(--border-color);
  margin: 10px 0;
}

.tirkah-net-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tirkah-net-row .lbl {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
}

.tirkah-net-row .val {
  font-size: 17px;
  font-weight: 800;
  color: var(--emerald-main);
}

body.dark-mode .tirkah-net-row .val {
  color: #34d399;
}

/* ===== BUTTONS ===== */
.btn-primary {
  width: 100%;
  padding: 12px 16px;
  border-radius: 6px;
  border: 1px solid var(--emerald-dark);
  background: var(--emerald-main);
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary:active {
  opacity: 0.9;
}

.btn-gold {
  width: 100%;
  padding: 11px 14px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--bg-app);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-gold:active {
  background: var(--border-color);
}

.action-btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

/* ===== RESULT TABLES ===== */
.case-status-banner {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.case-status-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.case-badge {
  background: var(--emerald-soft);
  color: var(--emerald-main);
  border: 1px solid var(--border-accent);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
}

body.dark-mode .case-badge {
  color: #6ee7b7;
}

.ashl-pill {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
}

.case-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  margin-bottom: 16px;
}

.faraid-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.faraid-table th {
  background: var(--bg-app);
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-strong);
  padding: 9px 8px;
  font-weight: 600;
  text-align: left;
  font-size: 11.5px;
}

.faraid-table td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  vertical-align: middle;
}

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

.faraid-table.arab-table {
  direction: rtl;
  font-family: 'Tajawal', sans-serif;
  font-size: 14px;
}

.faraid-table.arab-table th {
  text-align: right;
  background: var(--bg-app);
  border-bottom: 1px solid var(--border-strong);
}

.mahjub-card-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mahjub-item {
  background: var(--bg-card);
  border: 1px solid var(--danger-border);
  border-radius: 6px;
  padding: 9px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.mahjub-item .m-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--danger);
}

.mahjub-item .m-reason {
  font-size: 11.5px;
  color: var(--text-secondary);
}

.mahjub-item .m-arab {
  font-family: 'Tajawal', sans-serif;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--danger);
  padding: 2px 6px;
  border: 1px solid var(--danger-border);
  border-radius: 4px;
  flex-shrink: 0;
}

/* ===== DEVELOPER CONTACT BOX ===== */
.dev-contact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-app);
  text-decoration: none;
  color: var(--text-primary);
  font-size: 12.5px;
  margin-top: 8px;
}

.dev-contact-row:hover {
  border-color: var(--emerald-main);
}

/* ===== MODAL POPUP ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  display: none;
  align-items: flex-end;
  justify-content: center;
}

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

.modal-sheet {
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  background: var(--bg-card);
  border-top: 1px solid var(--border-strong);
  border-radius: 12px 12px 0 0;
  padding: 16px;
  overflow-y: auto;
}

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

.modal-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.jenis-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}

.jenis-btn {
  padding: 9px 10px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-app);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-align: left;
}

.jenis-btn i {
  font-size: 14px;
  color: var(--text-secondary);
  width: 22px;
  text-align: center;
}

.jenis-btn .j-lbl {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.jenis-btn.active {
  border-color: var(--emerald-main);
  background: var(--bg-card-alt);
}

.jenis-btn.active i {
  color: var(--emerald-main);
}

/* ===== BOTTOM NAVIGATION (FLAT, NO SHADOW) ===== */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  padding: 6px 6px max(8px, env(safe-area-inset-bottom));
  z-index: 100;
}

.nav-item {
  flex: 1;
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 4px;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 500;
  cursor: pointer;
  position: relative;
}

.nav-item i {
  font-size: 16px;
}

.nav-item.active {
  color: var(--emerald-main);
  font-weight: 700;
}

body.dark-mode .nav-item.active {
  color: #34d399;
}

.nav-badge {
  position: absolute;
  top: 2px;
  right: 24%;
  background: var(--emerald-main);
  color: #ffffff;
  font-size: 9px;
  font-weight: 700;
  min-width: 15px;
  height: 15px;
  border-radius: 99px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ===== TOAST NOTIFICATION ===== */
#toast-container {
  position: fixed;
  bottom: 76px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 90%;
  max-width: 420px;
  pointer-events: none;
}

.toast-msg {
  background: #18181b;
  color: #ffffff;
  border: 1px solid #3f3f46;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
}

/* ===== PRINT MEDIA ===== */
@media print {
  body {
    background: #ffffff !important;
  }
  #app {
    max-width: 100% !important;
    border: none !important;
    padding-bottom: 0 !important;
  }
  .app-header, #bottom-nav, .no-print {
    display: none !important;
  }
  .page-section {
    display: block !important;
  }
}
