@import url('/static/css/icons.css');

/* Unified Navigation Styles */
nav {
    display: flex;
    align-items: center;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    width: 100%;
    height: 64px;
    position: relative;
    padding: 0;
    justify-content: space-between;
}

/* Force fixed height on all navigation instances */
.unified-nav {
    height: 64px;
    min-height: 64px;
    max-height: 64px;
}

/* Standard sizing tokens */
:root {
    /* Panels (docked/right-side) */
    --panel-width: 480px;
    /* Back-compat alias used across the existing panel system */
    --modal-panel-width: var(--panel-width);

    /* Modals (centered) */
    --modal-width-md: 560px;
    --modal-width-lg: 960px;
    --modal-width-xl: 1200px;
    --modal-width-xxl: 1440px;
}

/* =========================================================
   Shared Markdown Typography
   - Centralized here so it applies everywhere (manual modal,
     workflow outputs, previews) without duplicating per-page CSS.
   ========================================================= */
.markdown-content {
    overflow-x: hidden;
    padding: var(--space-md);
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    font-size: 0.9rem;
    color: var(--color-text-primary);
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
    margin-top: 1.5em;
    margin-bottom: 0.75em;
    font-weight: 600;
    line-height: 1.25;
}

.markdown-content h1 {
    font-size: 1.5rem;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 0.3em;
    text-transform: uppercase;
}

.markdown-content h2 {
    font-size: 1.25rem;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 0.3em;
    text-transform: uppercase;
}

.markdown-content h3 { font-size: 1.125rem; }

.markdown-content p,
.markdown-content ul,
.markdown-content ol {
    margin-top: 0;
    margin-bottom: 16px;
}

.markdown-content ul,
.markdown-content ol {
    padding-left: 2em;
}

.markdown-content blockquote {
    padding: 0 1em;
    color: var(--color-text-secondary);
    border-left: 0.25em solid var(--color-border);
    margin: 0 0 16px 0;
}

.markdown-content code {
    padding: 0.2em 0.4em;
    margin: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 85%;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}

.markdown-content pre {
    padding: 16px;
    overflow: auto;
    font-size: 85%;
    line-height: 1.45;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    margin-bottom: 16px;
}

.markdown-content pre code {
    padding: 0;
    margin: 0;
    font-size: 100%;
    background-color: transparent;
    border-radius: 0;
    white-space: pre;
}

.markdown-content table {
    display: block;
    width: 100%;
    overflow: auto;
    margin-bottom: 16px;
    border-collapse: collapse;
}

.markdown-content table th,
.markdown-content table td {
    padding: 6px 13px;
    border: 1px solid var(--color-border);
}

.markdown-content table tr {
    background-color: transparent;
    border-top: 1px solid var(--color-border);
}

.markdown-content table tr:nth-child(2n) {
    background-color: var(--color-surface-variant);
}

/* Size variants for modals/panels */
.modal-container.modal-container--size-md {
    max-width: min(100vw, var(--modal-width-md));
}

.modal-container.modal-container--size-lg {
    max-width: min(100vw, var(--modal-width-lg));
}

.modal-container.modal-container--size-xl {
    max-width: min(96vw, var(--modal-width-xl));
}

.modal-container.modal-container--size-xxl {
    max-width: min(98vw, var(--modal-width-xxl));
}
/* Project segment styles */
.nav-segment--project {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative; /* anchor dropdown to segment */
}

/* Simplified native dropdown styling */
.nav-select {
  display: inline-block;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-text-primary);
  cursor: pointer;
  font: inherit;
  line-height: 1.2;
  max-width: 240px;
}

.nav-select:focus-visible {
  outline: 2px solid var(--color-status-info);
  outline-offset: 2px;
}

/* Small icon button next to dropdowns (e.g., new workflow) */
.nav-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-btn-icon:hover {
  background: var(--color-brand-primary);
  border-color: var(--color-brand-primary);
  color: var(--color-on-primary);
}

.nav-btn-icon:focus-visible {
  outline: 2px solid var(--color-status-info);
  outline-offset: 2px;
}

/* Nav action button (Edit/Run buttons in workflow segment) */
.nav-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  background: var(--color-brand-dark);
  color: #ffffff;
}

