/* === M1 Brand CSS — m1-finance ===
   Palette and shell styles ported from m1-scheduling (the portfolio baseline).
   Finance-specific component styles live in app.css.
*/
@import url('https://fonts.googleapis.com/css2?family=Roboto+Condensed:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&display=swap');

:root {
  /* Primary palette */
  --m1-bone:         #E6E1D2;
  --m1-dark-green:   #1D3026;
  --m1-olive:        #596152;
  --m1-artichoke:    #737660;  /* ADA-corrected: 4.68:1 with white */
  --m1-dutch-white:  #DDD2A4;

  /* Secondary palette (accents) */
  --m1-slate-gray:   #314E56;
  --m1-teal:         #276B6E;
  --m1-emerald:      #4DA284;
  --m1-electric-green: #AAD372;
  --m1-burnt-umber:  #84352D;

  /* ADA-corrected variants */
  --m1-success:      #2E7F65;
  --m1-border-secondary: #8C8672;
  --m1-toggle-off:   #888888;
  --m1-olive-dark:   #4A5043;
  --m1-teal-dark:    #1E5557;
  --m1-burnt-dark:   #6B2A24;
  --m1-amber:        #946C14;
  --m1-warm-grey:    #9C927C;  /* Files lens — warm, separates from teal */
  --m1-placeholder:  #7A7D6E;

  /* Tints */
  --m1-sand:         #C4BFA6;
  --m1-bone-80:      #EBE7DB;
  --m1-bone-60:      #F0EDE4;

  /* Semantic mappings */
  --color-bg:        #EDEBE4;
  --color-surface:   #FFFFFF;
  --color-surface-alt: #f4f2ec;
  --color-text:      var(--m1-dark-green);
  --color-text-muted: var(--m1-olive);
  --color-nav-bg:    var(--m1-dark-green);
  --color-nav-text:  var(--m1-bone);
  --color-primary:   var(--m1-teal);
  --color-primary-hover: var(--m1-slate-gray);
  --color-success:   var(--m1-success);
  --color-warning:   var(--m1-dutch-white);
  --color-danger:    var(--m1-burnt-umber);
  --color-highlight: var(--m1-electric-green);
  --color-table-header: var(--m1-artichoke);
  --color-section-header-bg: var(--m1-dark-green);
  --color-section-header-text: var(--m1-bone);
  --color-text-secondary: var(--m1-olive-dark);
  --color-link-on-light: var(--m1-teal-dark);
  --color-danger-text:  var(--m1-burnt-dark);
  --color-warning-text: var(--m1-amber);
  --color-placeholder:  var(--m1-placeholder);

  /* Structural tokens */
  --color-border:          #ccc;
  --color-border-warm:     #e0ddd4;
  --color-border-light:    #eee;
  --color-neutral:         #999;
  --color-success-hover:   #277554;
  --color-danger-hover:    var(--m1-burnt-dark);
  --color-primary-focus:   rgba(39,107,110,0.2);
  --color-primary-subtle:  rgba(39,107,110,0.05);
  --color-primary-selected: rgba(39,107,110,0.08);
  --color-danger-subtle:   rgba(132,53,45,0.08);

  /* Typography */
  --font-family: "Roboto Condensed", "Segoe UI", -apple-system, system-ui, sans-serif;

  /* Layout */
  --nav-height: 40px;
  --border-radius: 4px;
  --border-radius-lg: 8px;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.1);
  --content-padding: 16px;

  /* Legacy aliases kept for app.css compatibility */
  --bg: var(--color-bg);
  --surface: var(--color-surface);
  --shadow: var(--shadow-card);
}

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

html { font-size: 13px; }

body {
  font-family: var(--font-family);
  background: var(--color-bg);
  color: var(--color-text);
  margin: 0;
  padding: 0;
  line-height: 1.5;
}

h1 { font-size: 18px; font-weight: 700; margin: 0 0 8px; }
h2 { font-size: 15px; font-weight: 700; margin: 0 0 6px; }
h3 { font-size: 14px; font-weight: 600; margin: 0 0 4px; }

a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-hover); text-decoration: underline; }

/* === HTMX Request States === */
.htmx-request {
  opacity: 0.6;
  pointer-events: none;
  transition: opacity 0.15s;
}
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: inline-block; }

/* === Focus (ADA) === */
:focus-visible {
  outline: 2px solid var(--m1-teal);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(39,107,110,0.25);
}

/* === Skip Nav (ADA) === */
.skip-nav {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 9999;
  background: var(--m1-dark-green);
  color: var(--m1-bone);
  padding: 8px 16px;
  font-weight: 600;
}
.skip-nav:focus { left: 0; }

