/* ----------------------------------------------------------------
   The Layer - Outlook Web Add-in Styles
   Modern Fluent-inspired design matching Office UI
   Copyright (c) Layer Systems. All Rights Reserved.
   ---------------------------------------------------------------- */

:root {
  --primary: #0078d4;
  --primary-hover: #106ebe;
  --primary-active: #005a9e;
  --danger: #d13438;
  --danger-hover: #a4262c;
  --success: #107c10;
  --warning: #ffb900;
  --text: #323130;
  --text-secondary: #605e5c;
  --bg: #ffffff;
  --bg-secondary: #faf9f8;
  --border: #d2d0ce;
  --border-focus: #0078d4;
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
  --radius: 4px;
  --font: "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;

  /* Soft fill + matching foreground pairs for the context card's verdict
     pill and due chips. Tokens, never literals: this file still has no
     prefers-color-scheme block, and the badge/result-message colours below
     are hardcoded hexes (#dff6dd, #fde7e9, #deecf9) that will each need
     hunting down when one lands. The card must not add to that debt — an
     amber-on-white pill hardcoded today is a white-on-white pill the day
     dark mode ships. Redefine these eight in the dark block and the whole
     card follows. */
  --danger-soft: #fde7e9;
  --danger-soft-fg: #a4262c;
  --warning-soft: #fff4ce;
  --warning-soft-fg: #7a5400;
  --neutral-soft: #edebe9;
  --neutral-soft-fg: #323130;
  /* "No open cases" is an ABSENCE, not a success — deliberately not green,
     which would read as "resolved". */
  --quiet-soft: #f3f2f1;
  --quiet-soft-fg: #605e5c;
  --skeleton: #edebe9;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--bg-secondary);
  line-height: 1.5;
}

#app {
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background: var(--primary);
  color: white;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-row {
  display: flex;
  align-items: center;
}

.gear-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.15s;
}

.gear-btn:hover {
  color: white;
}

.nav-bar {
  display: flex;
  flex: 1;
  gap: 2px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.nav-bar::-webkit-scrollbar {
  display: none;
}

.nav-btn {
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  border: none;
  padding: 8px 10px;
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}

.nav-btn:hover {
  color: white;
  background: rgba(255, 255, 255, 0.1);
}

.nav-btn.active {
  color: white;
  border-bottom-color: white;
  font-weight: 600;
}

/* Views */
.view {
  padding: 16px;
  flex: 1;
}

/* Cards */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.card + .card {
  margin-top: 12px;
}

.card h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 16px;
}

/* Form Elements */
.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}

/* Style every field from the bare `input` selector, never an enumerated
   type list: the production HTML minifier strips type="text" as a
   redundant attribute, so `input[type="text"]` silently stops matching in
   the built output and text fields fall back to raw browser styling.
   Keeping this at the lowest specificity also lets the type-specific
   rules below (checkbox, date) override it naturally. */
input,
textarea,
select {
  display: block !important;
  width: 100% !important;
  padding: 0 10px !important;
  height: 36px !important;
  line-height: 34px !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  font-family: var(--font) !important;
  font-size: 14px !important;
  color: var(--text) !important;
  background-color: var(--bg) !important;
  box-sizing: border-box !important;
  transition: border-color 0.15s;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  margin: 0 !important;
  /* The Outlook webview paints its own outlines/shadows on form controls,
     which shows up as a dark box around text inputs — suppress everything
     except our own border so every control looks the same at rest. */
  outline: none !important;
  box-shadow: none !important;
}

/* Keep autofilled fields looking like every other field */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--bg) inset !important;
  -webkit-text-fill-color: var(--text) !important;
  border: 1px solid var(--border) !important;
}

.form-group input,
.form-group textarea,
.form-group select,
.input-group input {
  display: block !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

/* Checkboxes must stay inline beside their label text — the block/full-width
   rules above otherwise stack them on their own line. */
input[type="checkbox"],
input[type="radio"],
.form-group input[type="checkbox"],
.checkbox-group input[type="checkbox"] {
  display: inline-block !important;
  width: auto !important;
  height: auto !important;
  margin: 0 6px 0 0 !important;
  vertical-align: middle;
  -webkit-appearance: auto !important;
  -moz-appearance: auto !important;
  appearance: auto !important;
  accent-color: var(--primary);
}

/* Fields that are not yet usable should visibly read as inactive */
input:disabled,
textarea:disabled,
select:disabled {
  background-color: var(--bg-secondary) !important;
  color: var(--text-secondary) !important;
  cursor: not-allowed;
}

/* Native date/time pickers need their built-in segmented editor.
   appearance:none collapses it, which renders the placeholder as
   "dd------yyyy" and hides the calendar control (LCU-3846). */
input[type="date"],
input[type="datetime-local"] {
  -webkit-appearance: auto !important;
  -moz-appearance: auto !important;
  appearance: auto !important;
  line-height: normal !important;
  padding: 6px 10px !important;
  min-width: 0 !important;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 width=%2712%27 height=%2712%27 viewBox=%270 0 12 12%27%3E%3Cpath fill=%27%23605e5c%27 d=%27M2.5 4.5L6 8l3.5-3.5z%27/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding: 0 28px 0 10px !important;
  cursor: pointer;
}

input:focus,
textarea:focus,
select:focus {
  outline: none !important;
  border-color: var(--border-focus) !important;
  box-shadow: 0 0 0 1px var(--border-focus) !important;
}

.form-group textarea {
  resize: vertical;
  height: auto !important;
  min-height: 80px;
  padding: 6px 10px !important;
  line-height: 1.5 !important;
}

.form-row {
  display: flex;
  gap: 8px;
}

.form-row .form-group {
  flex: 1;
  /* Allow flex children to shrink so date inputs never clip their segments */
  min-width: 0;
}

.input-group {
  display: flex;
  gap: 0;
  margin-bottom: 8px;
}

.input-group input {
  flex: 1;
  min-width: 0;
  border-top-right-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
  border-right: none !important;
}

.input-group .btn {
  height: 36px;
  flex-shrink: 0;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text);
}