.nav-action-btn:hover {
  background: var(--color-brand-button);
  color: var(--color-on-primary);
}

.nav-action-btn .icon-regular {
  font-size: 16px;
  color: inherit;
}

/* Icons inherit color naturally from parent */

/* Nav toggle (e.g., JSON view toggle) */
.nav-segment--toggle {
  display: flex;
  align-items: center;
}

.nav-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

.nav-toggle:hover {
  background: var(--color-brand-primary-15);
}

.nav-toggle input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--color-brand-primary);
  cursor: pointer;
}

.nav-toggle-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--color-text-secondary);
}

.nav-toggle input:checked + .nav-toggle-label {
  color: var(--color-brand-primary);
}

/* Platform branding segment - QESTIT logo (red) + platform name */
/* NOTE: QESTIT is platform branding - always red, never themed */
.nav-segment--platform {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 var(--space-md);
    height: 100%;
    text-decoration: none;
    color: #d50032; /* QESTIT red - hardcoded, not themed */
    position: relative;
}

.nav-segment--platform .platform-logo {
    height: 16px;
    width: auto;
    flex-shrink: 0;
}

.nav-segment--platform .platform-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-secondary);
    white-space: nowrap;
}

.platform-hover-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    background: var(--color-surface-hover);
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}
.platform-hover-overlay img { width: 32px; height: 32px; }
.nav-segment--platform:hover .platform-hover-overlay { opacity: 1; }

/* Home page title styling */
.unified-nav .nav-left {
    display: flex;
    align-items: center;
    height: 100%;
}

/* Title segment (utilities/workflows) - shows page name, back arrow on hover */
.nav-segment--title.nav-home {
    text-decoration: none;
    color: var(--color-text-primary);
    cursor: pointer;
    position: relative;
    /* Flexible width for utilities - grows with title text */
    /* Use padding like platform segment for consistency */
    padding: 0 var(--space-md);
}
.nav-home-text { font-size: 1.125rem; font-weight: 600; line-height: 64px; letter-spacing: -0.01em; white-space: nowrap; }

.title-hover-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    background: var(--color-surface-hover);
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}
.title-hover-overlay .nav-home-icon {
    fill: currentColor;
    opacity: 1;
}
.nav-segment--title.nav-home:hover .title-hover-overlay { opacity: 1; }

/* Workflow mode: always show blur overlay with back arrow, fixed width */
.workflow-mode .nav-segment--title .nav-home-text { display: none; }
.workflow-mode .nav-segment--title .title-hover-overlay { opacity: 1; }
.workflow-mode .nav-segment--title.nav-home { width: 64px; min-width: 64px; }

/* Non-home pages only */
.unified-nav:not(.home-mode) {
    align-items: stretch;
}

/* Consistent title styling */
.nav-title {
    margin: 0;
    color: var(--color-text-primary);
    font-size: 1.125rem; /* 18px */
    font-weight: 600;
    letter-spacing: -0.005em;
}

/* Automatic separators between segments (robust against interleaved scripts) */
.unified-nav .nav-segment { border-left: 1px solid var(--color-border); }
.nav-left .nav-segment:first-child { border-left: none; }

.unified-nav .nav-spacer { border-left: 1px solid var(--color-border); }
.unified-nav .nav-left { border-right: none; }

/* Reduce padding for actions segment to avoid double spacing */
.unified-nav .nav-segment--actions { padding: 0; }

/* Common Elements */
.nav-segment {
    display: flex;
    align-items: center;
    height: 100%;
    position: relative;
    padding: 0 var(--space-md);
    transition: background-color 0.2s ease;
    cursor: default;
}

.unified-nav .nav-segment:not(:empty):hover { background-color: var(--color-surface-hover); }

/* Simplified active selection color for all segments */
.unified-nav .nav-segment.active {
    background-color: var(--color-accent-on-light-15);
    color: var(--color-text-primary);
}



.nav-segment--back {
    width: 64px;
    padding: 0;
    justify-content: center;
    cursor: default;
}



.nav-segment--title { cursor: default; min-width: 64px; }