/* === Navbar === */
.navbar {
  background: var(--color-nav-bg);
  height: var(--nav-height);
  display: flex;
  align-items: center;
  padding: 0 var(--content-padding);
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
.navbar-brand span {
  color: var(--color-nav-text);
  font-weight: 700;
  font-size: 14px;
}
.navbar-links {
  display: flex;
  align-items: center;
  gap: 0;
  margin-left: 24px;
  height: 100%;
}
.navbar-link {
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 14px;
  color: var(--color-nav-text);
  text-decoration: none;
  font-size: 13px;
  border-bottom: 2px solid transparent;
}
.navbar-link[aria-current="page"] {
  font-weight: 700;
  border-bottom-color: var(--m1-electric-green);
  background: rgba(255,255,255,0.08);
}

/* ── Entity-tab differentiation (spec 2026-06-04-nav-cleanup) ──
   Deals/Files/Quotes get a lens color + leading icon. Color is NOT the only
   cue — the icon silhouette + label carry meaning in grayscale (WCAG 1.4.1).
   These override the generic electric-green active style for the 3 tabs only. */

/* Icon: explicit box + display:block so the inline SVG centers on the text
   centerline instead of riding the baseline. .navbar-link is already
   display:flex; align-items:center, so the row centers vertically. */
.nav-link-icon {
  flex: none;
  width: 16px;
  height: 16px;
  display: block;
}

/* 6px between the leading icon and the label (spec §4.3). Scoped to the
   icon-bearing tabs so Dashboard/Settings (no icon) are unaffected. */
.nav-link--deal,
.nav-link--file,
.nav-link--quote { gap: 6px; }

/* Inactive label tints (on the dark-green #1D3026 nav). */
.nav-link--deal  { color: #62B8BA; }   /* brand teal, brightened */
.nav-link--file  { color: #C2BAA6; }   /* warm stone-grey */
.nav-link--quote { color: #D7B564; }   /* amber */

/* Active state: lens-color underline + faint wash + bold, replacing the
   generic electric-green active style for these three tabs.
   Desktop only: the @media (max-width:768px) block re-declares a border-bottom
   shorthand that neutralizes border-bottom-color here, so mobile keeps the
   electric-green border-left active indicator — intentional. */
.nav-link--deal[aria-current="page"] {
  color: #8fd6d8;
  font-weight: 700;
  border-bottom-color: var(--m1-teal);
  background: rgba(39, 107, 110, 0.16);
}
.nav-link--file[aria-current="page"] {
  color: #ddd5c4;
  font-weight: 700;
  border-bottom-color: var(--m1-warm-grey);
  background: rgba(156, 146, 124, 0.16);
}
.nav-link--quote[aria-current="page"] {
  color: #e9c876;
  font-weight: 700;
  border-bottom-color: #D7A93B;  /* mid-amber, darker than the inactive tint for active contrast */
  background: rgba(215, 169, 59, 0.16);
}

.navbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.navbar-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--m1-olive);
  color: var(--m1-bone);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}
.navbar-user-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-nav-text);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.navbar-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--color-surface);
  border-radius: var(--border-radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  min-width: 160px;
  padding: 4px 0;
  z-index: 200;
}
.user-menu { position: relative; }
.user-menu.open .navbar-dropdown { display: block; }
.navbar-dropdown a {
  display: block;
  padding: 8px 16px;
  color: var(--color-text);
  font-size: 13px;
  text-decoration: none;
}
.navbar-dropdown a:hover { background: var(--color-surface-alt); }
.navbar-dropdown .logout { color: var(--color-danger); }
/* === Navbar Mobile === */
.navbar-hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--color-nav-text);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  margin-left: 12px;
}
@media (max-width: 768px) {
  .navbar-hamburger { display: block; }
  .navbar-links {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: var(--color-nav-bg);
    flex-direction: column;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    z-index: 99;
  }
  .navbar-links.open { display: flex; }
  .navbar-link {
    height: auto;
    padding: 10px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
  }
  .navbar-link[aria-current="page"] {
    border-bottom: 1px solid rgba(255,255,255,0.1);
    border-left: 3px solid var(--m1-electric-green);
  }
}

/* === Toast === */
.toast-container {
  position: fixed;
  top: calc(var(--nav-height) + 8px);
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--border-radius);
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: toast-in 0.3s ease;
  min-width: 280px;
}
.toast-success { background: var(--color-success); color: #fff; }
.toast-warning { background: var(--color-warning); color: var(--color-text); }
.toast-error   { background: var(--color-danger);  color: #fff; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(100%); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(100%); }
}
.toast.dismissing {
  animation: toast-out 0.3s ease forwards;
  pointer-events: none;
}

/* === Modal === */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
  z-index: 900;
  display: none;
}
.modal-backdrop.active { display: flex; align-items: center; justify-content: center; }
.modal {
  background: var(--color-surface);
  border-radius: var(--border-radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border-warm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
}
.modal-body   { padding: 16px; }
.modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--color-border-warm);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

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