:root {
    --bg-dark: #0D1117;
    --bg-light: #161B22;
    --border-color: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #7d8590;
    --accent-purple: #8B5CF6;
    --accent-green: #A3E635;

    --pico-border-radius: 2rem;
    --pico-typography-spacing-vertical: 1.5rem;
    --pico-form-element-spacing-vertical: 1rem;
    --pico-form-element-spacing-horizontal: 1.25rem;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 16px;
    letter-spacing: -0.01em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Typography hierarchy for legal professionals */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Raleway', 'Inter', system-ui, sans-serif;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.3;
}

h1 {
    color: var(--text-primary);
    margin-top: 0;
    font-size: 2rem;
}

h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-top: 2rem;
    margin-bottom: 1rem;
}

h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
}

/* Improved paragraph and text readability */
p, li, td {
    line-height: 1.7;
    color: var(--text-primary);
}

/* Subtle text for secondary information */
.text-secondary, small, .meta {
    color: var(--text-secondary);
    font-size: 0.875rem;
}
label, button, select {
    margin-top: 1em;
}
form {
    margin-bottom: 1em;
}
.container {
    display: flex;
    gap: 1.5rem;
}
.facts-sidebar {
    width: 260px;
}
.facts-sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.fact-item {
    cursor: pointer;
}
.issue-item {
    cursor: pointer;
}

/* keep text visible when selecting facts or issues */
.fact-item::selection,
.issue-item::selection {
    color: inherit;
}
.pdf-viewer {
    flex: 1;
}
.highlight-box{
    position:absolute;
    background:transparent;
    pointer-events:auto;
    cursor:pointer;
    z-index:5;
    /* ensure the box actually occupies space so squiggly is visible */
    min-width:2px; min-height:6px;
    /* Smooth transition for selection state changes */
    transition: box-shadow 0.25s ease-out, border-radius 0.25s ease-out;
}
.highlight-box:hover .squiggly{
    opacity:.7;
}

/* highlight style when a related issue is selected */
.highlight-box.issue-selected {
    box-shadow: inset 0 0 0 2px var(--accent-purple);
    border-radius: 2px;
}

/* ── improved squiggly underline (neutral, accessible, branded) ────────── */
.squiggly {
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 4px;
    background:
      repeating-linear-gradient(
        -45deg,
        var(--accent-purple) 0 2px,
        transparent 2px 4px
      ),
      repeating-linear-gradient(
        45deg,
        var(--accent-green) 0 2px,
        transparent 2px 4px
      );
    opacity: 0.85;
    pointer-events: none;
    z-index: 6;
    border-radius: 1.5px;
    filter: drop-shadow(0 0 2px #fff7) drop-shadow(0 1px 1.5px #6ee7b7cc);
    mix-blend-mode: multiply;
    transition: opacity 0.18s;
}

/* Loading spinner with professional polish */
.spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 2px solid rgba(139, 92, 246, 0.2);
    border-top-color: var(--accent-purple);
    border-radius: 50%;
    animation: spin 0.8s linear infinite, pulse 2s ease-in-out infinite;
    vertical-align: middle;
}

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

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.3);
    }
    50% {
        box-shadow: 0 0 8px 2px rgba(139, 92, 246, 0.15);
    }
}

/* --- Header styling --- */
.site-header {
    background: var(--bg-light);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    padding: 0.5rem 0;
}
.header-container {
    align-items: center;
    justify-content: space-between;
}
.branding {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}
.branding h1 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-primary);
    font-family: 'Raleway';
    font-weight: 400;
    --pico-typography-spacing-vertical: 0.5rem;
}
.logo {
    height: 36px;
}
.brand-link {
    text-decoration: none;
    color: inherit;
}
.brand-link:hover {
    text-decoration: none;
}
.site-header nav a {
    color: var(--text-secondary);
    text-decoration: none;
    margin-left: 0.5rem;
    padding: 0.5rem 0.875rem;
    border-radius: 6px;
    font-weight: 500;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.site-header nav a:hover {
    background-color: var(--bg-dark);
    color: var(--text-primary);
}
.site-header nav a:focus-visible {
    outline: 2px solid var(--accent-purple);
    outline-offset: 2px;
}

/* Contracts dashboard table */
.contracts-table{
  width:100%;
  border-collapse:collapse;
  font-size:0.95rem;
}
.contracts-table th{
  text-align:left;
  font-weight:600;
  padding:0.75rem 1rem;
}
.contracts-table td{
  padding:0.75rem 1rem;
}
.contracts-table tbody tr:hover{
  background: var(--bg-light);
}

/* Status badges for document list scannability */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
}