/* Workflow/page title size (smaller than before) */
.nav-segment--title h2 {
    font-size: 1.125rem; /* 18px */
    font-weight: 600;
    margin: 0;
    letter-spacing: -0.005em;
}

.nav-spacer {
    flex: 1;
    align-self: stretch;
}

.back-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: var(--color-text-secondary);
    text-decoration: none;
}

.back-button:hover {
    color: var(--color-text-primary);
}

.back-button svg {
    transition: transform 0.2s ease;
    fill: #333333;
}

.back-button:hover svg {
    transform: translateX(-2px);
    fill: #000000;
}

/* Focus styles for keyboard navigation */
.nav-project-toggle:focus-visible,
.nav-project-settings:focus-visible,
.back-button:focus-visible,
.action-btn[role="button"]:focus-visible,
.nav-segment--notification:focus-visible,
.nav-segment--version:focus-visible,
.nav-segment--client:focus-visible,
.nav-segment--status:focus-visible {
    outline: 2px solid var(--color-status-info);
    outline-offset: 2px;
    border-radius: 6px;
}

/* Status section */
.status-items {
    display: flex;
    gap: var(--space-md);
    justify-content: flex-start;
    width: 100%;
}

.status-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.status-item .label {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
}

/* Status indicators */
#appStatus {
    font-weight: 500;
    transition: all 0.2s ease;
}

#appStatus.ready {
    color: var(--color-text-primary);
}

#appStatus.processing {
    color: var(--color-accent-on-light);
}

#appStatus.complete {
    color: var(--color-status-success);
}

#appStatus.error {
    color: var(--color-status-error);
}

/* Status segment - now clickable for modal, no hover tooltip - moved to bottom with other segments */



/* Error message */
.error-message {
    color: var(--color-status-error);
    padding: 1rem;
    text-align: center;
    font-style: italic;
}

/* Hover effects - removed as handled by individual segments */

/* Action items - clean, no border management needed */
.nav-action-item {
    display: flex;
    align-items: center;
    height: 64px;
    padding: 0 var(--space-md);
    transition: background-color 0.2s ease;
}

/* Action buttons - Base styles for all buttons */
.unified-nav .action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 24px;
    color: white;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    min-width: 96px;
    height: 36px;
    font-size: 13.5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin: 14px;
    border: none;
}

/* Action buttons with left icon */
.unified-nav .action-btn.icon-left {
    gap: 8px;
}

.unified-nav .action-btn .icon-regular {
    font-size: 18px;
    line-height: 1;
}

