/* ============================================================================
   AMANAH — Layout
   ============================================================================ */

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-body {
  flex: 1;
  width: 100%;
}

/* ---- Nav ------------------------------------------------------------------
   Dark tone reserved for nav + footer, per the "private ledger, not a
   dashboard" direction — not a full dark theme. */
.nav {
  background: var(--charcoal-deep);
  color: var(--ink-on-dark);
  height: var(--nav-height);
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-inner {
  width: 100%;
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 0 var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
}

.nav-brand {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 500;
  color: var(--ink-on-dark);
  letter-spacing: 0.01em;
}
.nav-brand:hover { text-decoration: none; opacity: 0.85; }

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  flex: 1;
}

.nav-link {
  color: var(--ink-on-dark-soft);
  font-size: var(--text-sm);
  font-weight: 500;
  padding: var(--space-2) 0;
  border-bottom: 2px solid transparent;
  transition: color var(--duration-base) var(--ease-out), border-color var(--duration-base) var(--ease-out);
}
.nav-link:hover {
  color: var(--ink-on-dark);
  text-decoration: none;
}
.nav-link[aria-current="page"] {
  color: var(--ink-on-dark);
  border-bottom-color: var(--emerald);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  flex-shrink: 0;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--ink-on-dark-soft);
  cursor: pointer;
  transition: color var(--duration-base) var(--ease-out), border-color var(--duration-base) var(--ease-out);
}
.theme-toggle:hover { color: var(--ink-on-dark); border-color: rgba(243, 240, 230, 0.16); }

.nav-toggle {
  display: none;
}

/* ---- Footer ------------------------------------------------------------ */
.footer {
  background: var(--charcoal-deep);
  color: var(--ink-on-dark-soft);
  padding: var(--space-6) var(--space-5);
  margin-top: var(--space-9);
}
.footer-inner {
  max-width: var(--page-width);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  font-size: var(--text-sm);
}
.footer a { color: var(--ink-on-dark-soft); }
.footer a:hover { color: var(--ink-on-dark); }

/* ---- Containers ---------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--page-width);
  margin: 0 auto;
  padding: var(--space-6) var(--space-5);
}

.container-narrow {
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: var(--space-6) var(--space-5);
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}

.page-header p {
  margin: var(--space-1) 0 0;
}

/* ---- Auth / centered card layout ----------------------------------------- */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background:
    radial-gradient(ellipse at top left, rgba(30,107,82,0.06), transparent 55%),
    var(--ivory);
}

.auth-card {
  width: 100%;
  max-width: 26rem;
  background: var(--ivory-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-7) var(--space-6);
  box-shadow: var(--shadow-card);
}

/* ---- Stat grid (dashboard) ------------------------------------------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-7);
}

/* ---- Money summary (dashboard: owed to you / you owe, split by currency) --- */
.money-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

/* ---- Record grid / list ----------------------------------------------------- */
.record-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* ---- Two-column detail layout ------------------------------------------------ */
.detail-layout {
  display: grid;
  grid-template-columns: 1fr 20rem;
  gap: var(--space-6);
  align-items: start;
}

/* ---- Tabs ------------------------------------------------------------------ */
.tabs {
  display: flex;
  gap: var(--space-5);
  border-bottom: 1px solid var(--line);
  margin-bottom: var(--space-5);
}
.tab {
  padding: var(--space-3) var(--space-1);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-soft);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  cursor: pointer;
}
.tab[aria-selected="true"] {
  color: var(--ink);
  border-bottom-color: var(--emerald);
}

/* ---- Empty states ------------------------------------------------------------- */
.empty-state {
  text-align: center;
  padding: var(--space-8) var(--space-5);
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  color: var(--ink-soft);
}
.empty-state h3 { color: var(--ink); margin-bottom: var(--space-2); }
.empty-state p { max-width: 28rem; margin-left: auto; margin-right: auto; }

/* ---- App-open splash ----------------------------------------------------------
   Shown while the session check resolves — the app's "opening" moment,
   especially when launched standalone from the home screen. Ivory
   background matches the manifest's background_color so there's no color
   flash coming off the OS-native splash screen into this one. */
.app-splash {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ivory);
}
.app-splash-logo {
  width: 104px;
  height: 104px;
  animation:
    splash-in 650ms var(--ease-out) both,
    splash-breathe 1800ms ease-in-out 650ms infinite;
}
.app-splash.is-leaving {
  animation: splash-fade-out 320ms var(--ease-out) forwards;
}
.app-splash.is-leaving .app-splash-logo {
  animation: none; /* stop breathing so it doesn't fight the fade-out */
}

@keyframes splash-in {
  0%   { opacity: 0; transform: scale(0.78); }
  65%  { opacity: 1; transform: scale(1.045); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes splash-breathe {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.035); }
}
@keyframes splash-fade-out {
  to { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .app-splash-logo { animation: none; }
  .app-splash.is-leaving { animation: splash-fade-out 1ms forwards; }
}

[data-auth-guard] {
  display: none;
}
[data-auth-guard].is-ready {
  display: block;
  animation: content-in 420ms var(--ease-out) both;
}
@keyframes content-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  [data-auth-guard].is-ready { animation: none; }
}
