/* ============================================================
   BudgetCashflow – Global Styles
   - App shell (body, header, main)
   - Global palette + typography
   - Shared buttons / inputs / messages
============================================================ */

:root {
  /* Core layout colors */
  --bg: #0d0f17;
  --fg: #e5e7eb;
  --card-bg: #0d0f17;
  --border-subtle: #1e293b;
  --current-month-bg: #111827;

  /* Accent (cool blue for controls) */
  --accent: #38bdf8; /* cyan-400 */
  --accent-soft: #1f2937; /* slate-800 */

  /* Unified semantic colors */
  --red: #ef4444; /* red-500 */
  --green: rgba(6, 214, 160, 0.9); /* green-500 */

  --error: var(--red);
  --message: var(--green);

  /* === VALUE CELL COLORS: OUTLINE STYLE === */

  /* Vibrant bases (unchanged) */
  --value-green-base: #06d6a0;
  --value-red-base: #ef4444;

  /* Outlines instead of fills */
  --value-green-outline: rgba(6, 214, 160, 0.9);
  --value-red-outline: rgba(239, 68, 68, 0.9);

  /* Light hover backgrounds for feedback */
  --value-green-hover-bg: rgba(6, 214, 160, 0.12);
  --value-red-hover-bg: rgba(239, 68, 68, 0.12);

  /* Row + label styling */
  --cf-row-hover-bg: #0c2036;
  --cf-label-bg: #0d0f17;

  /* Sticky column widths */
  --cf-actions-width: 70px;
  --cf-kind-width: 110px;
  --cf-type-width: 110px;
  --cf-name-width: 110px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: var(--bg);
  color: var(--fg);

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

/* ===== Header / layout ===== */

.header {
  border-bottom: 1px solid var(--border-subtle);
  padding: 1rem 0.5rem 1rem 1rem;
  flex: 0 0 auto;

  width: 100%;
  margin: 0 auto;
}

.header-inner {
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-weight: 700;
}

.nav a {
  margin-right: 1rem;
  text-decoration: none;
  color: var(--fg);
}

.nav a:hover {
  text-decoration: underline;
}

.link-button {
  background: none;
  border: none;
  color: var(--fg);
  cursor: pointer;
  padding: 0;
  margin-right: 15px;
}

.link-button:hover {
  text-decoration: underline;
  color: var(--fg);
}

.theme-toggle {
  margin-left: 0.5rem;
  cursor: pointer;
  background: none;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0.25rem 0.5rem;
  color: var(--fg);
}

/* Main app area */

.main {
  flex: 1 1 auto;
  width: 100%;
  margin: 0 auto;
  padding: 0px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: auto;
}

h1,
h2,
h3 {
  margin-top: 0;
}

/* ===== Global form + controls ===== */

input,
select,
button {
  font: inherit;
}

button {
  border-radius: 0.5rem;
  border: none;
  background: none;
  color: #0d0f17;
  cursor: pointer;
}

.settings-submit-btn {
  background-color: var(--accent);
  padding: 0.5rem 1rem;
  font-weight: 600;
}

button:hover {
  opacity: 0.92;
}

.icon-btn {
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  color: var(--fg);
  cursor: pointer;
}

/* Messages */

.error {
  color: var(--error);
}

.message {
  color: var(--message);
}

.header-entity-switcher {
  margin-bottom: 0px;
}

.header-entity-switcher option {
  background-color: #1e293b;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  color: inherit;
}

.logo-img {
  width: 20px; /* adjust if needed */
  height: 20px;
  display: block;
}

.logo-text {
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.25px;
}

.delete-row-btn,
.cf-rail-delete-btn {
  /* Big X delete button */
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 1rem;
  color: var(--danger, #ff4a4a);
}
.delete-row-btn:hover,
.cf-rail-delete-btn:hover {
  background: rgba(255, 74, 74, 0.12);
}

.add-row-below-btn {
  position: relative;
  width: 28px; /* circle size */
  height: 28px;
  border-radius: 999px; /* full circle */
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: #38bdf8; /* plus colour */
  font-size: 20px; /* tweak this freely */
  line-height: 1;
  cursor: pointer;
}

.add-row-below-btn:hover {
  background: #0b242e;
}

/* =========================================
   Global Header (Controls / Workbench / Charts)
   ========================================= */

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 0 14px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  height: 50px;
  background: #0d0f17;
  box-sizing: border-box;
}

/* ---------- Left ---------- */

.app-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0; /* allows truncation */
}

.app-header-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: white;
  min-width: 0;
}

.app-header-logo-img {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
}