/* Standardized button variants */
.unified-nav .action-btn.is-primary { background-color: var(--color-brand-button); color: var(--color-on-primary); }
.unified-nav .action-btn.is-primary:hover { background-color: var(--color-brand-button-hover); color: var(--color-on-primary-hover); }
/* Icons inherit text color naturally from parent */
.unified-nav .action-btn.is-secondary { background-color: var(--color-brand-dark); color: #ffffff; }
.unified-nav .action-btn.is-secondary:hover { background-color: var(--color-brand-button); color: var(--color-on-primary); }
.unified-nav .action-btn.is-success { background-color: var(--color-status-success); color: #fff; }
.unified-nav .action-btn.is-danger { background-color: var(--color-status-error); color: #fff; }

.unified-nav .action-btn:hover { filter: brightness(1.08); }

.unified-nav .action-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Primary actions - smart button color (adapts to bright/dark brand colors) */
.unified-nav .generate,
.unified-nav .resume,
.unified-nav .retry-failed { background-color: var(--color-brand-button); color: var(--color-on-primary); }

.unified-nav .generate:hover,
.unified-nav .resume:hover,
.unified-nav .retry-failed:hover { background-color: var(--color-brand-button-hover); color: var(--color-on-primary-hover); }

/* Stop action - red */
.unified-nav .stop { background-color: var(--color-status-error); color: white; }

.unified-nav .stop:hover { filter: brightness(1.08); }

/* Success actions - green */
.unified-nav .refresh-contexts { background-color: var(--color-status-success); color: white; }

.unified-nav .refresh-contexts:hover { filter: brightness(1.08); }

/* Confluence/Jira connector actions - specific button styling */
.unified-nav .confluence-download {
    background-color: var(--color-status-info);
    color: white;
}

.unified-nav .confluence-download:hover { filter: brightness(1.08); }

.unified-nav .confluence-refresh {
    background-color: var(--color-status-success);
    color: white;
}

.unified-nav .confluence-refresh:hover { filter: brightness(1.08); }

/* Special case: disabled buttons (override all specific colors) */
.unified-nav .action-btn.disabled,
.unified-nav .action-btn:disabled {
    background-color: var(--color-disabled);
    color: var(--color-on-disabled);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
    pointer-events: none;
}

.unified-nav .action-btn.disabled:hover,
.unified-nav .action-btn:disabled:hover {
    background-color: var(--color-disabled) !important;
    color: var(--color-on-disabled) !important;
    transform: none;
}

/* Retry Failed button - special layout only */
.unified-nav .retry-failed {
    gap: 8px;
}

.unified-nav .retry-failed img {
    filter: brightness(0) invert(1); /* Make icon white */
}

/* Version segment unifies with standard segment hover */
/* NOTE: Version segment shows QESTIT logo - always red, never themed */
.nav-segment--version {
    cursor: pointer;
    gap: 8px;
    color: #d50032; /* QESTIT red - hardcoded, not themed */
}

.nav-segment--whatsnew,
.nav-segment--config { cursor: pointer; gap: 8px; }

.nav-link-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
}

.nav-segment--whatsnew:hover .nav-link-text,
.nav-segment--config:hover .nav-link-text,
.nav-segment--version:hover .nav-link-text { color: var(--color-text-primary); }

/* Hide Change Notes text on non-home pages */
.unified-nav:not(.home-mode) .nav-segment--version .nav-link-text { display: none; }

/* Remove underline for Settings link */
.nav-segment--config,
.nav-segment--config:hover,
.nav-segment--config:focus-visible { text-decoration: none; }



/* Active states unified via .nav-segment.active above */

.version-number { display: none; }

.nav-segment--version #qestit-logo { height: 16px; width: auto; margin-bottom: -2px; }

/* Client segment unifies with standard segment hover */
.nav-segment--client {
    cursor: pointer;
    gap: 8px;
}

/* Constrain injected client logo SVG to fit nav height */
.nav-segment--client svg {
    height: 48px;
    width: auto;
    max-width: 200px;
    display: block;
    flex-shrink: 0;
}

.client-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
}

/* merged client hover/active with shared interactive segment rules above */

/* Status segment for clickable token/cost info */
.nav-segment--status {
    cursor: pointer;
    transition: all 0.2s ease;
}

/* User Manual segment */
.nav-segment--help {
    cursor: pointer;
    gap: 0;
}

.nav-segment--help:hover {
    gap: 10px;
}

.nav-segment--help .icon-regular {
    font-size: 18px;
    color: var(--color-text-secondary);
}

.nav-segment--help:hover .icon-regular {
    color: var(--color-text-primary);
}

/* Collapsible label: icon-only by default, expands on hover */
.nav-help-label {
    max-width: 0;
    overflow: hidden;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
    transition: max-width 0.2s ease;
}

.nav-segment--help:hover .nav-help-label {
    max-width: 140px;
    color: var(--color-text-primary);
}

/* merged status hover/active with shared interactive segment rules above */

/* Shared modal system */
.modal-backdrop {
    position: fixed;
    top: 64px; /* Start below navigation */
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 9999;
    display: flex;
    align-items: flex-start; /* Align to top instead of center */
    justify-content: center;
    padding: 20px;
    opacity: 1;
}

.modal-backdrop.show {
    opacity: 1;
}

.modal-container {
    position: relative;
    /* Fixed height: full height minus nav and backdrop padding */
    height: calc(100vh - 64px - 40px);
    max-height: calc(100vh - 64px - 40px);
    width: 100%;
    overflow: hidden;
    background: var(--color-surface);
    border-radius: 16px;
    box-shadow:
        0 20px 25px -5px rgba(0, 0, 0, 0.1),
        0 10px 10px -5px rgba(0, 0, 0, 0.04),
        0 0 0 1px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    opacity: 1;
    transform: none;
}

.modal-backdrop.show .modal-container {
    opacity: 1;
    transform: none;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 24px 20px 24px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface-variant);
    border-radius: 16px 16px 0 0;
    flex-shrink: 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-text-primary);
    letter-spacing: -0.025em;
}

