/* Dahmiyat parallel web app: Amer design system (Warm Alabaster light by default, Obsidian dark). */
:root,
[data-theme="light"] {
  --bg-0: #FAF8F5;
  --bg-1: #FFFFFF;
  --bg-2: #F3EFEA;
  --text-0: #141413;
  --text-1: #52504C;
  --text-2: #8A8680;
  --accent: #D92D20;
  --accent-soft: #FEE4E2;
  --border-hairline: rgba(20, 20, 19, 0.09);
  --status-success: #15803D;
  --status-warning: #B45309;
  --status-danger: #B91C1C;
  --dock-glass-bg: rgba(255, 255, 255, 0.84);
}

[data-theme="dark"] {
  --bg-0: #0B0C0E;
  --bg-1: #131519;
  --bg-2: #1C1F26;
  --text-0: #F5F5F7;
  --text-1: #A1A5B0;
  --text-2: #6E7380;
  --accent: #F04438;
  --accent-soft: rgba(240, 68, 56, 0.18);
  --border-hairline: rgba(245, 245, 247, 0.09);
  --status-success: #22C55E;
  --status-warning: #F59E0B;
  --status-danger: #EF4444;
  --dock-glass-bg: rgba(19, 21, 25, 0.84);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  direction: rtl;
  font-family: -apple-system, BlinkMacSystemFont, "SF Arabic", "Geeza Pro", sans-serif;
  font-variant-numeric: tabular-nums;
  background: var(--bg-0);
  color: var(--text-0);
}

body { margin: 0; min-height: 100vh; background: var(--bg-0); color: var(--text-0); }

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }

[hidden], .ds-hidden { display: none !important; }

/* Scroll container + reserved space under the floating dock. */
.ds-scroll { width: 100%; max-width: 1280px; margin-inline: auto; padding: 16px; overflow-y: auto; }
.ds-bottom-bar-inset { padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }

/* Width caps: floating surfaces. */
.ds-banner,
.ds-dialog,
.ds-login-card,
.ds-tab-dock {
  max-width: 520px;
  width: calc(100% - 32px);
  margin-inline: auto;
}

.ds-reading-column { max-width: 680px; margin-inline: auto; }

/* Floating tab dock (the only navigation surface). */
.ds-tab-dock {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  border-radius: 999px;
  padding: 6px;
  border: 1px solid var(--border-hairline);
  background: var(--dock-glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  gap: 4px;
}

.ds-tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 88px;
  height: 56px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-1);
}
.ds-tab-btn svg { width: 22px; height: 22px; }
.ds-tab-btn[aria-selected="true"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* Cards and tree rows. */
.ds-card {
  background: var(--bg-1);
  border: 1px solid var(--border-hairline);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
}
.ds-title { font-size: 17px; font-weight: 600; color: var(--text-0); margin: 0 0 4px; }
.ds-subtitle { font-size: 14px; color: var(--text-1); margin: 0; }
.ds-caption { font-size: 12px; color: var(--text-2); }

.ds-breadcrumb-bar {
  height: 36px;
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  white-space: nowrap;
  font-size: 13px;
  color: var(--text-1);
}

.ds-leaf-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border-hairline);
}
.ds-leaf-body { padding: 12px 16px; background: var(--bg-1); color: var(--text-1); }
.ds-leaf-flash { background: var(--accent-soft); }

/* Badges and buttons. */
.ds-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--text-1);
  font-size: 12px;
}
.ds-badge-success { color: var(--status-success); }
.ds-badge-warning { color: var(--status-warning); }
.ds-badge-danger { color: var(--status-danger); }

.ds-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  background: var(--accent);
  color: #FFFFFF;
  font-weight: 600;
}
.ds-btn-secondary { background: var(--bg-2); color: var(--text-0); border: 1px solid var(--border-hairline); }
.ds-btn-danger { background: var(--status-danger); }
.ds-btn:disabled { opacity: 0.5; cursor: default; }

.ds-input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--border-hairline);
  background: var(--bg-2);
  color: var(--text-0);
  font: inherit;
}

/* Wide screens: multi-column apps grid. */
@media (min-width: 768px) {
  .ds-apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    align-items: start;
  }
  .ds-apps-grid > .ds-card { margin-bottom: 0; }
}

/* Split view: list on the right, details on the left (RTL). */
@media (min-width: 900px) {
  .ds-split {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 16px;
    max-width: 1280px;
    margin-inline: auto;
    align-items: start;
  }
}

/* Rows, status slots and the update banner (fixed so it never shifts content). */
.ds-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ds-row > .ds-grow { flex: 1; min-width: 0; }
.ds-csrf-banner { position: fixed; inset-inline: 12px; bottom: 12px; z-index: 50; display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.ds-status-slot { min-height: 20px; font-size: 13px; color: var(--text-1); }
.ds-leaf-body { white-space: pre-wrap; }
.ds-banner {
  position: fixed;
  top: 8px;
  left: 0;
  right: 0;
  z-index: 110;
  padding: 10px 16px;
  border-radius: 14px;
  background: var(--accent);
  color: #FFFFFF;
}

/* Security audit log: rows keep a fixed collapsed height so inserts cause no layout shift. */
.ds-audit-row { padding: 0; overflow: hidden; overflow-anchor: auto; }
.ds-audit-head { cursor: pointer; min-height: 48px; border-block-end: 0; }
.ds-audit-head > svg { width: 20px; height: 20px; flex: none; color: var(--accent); }
.ds-audit-head > .ds-grow { flex: 1; min-width: 0; }
.ds-audit-summary { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-audit-badge { flex: none; background: var(--accent-soft); }
.ds-audit-time { flex: none; margin-inline-start: 4px; }
.ds-audit-body { border-block-start: 1px solid var(--border-hairline); overflow-wrap: anywhere; }
.ds-audit-header { flex-wrap: wrap; }

/* SSO migration badges and section (identity tokens only, RTL-safe). */
.sso-badge, .sso-check {
  display: inline-block;
  padding-block: 2px;
  padding-inline: 10px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--bg-2);
}
.sso-badge--active, .sso-check--pass { background: var(--accent-soft); color: var(--accent); }
.sso-badge--pending, .sso-check--fail { background: var(--bg-2); }
.sso-checks, .sso-detail { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-block: 8px; }
.sso-section { margin-block-end: 12px; }
