/* ============================================================
   CRM application shell + page styling. Builds on the themeable --tcc-* component classes (teamcore-components.css)
   and the --crm-* / --tcc-* palette (theme.css). No inline styles in the Razor markup — everything reads from here so
   light / dark theming is a single attribute flip on <html>.
   ============================================================ */

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--crm-font);
  background: var(--crm-bg);
  color: var(--crm-text);
  -webkit-font-smoothing: antialiased;
}

body { transition: background-color .2s ease, color .2s ease; }

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

* { box-sizing: border-box; }

/* ------------------------------- App bar ------------------------------- */
.crm-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: .35rem;
  padding: .55rem 1.5rem;
  background: var(--crm-nav-bg);
  border-bottom: 1px solid var(--crm-nav-border);
  box-shadow: var(--crm-shadow-nav);
}

.crm-nav__brand {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  margin-right: 1.25rem;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: .01em;
  color: var(--crm-text);
}
.crm-nav__brand:hover { text-decoration: none; }
.crm-nav__mark { width: 1.5rem; height: 1.5rem; flex: none; color: var(--crm-accent); }
.crm-nav__brand-em { color: var(--crm-accent); }

.crm-nav__link {
  padding: .4rem .7rem;
  border-radius: 7px;
  color: var(--crm-text-muted);
  font-weight: 500;
  font-size: .92rem;
  line-height: 1;
  transition: background-color .12s ease, color .12s ease;
}
.crm-nav__link:hover { background: rgba(127, 127, 127, .1); color: var(--crm-text); text-decoration: none; }
.crm-nav__link.active { color: var(--crm-accent); background: var(--crm-accent-soft); }

.crm-nav__spacer { margin-left: auto; }

.crm-nav__tools { display: inline-flex; align-items: center; gap: .9rem; margin-left: .9rem; }

/* Theme toggle: one button, shows the icon for the theme you'd switch TO. CSS swaps the glyph off [data-theme]. */
.crm-theme-toggle { color: var(--crm-text-muted); }
.crm-theme-toggle:hover { color: var(--crm-accent); }
.crm-theme-toggle .crm-icon-sun { display: none; }
.crm-theme-toggle .crm-icon-moon { display: inline-flex; }
:root[data-theme="dark"] .crm-theme-toggle .crm-icon-sun { display: inline-flex; }
:root[data-theme="dark"] .crm-theme-toggle .crm-icon-moon { display: none; }

/* ------------------------------- Page ------------------------------- */
.crm-main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 3rem;
}

.crm-page__title {
  margin: 0 0 .25rem;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -.01em;
}
.crm-page__intro {
  margin: 0 0 1.5rem;
  color: var(--crm-text-muted);
  max-width: 70ch;
  line-height: 1.5;
}

.crm-section-title { margin: 0 0 .75rem; font-size: 1.15rem; font-weight: 700; }

/* Toolbar: the row of inputs / actions above a list. */
.crm-toolbar {
  display: flex;
  gap: .6rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

/* ------------------------------- Inputs ------------------------------- */
/* Standalone field chrome (the .tcc-field__* set is built for the full label+control component; these mirror its look
   for the bare inputs the CRM screens use, reading the same --tcc-field-* tokens so they theme identically). */
.crm-input, .crm-select, .crm-textarea {
  font: inherit;
  font-size: .92rem;
  color: var(--tcc-field-fg);
  background: var(--tcc-field-bg);
  border: 1px solid transparent;
  border-bottom: 1px solid var(--tcc-field-line);
  border-radius: var(--tcc-radius-s) var(--tcc-radius-s) 0 0;
  padding: .5rem .7rem;
  outline: none;
  color-scheme: var(--tcc-field-scheme, light);
  transition: background-color .15s ease, border-color .15s ease;
}
.crm-input::placeholder, .crm-textarea::placeholder { color: var(--tcc-field-placeholder); }
.crm-input:hover:not(:disabled), .crm-select:hover:not(:disabled), .crm-textarea:hover:not(:disabled) { background: var(--tcc-field-bg-hover); }
.crm-input:focus, .crm-select:focus, .crm-textarea:focus { border-bottom: 2px solid var(--tcc-field-accent); padding-bottom: calc(.5rem - 1px); }
.crm-input:disabled, .crm-select:disabled, .crm-textarea:disabled { opacity: .6; cursor: not-allowed; }
.crm-select { cursor: pointer; }
.crm-textarea { resize: vertical; min-height: 5rem; width: 100%; }

.crm-field-label { display: block; margin-bottom: .9rem; font-size: .9rem; }
.crm-field-label > span { display: block; margin-bottom: .25rem; color: var(--crm-text-muted); font-size: .8rem; }

/* ------------------------------- Cards ------------------------------- */
.crm-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

/* Quick-link / summary card with a hover lift. */
.crm-tile {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  padding: 1.1rem 1.25rem;
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--tcc-radius);
  color: var(--crm-text);
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
a.crm-tile:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--tcc-shadow-s); border-color: var(--crm-accent); }
.crm-tile__title { font-weight: 700; font-size: 1.05rem; }
.crm-tile__desc { color: var(--crm-text-muted); font-size: .88rem; line-height: 1.45; }

