/* ==========================================================================
   The Engineering Dispatch — Components & Interactive Elements
   Buttons, search palette, AI drawer, modal dialogs, lightbox.
   ========================================================================== */

/* ==========================================================================
   1. Buttons & Controls
   ========================================================================== */

.btn-primary,
.button-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 750;
  color: #ffffff !important;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-xs);
  text-decoration: none;
  transition: background-color 120ms ease, border-color 120ms ease;
}

html[data-theme="dark"] .btn-primary,
html[data-theme="dark"] .button-primary {
  color: #121316 !important;
}

.btn-primary:hover,
.button-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-secondary,
.button-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-xs);
  text-decoration: none;
  transition: background-color 120ms ease, color 120ms ease;
}

.btn-secondary:hover,
.button-secondary:hover {
  background: var(--surface-raised);
}

.button {
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 700;
  border-radius: var(--radius-xs);
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--text);
  transition: background-color 120ms ease;
}

.text-button {
  background: none;
  border: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 6px;
  text-decoration: none;
}

.text-button:hover {
  text-decoration: underline;
}

.icon-button {
  min-width: 36px;
  height: 36px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-muted);
  transition: border-color 120ms ease, background-color 120ms ease, color 120ms ease;
}

.icon-button:hover {
  border-color: var(--rule);
  background: var(--surface);
  color: var(--text);
}

.icon-button svg,
.search-field svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.search-shortcut {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-subtle);
  padding: 1px 5px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  background: var(--surface-raised);
}

.theme-icon {
  font-size: 16px;
  line-height: 1;
}

.assistant-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 750;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-xs);
  transition: border-color 120ms ease, background-color 120ms ease;
}

.assistant-trigger:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.ai-spark {
  color: var(--accent);
  font-size: 12px;
}

.mobile-menu-toggle {
  display: none;
  width: 36px;
  height: 36px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  padding: 0;
}

.burger-bar {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
}

/* ==========================================================================
   2. Modals & Dialogs Common Architecture
   ========================================================================== */

dialog {
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-xs);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-overlay);
  padding: 0;
}

dialog::backdrop {
  background: rgb(15 18 22 / 68%);
}

dialog[open] {
  animation: dialog-fade-in 140ms ease-out;
}

@keyframes dialog-fade-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dialog-close {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  font-family: var(--mono);
  font-size: 16px;
  color: var(--text-muted);
  border: 1px solid var(--rule);
  border-radius: var(--radius-xs);
  background: var(--surface-raised);
  transition: color 120ms ease, border-color 120ms ease;
}

.dialog-close:hover {
  color: var(--text);
  border-color: var(--rule-strong);
}

/* ==========================================================================
   3. Search Command Palette Modal
   ========================================================================== */

.search-dialog {
  width: min(640px, calc(100% - 32px));
  max-height: min(84vh, 720px);
}

.search-dialog-panel {
  display: flex;
  flex-direction: column;
}

.search-dialog-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 2px solid var(--rule-strong);
  background: var(--surface-tint);
}

.search-field {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-field input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 16px;
  font-weight: 650;
  color: var(--text);
}

.search-field input::placeholder {
  color: var(--text-subtle);
  font-weight: 400;
}

.search-dialog-hint {
  padding: 8px 20px;
  background: var(--surface-raised);
  border-bottom: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-subtle);
}

.palette-results {
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.search-empty {
  padding: 32px 20px;
  margin: 0;
  text-align: center;
  color: var(--text-subtle);
  font-size: 14px;
}

.search-result {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
  color: var(--text);
  transition: background-color 100ms ease;
}

.search-result:hover,
.search-result[aria-selected="true"] {
  background-color: var(--surface-raised);
}

.search-result-title {
  font-size: 15px;
  font-weight: 750;
  color: var(--text);
}

.search-result-meta {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 650;
  color: var(--accent);
}

.search-result-description {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.search-dialog-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-top: 1px solid var(--rule);
  background: var(--surface-tint);
  font-size: 12px;
  color: var(--text-subtle);
}

.search-dialog-footer a {
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
}

/* ==========================================================================
   4. AI Assistant Drawer Modal
   ========================================================================== */

.assistant-dialog {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: auto;
  width: min(440px, 100%);
  height: 100dvh;
  max-height: none;
  margin: 0;
  border-radius: 0;
  border-block: 0;
  border-right: 0;
  border-left: 2px solid var(--rule-strong);
}

.assistant-panel {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 24px;
  background: var(--surface);
}

.assistant-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--rule);
}

.assistant-eyebrow {
  margin: 0 0 4px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.assistant-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.assistant-disclaimer {
  margin: 12px 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-subtle);
}

.assistant-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-block: 8px;
  border-block: 1px solid var(--rule);
}

.assistant-messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  padding-block: 16px;
  min-height: 0;
}

.assistant-message {
  max-width: 90%;
  padding: 12px 15px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-xs);
  font-size: 13.5px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.assistant-message p {
  margin: 0;
}

.assistant-message p + p {
  margin-top: 8px;
}

.assistant-message-user {
  align-self: flex-end;
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}

.assistant-message-ai {
  align-self: flex-start;
  background: var(--surface-raised);
}

.assistant-message-error {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 8%, var(--surface));
}

.assistant-composer {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
}

.assistant-composer textarea {
  flex: 1;
  min-height: 44px;
  max-height: 140px;
  resize: vertical;
  padding: 10px 12px;
  font-size: 13.5px;
  border: 1px solid var(--rule);
  border-radius: var(--radius-xs);
  background: var(--page);
  color: var(--text);
}

.assistant-composer textarea:focus {
  border-color: var(--accent);
  outline: 0;
}

/* ==========================================================================
   5. 2FA Verification Dialog
   ========================================================================== */

.verify-dialog {
  width: min(420px, calc(100% - 32px));
}

.verify-panel {
  padding: 24px;
}

.verify-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.verify-eyebrow {
  margin: 0 0 4px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.verify-heading h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
}

.verify-panel p {
  margin: 0 0 16px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
}

.verification-code {
  width: 100%;
  padding: 12px;
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.35em;
  text-align: center;
  border: 2px solid var(--rule-strong);
  border-radius: var(--radius-xs);
  background: var(--page);
  color: var(--text);
}

.verification-feedback {
  min-height: 20px;
  margin: 8px 0;
  font-size: 12px;
  color: var(--text-subtle);
}

.verification-feedback.is-error {
  color: var(--danger);
}

.verification-feedback.is-success {
  color: var(--success);
}

.verify-panel .button-primary {
  width: 100%;
}

/* ==========================================================================
   6. Lightbox Fullscreen Dialog
   ========================================================================== */

.lightbox-dialog {
  width: min(96vw, 1280px);
  height: min(94vh, 900px);
  border: 0;
  background: transparent;
  box-shadow: none;
}

.lightbox-dialog figure {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0;
}

.lightbox-dialog img {
  max-width: 100%;
  max-height: calc(100% - 40px);
  object-fit: contain;
}

.lightbox-dialog figcaption {
  min-height: 24px;
  padding-top: 10px;
  color: #eceae5;
  font-family: var(--mono);
  font-size: 12px;
  text-align: center;
}

.lightbox-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 38px;
  height: 38px;
  border: 1px solid rgb(255 255 255 / 35%);
  border-radius: var(--radius-xs);
  background: rgb(0 0 0 / 60%);
  color: #fff;
  font-size: 22px;
}