.status-badge.verified {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}

.status-badge.issues {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
}

.status-badge.processing {
  background: rgba(125, 133, 144, 0.15);
  color: var(--text-secondary);
}

.status-badge.failed {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

/* Clickable status badges (links) */
a.status-badge {
  text-decoration: none;
  transition: background 0.15s, transform 0.1s ease-out;
}

a.status-badge:hover {
  transform: translateY(-1px);
}

a.status-badge.verified:hover {
  background: rgba(34, 197, 94, 0.25);
}

a.status-badge.issues:hover {
  background: rgba(251, 191, 36, 0.25);
}

/* Actions column */
.actions{
  display:flex;
  gap:.5rem;
  align-items:center;
}

/* Button utilities */
.button{
  font-family:inherit;
  font-weight:500;
  border-radius:6px;
  line-height:1.2;
  cursor:pointer;
  transition:background .15s,color .15s,border-color .15s,transform .1s ease-out,box-shadow .15s;
  text-decoration:none;
  display:inline-block;
}
.button:hover{
  transform:translateY(-1px);
}
.button:active{
  transform:translateY(0);
}
.button.small{
  font-size:0.85rem;
  padding:0.35rem 0.9rem;
}
.button.primary{
  background: var(--accent-purple);
  color:#fff;
  border:1px solid var(--accent-purple);
}
.button.primary:hover{
  background:color-mix(in srgb, var(--accent-purple) 85%, white);
  border-color:color-mix(in srgb, var(--accent-purple) 85%, white);
  box-shadow:0 2px 8px rgba(139,92,246,0.25);
}
.button.outline{
  background:transparent;
  color:#dc2626;
  border:1px solid #dc2626;
}
.button.outline:hover{
  background:rgba(220,38,38,0.08);
}

/* ── Focus states for accessibility and keyboard navigation ────────── */
.button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent-purple);
    outline-offset: 2px;
}

.fact-item:focus-visible,
.issue-item:focus-visible {
    outline: 2px solid var(--accent-purple);
    outline-offset: 2px;
    background: var(--bg-light);
}

/* Selected state for sidebar items */
.fact-item.selected,
.issue-item.selected,
.fact-item[aria-selected="true"],
.issue-item[aria-selected="true"] {
    background: var(--bg-light);
    border-left: 3px solid var(--accent-purple);
    padding-left: 0.75rem;
}

/* Ensure interactive elements are focusable */
.fact-item,
.issue-item {
    transition: background 0.15s, border-color 0.15s;
}

/* ── Card containers for visual hierarchy and professional polish ────────── */
.card {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.card-header h2,
.card-header h3 {
    margin: 0;
    font-size: 1.125rem;
}

/* Upload container for new document action */
.upload-container {
    display: flex;
    justify-content: flex-end;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.upload-container form {
    margin: 0;
}

/* Count badge for panel headers - shows item totals */
.count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.25rem;
    padding: 0 0.375rem;
    margin-left: 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: 'Inter', system-ui, sans-serif;
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent-purple);
    vertical-align: middle;
}

/* Compact card variant for sidebars */
.card.compact {
    padding: 1rem;
}

/* Card with subtle shadow for elevation */
.card.elevated {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

/* ── Form input polish for professional trust ────────── */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="url"],
input[type="tel"],
input[type="number"],
textarea,
select {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]:hover,
input[type="email"]:hover,
input[type="password"]:hover,
input[type="search"]:hover,
input[type="url"]:hover,
input[type="tel"]:hover,
input[type="number"]:hover,
textarea:hover,
select:hover {
    border-color: var(--text-secondary);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="url"]:focus,