.input-group .btn:hover:not(:disabled) {
  background: var(--border);
}

.checkbox-group {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.checkbox-group label {
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-primary:active:not(:disabled) {
  background: var(--primary-active);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}

.btn-outline:hover:not(:disabled) {
  background: rgba(0, 120, 212, 0.05);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.btn-full {
  width: 100%;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
}

.btn-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.back-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 0;
  margin-bottom: 8px;
}

.back-btn:hover {
  text-decoration: underline;
}

/* Quick Actions */
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-actions .btn {
  flex: 1 1 calc(50% - 4px);
  min-width: 120px;
  font-size: 13px;
  padding: 10px 8px;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.badge-success {
  background: #dff6dd;
  color: var(--success);
}

.badge-danger {
  background: #fde7e9;
  color: var(--danger);
}

/* Settings */
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

/* Results & Messages */
.result-message {
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin: 12px 0;
}

.result-message.success {
  background: #dff6dd;
  color: var(--success);
  border: 1px solid #a7e3a5;
}

.result-message.error {
  background: #fde7e9;
  color: var(--danger);
  border: 1px solid #f1bbbd;
}

.error-message {
  color: var(--danger);
  font-size: 13px;
  margin: 8px 0;
}

.error-detail-toggle {
  background: none;
  border: none;
  color: inherit;
  font-family: var(--font);
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  margin-left: 4px;
  opacity: 0.8;
}

.error-detail-toggle:hover {
  opacity: 1;
}

.error-detail {
  margin-top: 6px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: var(--radius);
  font-size: 12px;
  font-family: monospace;
  word-break: break-word;
  white-space: pre-wrap;
}

/* List container */
.list-container {
  max-height: 300px;
  overflow-y: auto;
  margin-top: 12px;
}

.list-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.1s;
}

.list-item:hover {
  background: var(--bg-secondary);
}

.list-item:last-child {
  border-bottom: none;
}

/* A failed search must not look like an ordinary "nothing here" row —
   it is the difference between "no such customer" and "we could not ask". */
.list-item.error {
  background: #fde7e9;
  color: var(--danger);
  cursor: default;
}

/* Email preview */
.email-preview {
  background: var(--bg-secondary);
  font-size: 13px;
  margin: 12px 0;
  padding: 12px 16px;
  border-radius: var(--radius);
}

.email-preview p {
  margin-bottom: 4px;
}

/* Email banner (home page) */
.email-banner {
  background: var(--bg);
  margin-bottom: 12px;
  border-left: 3px solid var(--primary);
}

.email-banner-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.email-banner-subject {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-banner-sender {
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Search results */
.search-result {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.search-result:last-child {
  border-bottom: none;
}

.search-type-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
}

.type-customer {
  background: #e1dfdd;
  color: #323130;
}

.type-lead {
  background: #deecf9;
  color: #0078d4;
}

/* Loading */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

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

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ----------------------------------------------------------------
   Customer context card - the triage strip (LCU-3962)

   The reading order IS the triage order: verdict, the cases, has anyone
   touched it, commercial temperature. Divs, spans and buttons only - the
   card introduces NO form controls, so the bare `input, textarea, select`
   rule above and its five field-style groups are untouched (LCU-3942).
   Anything added here later that needs a <select> (a case filter, say)
   inherits that rule's !important block and will tempt you to raise its
   specificity to escape. Do not. Put the control elsewhere.

   Real <button> elements, not div + role - they get the Outlook
   high-contrast focus ring for free, and the `outline: none !important`
   above applies to inputs only, never to buttons.
   ---------------------------------------------------------------- */

.context-card {
  padding: 12px;
  /* 320px pane: wide content ellipses or scrolls inside its own container,
     it never widens the page. */
  overflow: hidden;
}

/* --- Band 1: verdict ---------------------------------------------------- */

.ctx-verdict {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
}

/* Always prominent. A domain match binds the card to a customer without
   knowing which contact wrote, so the name is what makes a wrong match
   obvious at a glance instead of silently framing someone else's cases. */
.ctx-customer {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The pill's TEXT carries the meaning; colour only reinforces it. */
.ctx-pill {
  flex-shrink: 0;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.ctx-pill-danger {
  background: var(--danger-soft);
  color: var(--danger-soft-fg);
}

.ctx-pill-warning {
  background: var(--warning-soft);
  color: var(--warning-soft-fg);
}

.ctx-pill-neutral {
  background: var(--neutral-soft);
  color: var(--neutral-soft-fg);
}

.ctx-pill-quiet,
.ctx-pill-checking {
  background: var(--quiet-soft);
  color: var(--quiet-soft-fg);
}

/* Outline only, never filled: "we could not find out" must not be mistaken
   for the filled danger pill that means "overdue". */
.ctx-pill-unavailable {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}

/* How we matched, in two words. Mitigates the wrong-customer risk a domain
   match carries by telling the reader which kind of match this is. */
.ctx-provenance {
  font-size: 11px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Band 2: the cases -------------------------------------------------- */

.ctx-cases {
  margin-top: 6px;
}

.ctx-cases:empty {
  margin-top: 0;
}

.ctx-cases-expanded {
  max-height: 200px;
  overflow-y: auto;
}

/* The placeholder row must be EXACTLY the height of a real row. The card
   sits above the Quick Actions buttons, so a card that grows late shoves
   them down under a finger that is already moving and the user files
   against the wrong record. */
.ctx-case,
.ctx-skeleton-row {
  display: block;
  width: 100%;
  min-height: 42px;
  padding: 5px 0;
  border: none;
  border-top: 1px solid var(--border);
  background: transparent;
  font-family: var(--font);
  text-align: left;
  overflow: hidden;
}

.ctx-case {
  cursor: pointer;
}

.ctx-case:hover {
  background: var(--bg-secondary);
}

.ctx-case:focus-visible,
.ctx-more:focus-visible,
.ctx-cta:focus-visible,
.ctx-note-btn:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: -2px;
}

.ctx-case-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.ctx-ref {
  flex-shrink: 0;
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  font-size: 12px;
  color: var(--text-secondary);
}

.ctx-subject {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ctx-case-meta {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Only the due chip is coloured - the age, owner and status beside it stay
   secondary so the breach signal is the one thing that carries weight. */
.ctx-due-overdue {
  color: var(--danger);
  font-weight: 600;
}

.ctx-due-today {
  color: var(--warning-soft-fg);
  font-weight: 600;
}

/* --- Band 2 footer: expand, or the contextual CTA ----------------------- */

.ctx-foot:empty {
  display: none;
}

.ctx-more,
.ctx-cta {
  display: block;
  width: 100%;
  padding: 7px 0;
  border: none;
  border-top: 1px solid var(--border);
  background: transparent;
  font-family: var(--font);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.ctx-more {
  color: var(--text-secondary);
}

.ctx-cta {
  color: var(--primary);
  font-weight: 600;
}

.ctx-more:hover,
.ctx-cta:hover {
  background: var(--bg-secondary);
}

/* --- Band 3: has someone already touched it ----------------------------- */

.ctx-note {
  min-height: 34px;
  margin-top: 4px;
  padding-top: 7px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
}

.ctx-note-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 12px;
  color: var(--text-secondary);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Tap to expand in place - the full text is already loaded. */
.ctx-note-open .ctx-note-btn {
  white-space: normal;
  overflow-wrap: break-word;
  /* Notes are where synced emails land, so an expanded one can be thousands of
     characters. Cap and scroll it, the same as the expanded case list. */
  max-height: 200px;
  overflow-y: auto;
}

.ctx-note-lead {
  color: var(--text);
  font-weight: 600;
}

/* --- Band 4: commercial temperature ------------------------------------- */

/* Counts only, no chrome, no affordance: it moderates your tone, it is not
   actionable here. Omitted entirely when both counts are zero rather than
   printing "0 - 0". */
.ctx-sales {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Failure rows ------------------------------------------------------- */

/* A band that failed must look different from a band that is genuinely
   empty. "No open cases" during an outage is a lie a service person will
   act on (LCU-3951). */
.ctx-msg-row {
  padding: 8px 0;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
}

.ctx-error-text {
  color: var(--danger);
}

.ctx-link {
  padding: 0;
  border: none;
  background: transparent;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  text-decoration: underline;
  cursor: pointer;
}

.ctx-link:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* --- Skeleton ----------------------------------------------------------- */

/* Static grey, no pulse. Motion in a 320px pane reads as an error state,
   and reserving the right HEIGHT matters far more than the shimmer. */
.ctx-skeleton-row {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
}

.ctx-skeleton-bar {
  display: block;
  height: 9px;
  border-radius: 3px;
  background: var(--skeleton);
}

.ctx-skeleton-bar-wide {
  width: 85%;
}

.ctx-skeleton-bar-narrow {
  width: 55%;
}

/* --- Degenerate match strip (inside the email banner) -------------------- */

.ctx-strip {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
}