.app-header-logo-text {
  font-weight: 650;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* Entity switcher: borrow rail styles */
.app-header-entity-switcher {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin: 0;
}

.app-header-entity-label {
  opacity: 0.7;
  white-space: nowrap;
}

.app-header-entity-select {
  height: var(--cf-input-h, 34px);
  padding: 0 10px;
  outline: none;
  background-color: #0d0f17;
  border: 0px solid #1e293b;
  color: white;
}

/* ---------- Center Nav ---------- */

.app-header-nav {
  display: inline-flex;
  align-items: center;
  gap: 10px;

  padding: 6px;
}

.app-nav-link {
  text-decoration: none;
  color: rgba(255, 255, 255, 0.82);
  font-weight: 650;

  padding: 7px 12px;
  border-radius: 999px;

  transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.app-nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.app-nav-link.app-nav-link-active {
  background: rgba(6, 214, 160, 0.14);
  color: #eafff7;
  box-shadow: 0 0 0 1px rgba(6, 214, 160, 0.25) inset;
}

.app-nav-link.app-nav-link-disabled {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

/* ---------- Right ---------- */

.app-header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.app-header-link,
.app-header-entity-select {
  color: white;
  text-decoration: none;
  font-weight: 650;
  opacity: 0.9;
  cursor: pointer;
}

.app-header-link:hover,
.app-header-entity-select:hover {
  opacity: 1;
  text-decoration: underline;
}

.app-header-logout-form {
  margin: 0;
}

.app-header-sep {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.08);
  margin: 0 2px;
}

/* ---------- System status pill (header variant) ---------- */

.system-status-bar.system-status-bar--header {
  margin: 0; /* override rail footer margin */
  padding: 6px 0px 6px 8px;
  border-top: none;

  display: inline-flex;
  align-items: center;
  gap: 0.4rem;

  color: #7df9ff;
}

.system-status-bar--header .system-status-label {
  color: rgba(255, 255, 255, 0.78);
  opacity: 1;
  font-weight: 600;
}

.system-status-bar--header .system-status-text {
  font-weight: 700;
}

/* Keep your existing neon states */
#save-status {
  color: #06d6a0;
  text-shadow: 0 0 6px #06d6a0;
}

#save-status.saving {
  color: #ffe066;
  text-shadow: 0 0 6px #ffe066aa;
}

#save-status.error {
  color: #ff4d4f;
  text-shadow: 0 0 6px #ff4d4faa;
}

/* ---------- Responsive: collapse link text / keep nav usable ---------- */
@media (max-width: 980px) {
  .app-header {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "left right"
      "nav nav";
    height: auto;
    padding: 10px 12px;
    row-gap: 10px;
  }

  .app-header-left {
    grid-area: left;
  }
  .app-header-right {
    grid-area: right;
  }
  .app-header-nav {
    grid-area: nav;
    justify-self: center;
  }

  .app-header-entity-select {
    min-width: 140px;
    max-width: 220px;
  }
}

@media (max-width: 620px) {
  .system-status-bar--header {
    display: none; /* optional: hide status pill on very small screens */
  }

  .app-header-entity-label {
    display: none;
  }
}

/* ============================================================
   System Status Bar states (global)
============================================================ */

.system-status-bar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.system-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.9);
}

.system-status-bar[data-state="ready"] {
  border-color: rgba(6, 214, 160, 0.25);
}
.system-status-bar[data-state="ready"] .system-status-dot {
  background: rgba(6, 214, 160, 0.95);
}

.system-status-bar[data-state="dirty"] {
  border-color: rgba(251, 191, 36, 0.25);
}
.system-status-bar[data-state="dirty"] .system-status-dot {
  background: rgba(251, 191, 36, 0.95);
}

.system-status-bar[data-state="saving"] {
  border-color: rgba(56, 189, 248, 0.25);
}
.system-status-bar[data-state="saving"] .system-status-dot {
  background: rgba(56, 189, 248, 0.95);
}

.system-status-bar[data-state="error"] {
  border-color: rgba(239, 68, 68, 0.35);
}
.system-status-bar[data-state="error"] .system-status-dot {
  background: rgba(239, 68, 68, 0.95);
}

.app-nav-link--with-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.staged-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.2rem;
  height: 1.2rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  font-size: 0.75rem;
  line-height: 1;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(56, 189, 248, 0.18);
}

.staged-badge.is-hidden {
  display: none;
}

/* Spinner element inside primary button */
.cf-modal-spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  margin-left: 0.5rem;
  border-radius: 999px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: cfspin 0.8s linear infinite;
  vertical-align: -0.15em;
}

@keyframes cfspin {
  to {
    transform: rotate(360deg);
  }
}

.app-nav-link--disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.app-nav-link--disabled:hover {
  text-decoration: none;
}

.fa-lock {
  color: #06d6a0;
}
.fa-lock-open {
  color: #ef4444;
}

.fa-note {
  color: #38bdf8;
}

.fa-tag {
  color: #f59e0b;
}
