/* base.css v1.0.0 */

/* ===== FM Suite Base Styles & Shell Layout ===== */

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--ff);
  background: var(--paper);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 14px;
}

:focus-visible {
  outline: 2px solid var(--peach2);
  outline-offset: 2px;
}

/* Serif display numerals for financial amounts */
.num {
  font-family: var(--serif-num);
  letter-spacing: -0.01em;
}

/* Directional colors */
.color-gain {
  color: var(--G);
}
.color-loss {
  color: var(--R);
}
.color-muted {
  color: var(--text3);
}

/* Privacy Blur mode */
.privacy-blur,
.privacy-val {
  transition: filter 0.15s ease;
}

.privacy-blur-active .privacy-blur,
.privacy-blur-active .privacy-val,
.privacy-active .privacy-blur,
.privacy-active .privacy-val,
body.privacy-active .privacy-blur,
body.privacy-active .privacy-val,
html.privacy-blur-active .privacy-blur,
html.privacy-blur-active .privacy-val {
  filter: blur(6px) !important;
  user-select: none !important;
  cursor: default !important;
}

/* Accessibility: Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ===== Shell Structure ===== */
.app-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Top bar */
.top-bar {
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--ink);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top));
}

.top-bar-brand {
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.top-bar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--ink3);
  color: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
.icon-btn:hover {
  background: var(--ink2);
}

/* Sidebar for desktop */
.app-sidebar {
  display: none;
  width: 240px;
  background: var(--ink);
  color: var(--on-ink);
  flex-direction: column;
  padding: 20px 14px;
  gap: 6px;
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 15px;
  font-weight: 700;
  padding: 8px 10px 16px;
  border-bottom: 1px solid var(--ink2);
  margin-bottom: 8px;
}

.sidebar-link,
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r);
  color: inherit;
  text-decoration: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
}
.sidebar-link:hover,
.sidebar-nav-item:hover {
  background: var(--ink2);
  color: #fff;
}
.sidebar-link.active,
.sidebar-nav-item.active {
  background: var(--ink2);
  color: var(--peach);
  box-shadow: inset 3px 0 0 var(--peach);
}
.sidebar-link svg,
.sidebar-nav-item svg {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  stroke: currentColor;
}

/* Main Content */
.main-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--paper);
}

.content-body {
  flex: 1;
  padding: 16px;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

/* Bottom Navigation for phones */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 70;
  background: var(--ink);
  color: #fff;
  display: flex;
  justify-content: space-around;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--ink2);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: 0;
  color: var(--text3);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 8px;
  cursor: pointer;
  flex: 1;
  min-width: 0;
}
.bottom-nav-item.active {
  color: var(--peach);
}
.bottom-nav-item .nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  font-size: 18px;
  line-height: 1;
}
.bottom-nav-item .nav-icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
}

@media (min-width: 768px) {
  .app-sidebar {
    display: flex;
  }
  .bottom-nav {
    display: none;
  }
  .content-body {
    padding-bottom: 24px;
  }
}

/* ===== Cards & Containers ===== */
.card {
  background: var(--bg);
  border: 1px solid var(--bor);
  border-radius: var(--rl);
  box-shadow: var(--sh);
  padding: 16px;
  margin-bottom: 14px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--bor);
}
.card-header h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--r);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: opacity 0.15s ease, background 0.15s ease;
  text-decoration: none;
  min-height: 38px;
}
.btn:hover {
  opacity: 0.92;
}
.btn:active {
  transform: scale(0.98);
}
.btn-primary {
  background: var(--ink);
  color: var(--on-ink);
  border-color: var(--ink);
}
.btn-secondary {
  background: var(--bg2);
  color: var(--text);
  border-color: var(--bor2);
}
.btn-peach {
  background: var(--peach);
  color: var(--ink);
  font-weight: 600;
}
.btn-danger {
  background: var(--R);
  color: #fff;
}
.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  min-height: 28px;
  border-radius: 6px;
}

/* ===== Forms ===== */
.fg {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}
.fg label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
}
.fg input, .fg select, .fg textarea {
  padding: 9px 12px;
  border: 1px solid var(--bor2);
  border-radius: var(--r);
  background: var(--bg);
  color: var(--text);
}
.fg input:focus, .fg select:focus, .fg textarea:focus {
  border-color: var(--peach2);
}
.field-error {
  color: var(--R);
  font-size: 11px;
  font-weight: 500;
  display: none;
}
.fg.has-error .field-error {
  display: block;
}
.fg.has-error input, .fg.has-error select, .fg.has-error textarea {
  border-color: var(--R);
}

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
}
.badge-occupied {
  background: var(--Gbg);
  color: var(--G);
  border: 1px solid var(--Gbr);
}
.badge-vacant {
  background: var(--peachbg);
  color: var(--peach2);
  border: 1px solid var(--bor2);
}
.badge-notice {
  background: var(--Abg);
  color: var(--A);
  border: 1px solid var(--Abr);
}
.badge-gain {
  background: var(--Gbg);
  color: var(--G);
}
.badge-loss {
  background: var(--Rbg);
  color: var(--R);
}

/* ===== Empty States ===== */
.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text3);
}
.empty-state-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: var(--text3);
  margin-bottom: 12px;
}
.empty-state-icon svg {
  width: 44px;
  height: 44px;
  stroke: var(--text3);
  stroke-width: 1.5;
}
.nav-svg-icon {
  display: inline-block;
  vertical-align: -2px;
  flex-shrink: 0;
}
.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.empty-state-desc {
  font-size: 13px;
  margin-bottom: 16px;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}

/* ===== Toast Container ===== */
.toast-container {
  position: fixed;
  bottom: calc(76px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 90vw;
}
@media (min-width: 768px) {
  .toast-container {
    bottom: 24px;
    right: 24px;
    left: auto;
    transform: none;
  }
}
.toast-item {
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
  opacity: 1;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast-fade-out {
  opacity: 0;
  transform: translateY(6px);
}
.toast-action-btn {
  background: var(--peach);
  color: var(--ink);
  border: 0;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  cursor: pointer;
}

/* ===== Accessible Dialog / Modal ===== */
dialog.app-dialog {
  border: 0;
  border-radius: var(--rl);
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 16px 40px rgba(0,0,0,0.3);
  padding: 20px;
  max-width: 440px;
  width: 90vw;
  margin: auto;
}
dialog.app-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}
.dialog-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
}
.dialog-body {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.4;
  margin-bottom: 18px;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
