/* ============================================================
   Briidea Review Tool — Custom Styles
   Supplements Tailwind CDN. Uses the same Briidea design tokens.
   ============================================================ */

/* Alpine.js — hide [x-cloak] elements until Alpine initialises */
[x-cloak] { display: none !important; }

/* Smooth scrollbar for sidebar */
aside {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}

/* Hide scrollbar on tab nav while keeping scroll functionality */
.tab-scroll-nav { scrollbar-width: none; -ms-overflow-style: none; }
.tab-scroll-nav::-webkit-scrollbar { display: none; }


[x-cloak] { display: none !important; }


/* Loading spinner animation */
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.animate-spin { animation: spin 0.7s linear infinite; }

/* Panel collapse/expand transitions */
[x-show] { transition: opacity 0.15s ease; }

/* Table sort-hover effect */
th[data-sort]:hover { cursor: pointer; background: #C8CDD0; }

/* Tab i-icon: match parent button hover colour */
button.group:hover .tab-info-icon { color: rgba(44, 62, 80, 0.6); }

/* Tab active indicator */
nav button[class*="border-navy"] {
  position: relative;
}

/* Truncate utility for sidebar items */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Focusable input consistent highlight */
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(46, 134, 193, 0.2);
  border-color: #2E86C1;
}

/* Badge status dots */
.status-dot-prospect { background-color: #F39C12; }
.status-dot-active   { background-color: #1E8449; }
.status-dot-reporting{ background-color: #2E86C1; }
.status-dot-archived { background-color: #D5D8DC; }

/* Responsive: hide sidebar on small screens, show when toggled open */
@media (max-width: 768px) {
  aside { display: none; }
  aside.sidebar-open { display: flex !important; }
  main { margin-left: 0 !important; }
}

/* Sidebar hamburger button — visible only on mobile */
.sidebar-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 4px;
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(44, 62, 80, 0.5);
  line-height: 0;
}
.sidebar-hamburger:hover { color: rgb(44, 62, 80); }
@media (max-width: 768px) {
  .sidebar-hamburger { display: flex; }
}

/* Sidebar backdrop — shown by Alpine x-show on mobile only */
.sidebar-backdrop {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 30;
}
@media (min-width: 769px) {
  .sidebar-backdrop { display: none !important; }
}

/* Help system */
.help-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  border: 1px solid rgba(46, 134, 193, 0.35);
  border-radius: 999px;
  background: #fff;
  color: #2E86C1;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.help-trigger:hover,
.help-trigger:focus-visible {
  background: #EBF5FB;
  border-color: #2E86C1;
  color: #1E3A5F;
}

/* Jargon tooltips — all styles scoped to body.beginner-mode */
body.beginner-mode [data-jt] {
  position: relative;
  cursor: help;
}
body.beginner-mode span[data-jt] {
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
body.beginner-mode [data-jt]::after {
  display: none;
  content: attr(data-jt);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  color: #f9fafb;
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1.45;
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  white-space: normal;
  width: 220px;
  z-index: 200;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  text-align: left;
  text-decoration: none;
}
body.beginner-mode [data-jt]::before {
  display: none;
  content: '';
  position: absolute;
  bottom: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #1f2937;
  z-index: 200;
  pointer-events: none;
}
body.beginner-mode [data-jt]:hover::after,
body.beginner-mode [data-jt]:hover::before {
  display: block;
}

.help-overlay {
  background: rgba(17, 24, 39, 0.45);
  z-index: 80;
}

.help-popover {
  position: fixed;
  top: 5rem;
  right: 1.5rem;
  width: min(26rem, calc(100vw - 3rem));
  max-height: calc(100vh - 7rem);
  overflow-y: auto;
  border: 1px solid #D5D8DC;
  border-radius: 8px;
  box-shadow: 0 24px 64px rgba(17, 24, 39, 0.24);
}

.help-popover-section {
  border-top: 1px solid #F4F6F7;
  padding-top: 0.85rem;
}

.help-wiki-topic {
  background: #fff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.help-wiki-topic-active {
  border-color: #2E86C1;
  box-shadow: 0 0 0 3px rgba(46, 134, 193, 0.16);
}

@media (max-width: 768px) {
  .help-popover {
    top: auto;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 82vh;
    border-radius: 8px 8px 0 0;
  }
}

/* ============================================================
   Dark Mode
   Controlled by class="dark" on <html>, toggled via Alpine store.
   Strategy: override semantic CSS variables where possible;
   use explicit class selectors for bg-white (which can't be
   changed via --color-white without breaking text-white on
   the sidebar and nav buttons).
   ============================================================ */

html.dark {
  --color-grey:        #111827; /* page/body background    (was #f4f6f7) */
  --color-grey-dark:   #374151; /* borders, dividers        (was #d5d8dc) */
  --color-ink:         #d1d5db; /* primary text             (was #2c3e50) */
  --color-sky:         #1e3a5f; /* light-blue tint panels   (was #d6eaf8) */
  --color-sky-dark:    #2a4f7f; /* (was #aed6f1) */
  --color-green-light: #0d2e1a; /* light-green tint panels  (was #d5f5e3) */
}

/* Card / panel backgrounds (white surfaces in light mode) */
html.dark .bg-white {
  background-color: #1f2937;
}

/* Navy / dark-blue text is unreadable on dark cards — lighten it
   (recommendation action line, area chips, etc.). Opacity-suffixed
   classes like text-navy/70 are separate selectors and unaffected. */
html.dark .text-navy,
html.dark .text-blue-dark {
  color: var(--color-blue-light);
}

/* Form fields — transparent by default in Tailwind, so set explicitly */
html.dark input:not([type="checkbox"]):not([type="radio"]),
html.dark select,
html.dark textarea {
  background-color: #1f2937;
  color: var(--color-ink);
  border-color: var(--color-grey-dark);
}

html.dark input::placeholder,
html.dark textarea::placeholder {
  color: #6b7280;
}

/* Help trigger button */
html.dark .help-trigger {
  background: #1f2937;
  border-color: rgba(46, 134, 193, 0.4);
  color: #5dade2;
}

html.dark .help-trigger:hover,
html.dark .help-trigger:focus-visible {
  background: #1e3a5f;
  border-color: #2e86c1;
  color: #d1d5db;
}

/* Help popover drawer */
html.dark .help-popover {
  background: #1f2937;
  border-color: #374151;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

html.dark .help-popover-section {
  border-top-color: #374151;
}

html.dark .help-wiki-topic {
  background: #1f2937;
}

html.dark .help-wiki-topic-active {
  border-color: #2e86c1;
  box-shadow: 0 0 0 3px rgba(46, 134, 193, 0.25);
}