/* Stat figure (Usage). */
.crm-stats { display: flex; gap: 1.25rem; flex-wrap: wrap; margin: 1rem 0 1.5rem; }
.crm-stat {
  min-width: 11rem;
  padding: 1.1rem 1.25rem;
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: var(--tcc-radius);
}
.crm-stat__value { font-size: 2.1rem; font-weight: 700; line-height: 1; color: var(--crm-accent); }
.crm-stat__label { margin-top: .4rem; color: var(--crm-text-muted); font-size: .85rem; }

/* ------------------------------- Tables ------------------------------- */
.crm-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--crm-border);
  border-radius: var(--tcc-radius-s);
  background: var(--crm-surface);
}
.crm-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .92rem; }
.crm-table thead th {
  text-align: left;
  padding: .7rem .9rem;
  background: var(--tcc-grid-head-bg);
  color: var(--tcc-grid-muted);
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
  border-bottom: 1px solid var(--crm-border);
}
.crm-table tbody td { padding: .65rem .9rem; border-bottom: 1px solid var(--crm-border); vertical-align: top; }
.crm-table tbody tr:last-child td { border-bottom: 0; }
.crm-table tbody tr:nth-child(even) { background: var(--tcc-grid-stripe); }
.crm-table tbody tr:hover { background: var(--tcc-grid-hover); }
.crm-table code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .85em; color: var(--crm-text-muted); }
.crm-cell-num { text-align: right; font-variant-numeric: tabular-nums; }

/* ------------------------------- Misc ------------------------------- */
.crm-muted { color: var(--crm-text-muted); }
.crm-empty { color: var(--crm-text-muted); padding: 1.5rem 0; }
.crm-loading { color: var(--crm-text-muted); }
.crm-stack { display: flex; flex-direction: column; gap: 1rem; }

/* Banner spacing when stacked above content. */
.crm-banner-gap { margin-bottom: 1rem; }

/* ------------------------- Deals pipeline board ------------------------- */
.crm-board { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: 1rem; align-items: flex-start; }
.crm-board__col {
  flex: 0 0 18rem;
  background: var(--crm-surface-2);
  border: 1px solid var(--crm-border);
  border-radius: var(--tcc-radius-s);
}
.crm-board__head {
  padding: .55rem .8rem;
  border-top: 4px solid var(--crm-accent);
  border-radius: var(--tcc-radius-s) var(--tcc-radius-s) 0 0;
  font-weight: 700;
  font-size: .95rem;
}
.crm-board__count { color: var(--crm-text-muted); font-weight: 500; }
.crm-board__body { display: flex; flex-direction: column; gap: .5rem; padding: .55rem; min-height: 3.5rem; }
.crm-deal-card {
  background: var(--crm-surface);
  border: 1px solid var(--crm-border);
  border-radius: 6px;
  padding: .65rem .7rem;
  cursor: grab;
  transition: box-shadow .12s ease, border-color .12s ease;
}
.crm-deal-card:hover { box-shadow: var(--tcc-shadow-s); border-color: var(--crm-accent); }
.crm-deal-card__title { font-weight: 600; }
.crm-deal-card__value { font-size: .85rem; margin-top: .2rem; }
.crm-deal-card__meta { font-size: .8rem; color: var(--crm-text-muted); }

/* ------------------------- Login gate (index.html) ------------------------- */
/* The markup sets these inline too (so the splash looks right even if this file fails to load); kept here so the gate
   honours the active theme once the CSS is in. */
#login-gate { background: var(--crm-bg) !important; color: var(--crm-text); }
#login-button { background: var(--crm-accent) !important; }