.modal-close {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    padding: 4px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #64748b;
    border-radius: 4px;
}

.modal-content {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

/* User Manual modal layout (XL + TOC sidebar) */
.user-manual-modal .modal-content {
    /* Manual modal scroll is handled by .user-manual-main, not the modal container */
    overflow: hidden;
}

.user-manual-modal .modal-container {
    max-height: calc(100vh - 64px - 40px);
}

.user-manual-modal .modal-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-manual-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.user-manual-bulk-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-surface);
    color: var(--color-text-secondary);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.user-manual-bulk-btn:hover {
    background: var(--color-brand-primary-15);
    color: var(--color-text-primary);
}

.user-manual-bulk-btn .icon-regular {
    font-size: 18px;
    color: inherit;
}

/* Segmented control (copied from utilities.css for pages that don't load it) */
.cfg-segmented {
    display: inline-flex;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--color-surface);
    flex: 0 0 auto;
}

.cfg-segment {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    color: var(--color-text);
    border-right: 1px solid var(--color-border);
}

.cfg-segment:last-child {
    border-right: 0;
}

.cfg-segment input {
    display: none;
}

.cfg-segment:has(input:checked) {
    background: var(--color-surface-variant);
    font-weight: 600;
}

/* Language toggle in user manual modal */
.user-manual-lang-toggle {
    font-size: 12px;
}

.user-manual-lang-toggle .cfg-segment {
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 700;
}

.user-manual-modal .modal-header .icon-regular {
    font-size: 18px;
    color: var(--color-text-secondary);
}

.user-manual-topic {
    margin-left: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
}

.user-manual-modal .user-manual-content {
    display: flex;
    overflow: hidden; /* sidebar + main handle their own scrolling */
    height: 100%;
    min-height: 0;
}

.user-manual-sidebar {
    width: 300px;
    max-width: 34%;
    border-right: 1px solid var(--color-border);
    background: var(--color-surface-variant);
    overflow: auto;
    min-height: 0;
}

.user-manual-sidebar-top {
    padding: 16px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
}

.user-manual-tabs {
    display: inline-flex;
    width: 100%;
    gap: 8px;
}

.user-manual-tab {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-surface);
    color: var(--color-text-secondary);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s ease;
}

.user-manual-tab:hover {
    background: var(--color-brand-primary-15);
    color: var(--color-text-primary);
}

.user-manual-tab.active {
    background: var(--color-brand-primary);
    border-color: var(--color-brand-primary);
    color: var(--color-on-primary);
}

.user-manual-tab:focus-visible {
    outline: 2px solid var(--color-status-info);
    outline-offset: 2px;
}

.user-manual-tabpanes {
    height: calc(100% - 0px);
}

.user-manual-pane {
    display: none;
}

.user-manual-pane.active {
    display: block;
}

.user-manual-select-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--color-text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.user-manual-select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-surface);
    color: var(--color-text-primary);
    font: inherit;
}

.user-manual-select:focus-visible {
    outline: 2px solid var(--color-status-info);
    outline-offset: 2px;
}

.user-manual-toc {
    padding: 14px 16px 18px 16px;
    font-size: 13px;
    color: var(--color-text-secondary);
}

.user-manual-toc .toc {
    margin: 0;
}

.user-manual-toc ul {
    list-style: none;
    padding-left: 0;
    margin: 10px 0 0 0;
}

.user-manual-toc ul ul {
    padding-left: 16px; /* indent only nested levels (h3+) */
    margin-top: 6px;
}

.user-manual-toc ul ul ul {
    padding-left: 28px; /* deeper nesting */
}

.user-manual-toc li {
    margin: 6px 0;
}

.user-manual-toc a {
    color: var(--color-text-secondary);
    text-decoration: none;
    border-radius: 6px;
    display: block;
    width: 100%;
    padding: 4px 6px;
}

.user-manual-toc a:hover {
    background: var(--color-brand-primary-15);
    color: var(--color-text-primary);
}

.user-manual-toc a.active {
    background: var(--color-brand-primary);
    color: var(--color-on-primary);
}