input[type="tel"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
    outline: none;
}

/* Error messages use design system colors */
.form-error,
.error-message {
    color: #f87171;
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* ── Analysis panel list items ────────── */
#facts-panel .fact-item,
#issues-panel .issue-item {
    padding: 0.625rem 0.75rem;
    margin: 0.25rem 0;
    border-radius: 6px;
    line-height: 1.5;
}

#facts-panel .fact-item:hover,
#issues-panel .issue-item:hover {
    background: rgba(139, 92, 246, 0.1);
}

/* Fact related to selected issue - evidence trail highlight */
#facts-panel .fact-item.fact-related {
    background: rgba(139, 92, 246, 0.15);
    border-left: 3px solid var(--accent-purple);
    padding-left: calc(0.75rem - 3px);
    animation: highlightFadeIn 0.25s ease-out;
}

/* Subtle animation for selection state changes */
@keyframes highlightFadeIn {
    from {
        background: transparent;
        border-left-color: transparent;
    }
    to {
        background: rgba(139, 92, 246, 0.15);
        border-left-color: var(--accent-purple);
    }
}

/* Selected issue - active investigation indicator */
#issues-panel .issue-item.issue-selected {
    background: rgba(139, 92, 246, 0.15);
    border-left-color: var(--accent-purple);
    animation: highlightFadeIn 0.25s ease-out;
}

/* Issues panel emphasis - the critical review area */
#issues-panel .issue-item {
    border-left: 3px solid transparent;
}

#issues-panel .issue-item:hover {
    border-left-color: var(--accent-purple);
}

/* ── Issue severity badges for quick lawyer triage ────────── */
.severity-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-right: 0.625rem;
    flex-shrink: 0;
    vertical-align: middle;
}

/* Critical - deal breakers, immediate attention required */
.severity-badge.severity-critical,
.severity-badge.severity-high {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Moderate - should address before signing */
.severity-badge.severity-moderate,
.severity-badge.severity-medium {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.3);
}

/* Low - minor issues, nice to fix */
.severity-badge.severity-low,
.severity-badge.severity-minor {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

/* Issue item layout improvements */
#issues-panel .issue-item {
    display: flex;
    align-items: flex-start;
    gap: 0;
}

.issue-text {
    flex: 1;
    line-height: 1.5;
}

.issue-category {
    color: var(--text-secondary);
    white-space: nowrap;
}

/* ── Empty state styling for panels - reassures lawyers during processing ────── */
.empty-state {
    color: var(--text-secondary);
    padding: 1.25rem 1rem;
    text-align: center;
    border: 1px dashed var(--border-color);
    border-radius: 6px;
    margin: 0.5rem 0;
    background: rgba(125, 133, 144, 0.04);
}

.empty-state em {
    font-style: normal;
    font-size: 0.875rem;
    letter-spacing: 0.01em;
}

/* ── Custom scrollbar styling for dark mode polish ────────── */
/* Webkit browsers (Chrome, Safari, Edge) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
    border: 2px solid transparent;
    background-clip: padding-box;
}

/* Scrollbar corner (where horizontal and vertical meet) */
::-webkit-scrollbar-corner {
    background: transparent;
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

/* ── Site footer for app completeness ────────── */
.site-footer {
    margin-top: auto;
    padding: 1.5rem 0;
    border-top: 1px solid var(--border-color);
    background: var(--bg-light);
}

.footer-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.footer-copyright {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.footer-divider {
    color: var(--border-color);
    font-size: 0.875rem;
}

.footer-tagline {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.footer-tagline a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s ease;
}

.footer-tagline a:hover {
    color: var(--accent-purple);
}

.footer-nav {
    display: flex;
    gap: 1.5rem;
}

.footer-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.15s ease;
}

.footer-nav a:hover {
    color: var(--text-primary);
}

.footer-nav a:focus-visible {
    outline: 2px solid var(--accent-purple);
    outline-offset: 2px;
}

/* Ensure footer stays at bottom with flex layout */
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main.container {
    flex: 1;
}
