/* =========================================================
   Family OS — Full Plan UI extensions (styles-fp.css)
   Loaded AFTER styles.css. Adds search, reminders, users,
   history, locations, backups, settings RTL polish, mobile.
   ========================================================= */

/* --------- Global search dropdown --------- */
.search { position: relative; }
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-start: 0;
  inset-inline-end: 0;
  background: #fff;
  border: 1px solid #e8dccb;
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(74, 61, 44, 0.18);
  z-index: 80;
  max-height: 420px;
  overflow-y: auto;
  padding: 6px;
}
.search-row {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s ease;
}
.search-row:hover { background: #faf3ec; }
.search-icon {
  font-size: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  background: #faf3ec;
  border-radius: 10px;
}
.search-body { min-width: 0; }
.search-title { font-weight: 600; color: #4a3d2c; }
.search-meta { font-size: 12px; }
.search-kind {
  font-size: 11px;
  color: #8b7a5e;
  background: #f4ead9;
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
.search-empty { padding: 18px; text-align: center; }

/* --------- Reminders grid --------- */
.reminders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.reminder-card {
  background: #fff;
  border: 1px solid #ecd9c0;
  border-radius: 16px;
  padding: 14px;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 10px;
  align-items: center;
  box-shadow: 0 2px 8px rgba(74, 61, 44, 0.05);
  border-inline-start: 4px solid #c2622e;
}
.reminder-card.t-birthday   { border-inline-start-color: #d4a017; }
.reminder-card.t-yahrzeit   { border-inline-start-color: #6d5a4a; background: #fbf6ee; }
.reminder-card.t-event      { border-inline-start-color: #5b8b78; }
.reminder-card.t-bar_mitzvah{ border-inline-start-color: #b08bbf; }
.reminder-icon {
  font-size: 26px;
  width: 44px; height: 44px;
  background: #faf3ec;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.reminder-title { font-weight: 700; color: #4a3d2c; }
.reminder-meta  { font-size: 12px; color: #8b7a5e; margin-top: 2px; }
.reminder-hebrew { font-size: 12px; color: #6d5a4a; margin-top: 4px; }
.reminder-when {
  font-weight: 700;
  color: #c2622e;
  background: #fcefe2;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  white-space: nowrap;
}

/* --------- Users / roles table --------- */
.role-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #f4ead9;
  color: #6d5a4a;
}
.role-pill.role-owner        { background: #fde6d5; color: #a14a14; }
.role-pill.role-admin        { background: #fcefe2; color: #c2622e; }
.role-pill.role-editor       { background: #e6f2ee; color: #4f7b69; }
.role-pill.role-contributor  { background: #fff3cd; color: #8b6914; }
.role-pill.role-viewer       { background: #f0e8f5; color: #7a5d8d; }
.role-pill.role-event_guest  { background: #f4ead9; color: #6d5a4a; }
.role-pill.role-guest_viewer { background: #f9f3e6; color: #8b7a5e; }

/* --------- Audit history --------- */
.audit-action {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: #f4ead9;
  color: #6d5a4a;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.audit-action.a-create  { background: #e6f2ee; color: #4f7b69; }
.audit-action.a-update  { background: #f0e8f5; color: #7a5d8d; }
.audit-action.a-delete  { background: #fbe0e0; color: #b04a4a; }
.audit-action.a-import  { background: #fcefe2; color: #c2622e; }
.audit-action.a-backup  { background: #dcebe4; color: #4f7b69; }

/* --------- Generic small util --------- */
.mono { font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, monospace; font-size: 12px; }
.small { font-size: 12px; }
.field-inline-hint {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: #8b7a5e;
  margin: -6px 0 10px 0;
}
.card-actions {
  display: flex; gap: 8px; margin-top: 10px;
}
.radio-list label.radio {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px;
  cursor: pointer;
}
.radio-list label.radio:hover { background: #faf3ec; }
label.check {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0; cursor: pointer;
}
.select {
  background: #fff;
  border: 1px solid #e8dccb;
  border-radius: 10px;
  padding: 8px 12px;
  color: #4a3d2c;
  font: inherit;
}

/* --------- Tree node hebrew label --------- */
.tree-node-hebrew {
  font-family: "David Libre", "Frank Ruhl Libre", serif;
}

/* --------- Linked grid --------- */
#linkedGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.linked-card {
  background: #fff;
  border: 1px solid #e8dccb;
  border-radius: 16px;
  padding: 16px;
  border-inline-start: 4px solid #b08bbf;
  box-shadow: 0 2px 8px rgba(74, 61, 44, 0.05);
}
.linked-mode {
  display: inline-block;
  background: #f0e8f5; color: #7a5d8d;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700;
  margin-bottom: 8px;
}

/* --------- Mobile / RTL polish --------- */
@media (max-width: 980px) {
  .reminders-grid { grid-template-columns: 1fr; }
  .reminder-card { grid-template-columns: 40px 1fr; }
  .reminder-when { grid-column: 1 / -1; justify-self: end; }
  .table { font-size: 13px; }
  .page-head { flex-wrap: wrap; gap: 10px; }
  .page-head-actions { flex-wrap: wrap; gap: 8px; }
  .grid-2col { grid-template-columns: 1fr !important; }
}
@media (max-width: 780px) {
  .sidebar { display: none; }
  .layout { grid-template-columns: 1fr !important; }
  .topbar { padding: 10px 12px; flex-wrap: wrap; gap: 8px; }
  .search input { width: 100%; }
  .search-results { max-height: 320px; }
  main { padding: 12px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .tile { padding: 12px; }
  table.table { display: block; overflow-x: auto; }
  .modal { width: 96vw !important; max-width: 96vw !important; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr !important; }
  .stat-value { font-size: 22px; }
  h1 { font-size: 20px; }
  .btn { padding: 8px 12px; font-size: 13px; }
}

/* --------- RTL: keep numeric data readable --------- */
[dir="rtl"] .mono, [dir="rtl"] code { direction: ltr; text-align: end; unicode-bidi: embed; }
[dir="rtl"] .search-row { direction: rtl; }

/* Soft focus indicators */
button:focus-visible, a.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid #c2622e;
  outline-offset: 2px;
}