.user-manual-main {
    flex: 1;
    overflow: auto;
    background: var(--color-surface);
    min-height: 0;
}

.user-manual-manuals {
    padding: 14px 16px 18px 16px;
    font-size: 13px;
    color: var(--color-text-secondary);
}

.user-manual-manuals h4 {
    margin: 12px 0 8px 0;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--color-text-secondary);
}

.user-manual-manuals .um-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    margin: 4px 0;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-surface);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.user-manual-manuals .um-item:hover {
    background: var(--color-brand-primary-15);
    color: var(--color-text-primary);
    border-color: var(--color-brand-primary-25);
}

.user-manual-manuals .um-item.active {
    background: var(--color-brand-primary);
    border-color: var(--color-brand-primary);
    color: var(--color-on-primary);
}

.user-manual-manuals .um-item .um-item-title {
    font-weight: 650;
}

/* Technical topic label removed from manuals list (title-only list) */

/* Collapsible headings inside manual content */
.user-manual-body .um-heading {
    position: relative;
    cursor: pointer;
    user-select: none;
    padding-right: 34px; /* room for icon on the right */
}

.user-manual-body .um-heading .um-collapse-icon {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 0.15s ease, transform 0.15s ease;
    color: var(--color-text-secondary);
    font-size: 24px;
}

.user-manual-body .um-heading:hover .um-collapse-icon {
    opacity: 1;
}

.user-manual-body .um-heading.is-collapsed .um-collapse-icon {
    transform: translateY(-50%) rotate(-90deg);
}

.user-manual-body .um-collapsible.is-collapsed > :not(.um-heading) {
    display: none;
}

.user-manual-body .um-collapsible.is-collapsed .um-collapse-icon {
    opacity: 1;
}

.user-manual-loading {
    padding: 18px 24px;
    color: var(--color-text-secondary);
    font-size: 13px;
}

.user-manual-body {
    /* Keep manual spacing; typography comes from shared .markdown-content */
    padding: 24px;
}

/* Manual content should size naturally so the right pane can scroll */
.user-manual-body.markdown-content {
    height: auto;
    flex: 0 0 auto;
}

.user-manual-body h1,
.user-manual-body h2,
.user-manual-body h3,
.user-manual-body h4 {
    scroll-margin-top: 12px;
}

@media (max-width: 900px) {
    .user-manual-sidebar { display: none; }
    .user-manual-body { padding: 18px; }
}

.modal-content::-webkit-scrollbar {
    width: 6px;
}

.modal-content::-webkit-scrollbar-track {
    background: var(--color-surface-variant);
}

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

.modal-content::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-secondary);
}

/* Version popup specific styles */
.version-popup {
    display: none;
}

.version-popup.show {
    display: block;
}

.version-popup-content {
    padding: 0;
}

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--color-text-secondary);
    font-size: 14px;
}



/* Notification segment unifies with standard segment hover */
.nav-segment--notification {
    cursor: pointer;
}

/* merged notification hover/active with shared interactive segment rules above */

.nav-segment--notification img {
    transition: all 0.2s ease;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    filter: brightness(0) saturate(100%);
}

.notification-badge {
    background: var(--color-status-error);
    color: white;
    border-radius: 10px;
    min-width: 18px;
    height: 18px;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    padding: 0 2px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.notification-badge:not(:empty) {
    display: flex;
}

/* Hide bell icon when there are notifications, show only badge */
.nav-segment--notification.has-notifications img {
    display: none;
}

/* Legacy powered-by styles - now handled by nav-segment--client */

/* Add styles for the token stats section */
.nav-segment--token-stats {
    position: relative;
    padding: 0 var(--space-md);
}

.nav-segment--token-stats .status-items {
    gap: var(--space-lg);
}

/* Token stats table unified once below */

/* Legacy duplicate styles removed - using unified segment approach */

/* Unified Right-Side Panel System */
.panel-backdrop {
    position: fixed;
    top: 64px; /* Start below navigation */
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 9999;
    opacity: 1;
}

.panel-backdrop.show {
    opacity: 1;
}

.panel-container {
    position: fixed;
    top: 64px; /* Below main navigation */
    bottom: 0;
    width: var(--modal-panel-width);
    background: var(--color-surface);
    box-shadow:
        -8px 0 32px rgba(0, 0, 0, 0.1),
        -4px 0 16px rgba(0, 0, 0, 0.05);
    transform: none;
    display: flex;
    flex-direction: column;
    z-index: 10000;
}

.panel-backdrop.show .panel-container {
    transform: none;
}

/* Docked panel containers for stacking */
.docked-panels {
    position: fixed;
    top: 64px; /* Below main navigation */
    bottom: 0;
    display: flex;
    align-items: stretch;
    gap: 0;
    z-index: 10000;
}

.docked-panels--right {
    right: 0;
    left: auto;
    flex-direction: row-reverse; /* New panels appear to the left */
}

.docked-panels--left {
    left: 0;
    right: auto;
    flex-direction: row; /* New panels appear to the right */
}

/* When inside dock wrappers, panel containers are relative flex items */
.docked-panels .panel-container {
    position: relative;
    top: 0;
    bottom: 0;
    height: 100%;
}

.docked-panels .panel-container--right,
.docked-panels .panel-container--left {
    right: auto;
    left: auto;
}

/* Docked panels (no backdrop) */
.panel-container--left {
    left: 0;
    right: auto;
    transform: none;
}

.panel-container--right {
    right: 0;
    left: auto;
    transform: none;
}

.panel-container--left.show,
.panel-container--right.show {
    transform: none;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 32px;
    border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
    flex-shrink: 0;
    position: relative;
}

.panel-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: #111827;
    letter-spacing: -0.025em;
    flex: 1;
}

.release-controls {
    display: flex;
    gap: 8px;
}

.release-btn {
    background: var(--color-surface-variant);
    border: 1px solid var(--color-border);
    color: var(--color-text-primary);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.release-btn:hover {
    background: var(--color-surface-hover);
    border-color: var(--color-border-hover);
    color: var(--color-text-primary);
}

.release-btn-copy {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
}

.release-btn-copy:hover {
    background: var(--color-surface-hover);
    border-color: var(--color-border-hover);
}

.panel-close {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    padding: 4px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.panel-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: #64748b;
    border-radius: 4px;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px; /* ensure sidebar has comfortable padding */
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

.panel-content::-webkit-scrollbar {
    width: 8px;
}

.panel-content::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.panel-content::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.panel-content::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Size variants for docked panels */
.panel-container--size-md {
    width: var(--modal-panel-width);
}

.panel-container--size-lg {
    width: min(100vw, calc(var(--modal-panel-width) * 2));
}

/* Responsive design for panels via variable override */
@media (max-width: 1024px) {
    :root { --panel-width: 60vw; }
}

@media (max-width: 768px) {
    :root { --panel-width: 100vw; }

    .panel-header {
        padding: 20px 24px;
    }

    .panel-header h3 {
        font-size: 1.125rem;
    }

    .panel-close {
        width: 28px;
        height: 28px;
        font-size: 16px;
    }
    .panel-container { width: 40%; }
    .nav-segment { padding: 0 var(--space-sm); }
    .unified-nav .action-btn { padding: 6px 16px; min-width: 88px; }
}

@media (max-width: 768px) {
    .panel-container { width: 60%; }
    .panel-header { padding: 20px 24px; }
    .panel-header h3 { font-size: 1.125rem; }
    .panel-close { width: 28px; height: 28px; font-size: 16px; }
    .nav-segment--client .client-name,
    .nav-segment--version .version-number { display: none; }
    .nav-project-settings { display: none; }
}

/* Modal content improvements - modern design */
.modal-info-content {
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.modal-info-content.status-modal-content {
    padding: 0;
}

/* Modern info sections with card-like design */
.info-section {
    margin: 0;
    padding: 24px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    transition: all 0.2s ease;
    position: relative;
}

.info-section:last-child {
    border-bottom: none;
}

.info-section:hover {
    background: var(--color-surface-hover);
    box-shadow: inset 0 1px 0 0 rgba(59, 130, 246, 0.1);
}

/* Status sections - clean minimal styling */
.status-section, .time-section, .model-section {
    padding: 20px 24px;
    background: var(--color-surface);
    transition: all 0.3s ease;
}

/* Modal list styling - consistent with release notes */
.info-section ul {
    margin: 12px 0 0 0;
    padding-left: 0;
    list-style: none;
}

.info-section li {
    position: relative;
    padding: 8px 12px;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    line-height: 1.5;
    transition: all 0.2s ease;
    border-left: 3px solid var(--color-border);
    margin-bottom: 2px;
    cursor: pointer;
}

.info-section li:hover {
    background-color: rgba(0, 0, 0, 0.02);
    border-left-color: var(--color-accent-on-light);
    color: var(--color-text-primary);
}

.info-section li:last-child {
    margin-bottom: 0;
}

.info-section h4 {
    margin: 0 0 12px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text-primary);
}

.info-section h5 {
    margin: 12px 0 8px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-primary);
}

/* Status modal specific styles - modern layout */
.status-item-modal {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    margin: 8px 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.6);
    padding: 16px;
    transition: all 0.2s ease;
}

.status-item-modal:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.status-item-modal .label {
    font-weight: 600;
    color: #64748b;
    font-size: 14px;
    letter-spacing: 0.025em;
    text-transform: uppercase;
}

.status-item-modal .value {
    font-weight: 700;
    color: #1e293b;
    font-size: 16px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* Minimal token table styling */
.token-stats-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.token-stats-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    font-size: 14px;
    border-bottom: 1px solid #e5e7eb;
}

.token-stats-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    color: #374151;
    font-size: 14px;
    font-weight: 400;
}

.token-stats-table th:first-child,
.token-stats-table td:first-child { font-weight: 600; }

.token-stats-table th:nth-child(2),
.token-stats-table td:nth-child(2),
.token-stats-table th:nth-child(3),
.token-stats-table td:nth-child(3),
.token-stats-table th:nth-child(4),
.token-stats-table td:nth-child(4) {
    text-align: right;
}

.token-stats-table .token-total td {
    border-top: 1px solid #d1d5db;
    font-weight: 600;
    padding-top: 16px;
}

.cost-explanation {
    margin-top: 16px;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.cost-explanation h5 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

.cost-explanation ul {
    margin: 8px 0;
    padding-left: 16px;
    list-style-type: disc;
}

.cost-explanation li {
    margin-bottom: 4px;
    font-size: 14px;
    color: #6b7280;
    line-height: 1.5;
}

.cost-explanation p {
    margin: 8px 0;
    font-size: 14px;
    color: #6b7280;
    line-height: 1.5;
}

/* Status value styling based on status */
.status-item-modal .value.status-ready {
    color: #059669;
    background: rgba(16, 185, 129, 0.1);
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
}

.status-item-modal .value.status-processing {
    color: #0ea5e9;
    background: rgba(14, 165, 233, 0.1);
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
}

.status-item-modal .value.status-complete {
    color: #059669;
    background: rgba(16, 185, 129, 0.1);
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
}

.status-item-modal .value.status-error {
    color: #dc2626;
    background: rgba(220, 38, 38, 0.1);
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
}

/* Notification history styling improvements */
.notification-history-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 12px;
    margin: 20px;
}

.notification-history-empty .empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.6;
}

.notification-history-empty h4 {
    margin: 0 0 8px 0;
    color: #374151;
    font-size: 18px;
    font-weight: 600;
}

.notification-history-empty p {
    margin: 0;
    color: var(--color-text-secondary);
    font-size: 14px;
    line-height: 1.5;
}

/* Notification history list improvements */
.notification-history-list {
    padding: 0;
}

.notification-item {
    padding: 16px 24px;
    border-bottom: 1px solid var(--color-border);
    transition: all 0.2s ease;
    background: var(--color-surface);
}

.notification-item:hover {
    background: var(--color-surface-hover);
    transform: translateX(4px);
}

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

/* Toggle (checkbox) styling for unified nav (minimal) */
.nav-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 8px;
  white-space: nowrap;
  font-size: 13px;
}

.nav-toggle input[type="checkbox"] {
  accent-color: var(--color-status-info);
  cursor: pointer;
}

/* Optional settings segment wrapper */
.nav-segment--settings {
  padding: 0 var(--space-md);
}
