/* Strategic Intelligence Dashboard CSS - Mobile-First v2.0 */
/* Created: 2025-11-16 */
/* Philosophy: Mobile-first, progressive enhancement, 44px touch targets */

/* ============================================
   CSS RESET
   ============================================ */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ============================================
   CSS VARIABLES - Now defined in design-tokens.css
   This file only contains component/layout styles.
   All variables are inherited from design-tokens.css.
   ============================================ */

/* ============================================
   BASE STYLES - Mobile-First (320px+)
   ============================================ */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--color-text);
    background: var(--color-surface);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: var(--space-2);
}

h1 {
    font-size: var(--text-xl);  /* 24px mobile */
}

h2 {
    font-size: var(--text-lg);  /* 18px mobile */
}

h3 {
    font-size: var(--text-base); /* 16px mobile */
}

p {
    margin-bottom: var(--space-2);
}

a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--color-accent-hover);
    text-decoration: underline;
}

/* ============================================
   BUTTONS - Touch-Friendly (44x44px minimum)
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);

    min-height: var(--touch-target);  /* 44px */
    padding: 0.75rem 1.5rem;  /* 12px 24px */

    font-size: var(--text-sm);
    font-weight: 500;
    font-family: inherit;

    border-radius: 6px;
    border: 1px solid transparent;
    background: transparent;

    cursor: pointer;
    transition: all 0.2s ease;

    /* Touch-friendly */
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.btn:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Primary Button - CTAs */
.btn--primary {
    background: var(--color-primary);
    color: white;
}

.btn--primary:hover {
    background: var(--color-primary-hover);
    opacity: 0.9;
}

.btn--primary:active {
    opacity: 1;
}

/* Secondary Button - Less emphasis */
.btn--secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-border);
}

.btn--secondary:hover {
    background: white;
    border-color: var(--color-accent);
}

/* Ghost Button - Minimal */
.btn--ghost {
    background: transparent;
    color: var(--color-accent);
}

.btn--ghost:hover {
    background: var(--color-surface);
}

/* Icon Button - Voting, Actions */
.btn--icon {
    width: var(--touch-target);   /* 44px */
    height: var(--touch-target);  /* 44px */
    padding: 0;
    border-radius: 50%;
}

/* Button Sizes - Actual size differences */
.btn--sm {
    min-height: 36px;
    padding: 0.375rem 0.75rem;  /* 6px 12px - Smaller */
    font-size: var(--text-xs);
}

.btn--lg {
    min-height: 52px;
    padding: 1rem 1.5rem;  /* 16px 24px - Larger */
    font-size: var(--text-base);
}

/* ============================================
   BADGES - Simplified System
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;

    padding: 0.125rem 0.5rem; /* 2px 8px - Reduced for efficiency */
    font-size: var(--text-xs);
    font-weight: 500;
    line-height: 1.4;

    border-radius: 10px;
    white-space: nowrap;
}

/* Priority Badges - More distinctive with borders */
.badge--p1 {
    background: var(--color-badge-p1-bg);
    color: var(--color-badge-p1-text);
    border: 2px solid var(--color-badge-p1-border);
    font-weight: 600;
}

.badge--p2 {
    background: var(--color-badge-p2-bg);
    color: var(--color-badge-p2-text);
    border: 2px solid var(--color-badge-p2-border);
    font-weight: 600;
}

.badge--p3 {
    background: var(--color-badge-p3-bg);
    color: var(--color-badge-p3-text);
    border: 2px solid var(--color-badge-p3-border);
    font-weight: 600;
}

/* Geographic Badges */
.badge--geo {
    background: var(--color-surface);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}

.badge--sweden {
    background: var(--color-badge-sweden-bg);
    color: var(--color-badge-sweden-text);
}

.badge--eu {
    background: var(--color-badge-eu-bg);
    color: var(--color-badge-eu-text);
}

.badge--global {
    background: var(--color-surface);
    color: var(--color-text-muted);
}

/* Theme/Entity Badges - Distinct from priority badges */
.badge--theme {
    background: var(--color-badge-theme-bg);
    color: var(--color-badge-theme-text);
    border: 1px solid var(--color-badge-theme-border);
}

.badge--entity {
    background: var(--color-badge-entity-bg);
    color: var(--color-badge-entity-text);
    border: 1px solid var(--color-badge-entity-border);
}

/* Score Badge */
.badge--score {
    background: var(--color-surface);
    color: var(--color-text);
    font-weight: 600;
}

/* Sentiment Badges (Phase 2.1) */
.badge--sentiment {
    padding: 4px 8px;
    font-size: 16px;
    line-height: 1;
}

.badge--sentiment-positive {
    background: var(--color-badge-sentiment-pos-bg);
    color: var(--color-badge-sentiment-pos-text);
}

.badge--sentiment-negative {
    background: var(--color-badge-sentiment-neg-bg);
    color: var(--color-badge-sentiment-neg-text);
}

.badge--sentiment-neutral {
    background: var(--color-badge-sentiment-neutral-bg);
    color: var(--color-badge-sentiment-neutral-text);
}

/* Editable badges with remove button */
.badge--editable {
    position: relative;
    padding-right: 28px; /* Space for remove button */
}

.badge__remove {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: currentColor;
    opacity: 0.6;
    cursor: pointer;
    font-size: 14px;
    padding: 0 4px;
    line-height: 1;
    transition: opacity 0.2s;
}

.badge__remove:hover {
    opacity: 1;
}

/* Scope editable badge - click to cycle */
.badge--scope-editable {
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.badge--scope-editable:hover {
    box-shadow: var(--shadow-sm);
}

.badge--scope-editable:active {
    opacity: 0.9;
}

.badge--add {
    background: var(--color-surface);
    color: var(--color-text-muted);
    border: 1px dashed var(--color-border);
    cursor: pointer;
    transition: all 0.2s;

    /* Match regular badge size (v2.2.14) */
    padding: 0.125rem 0.5rem; /* 2px 8px - same as regular badges */
    font-size: var(--text-xs); /* 12px - same as regular badges */
    line-height: 1.4; /* Match badge line-height */
}

.badge--add:hover {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

/* Modal overlay for add dialogs */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 24px;
    border-radius: 8px;
    min-width: 300px;
    max-width: 500px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.modal-content h3 {
    margin: 0 0 16px 0;
    font-size: 18px;
    color: var(--color-text);
}

/* ============================================
   ARTICLE CARDS - Mobile-First
   ============================================ */
.article-card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: var(--space-2);  /* Reduced: 12px from 24px */
    margin-bottom: var(--space-2);

    /* Stack vertically on mobile */
    display: flex;
    flex-direction: column;
    gap: var(--space-1);  /* Tighter gap: 8px from 16px */

    /* Prevent grid overflow issues */
    min-width: 0;
    overflow: hidden;

    transition: box-shadow 0.2s, border-left-color 0.2s;
}

/* Sentiment border indicator — L-shape: left + bottom (calm technology: ambient signal)
   Accessibility: solid vs dashed distinguishes sentiment without relying on color alone
   (WCAG 2.1 SC 1.4.1 — color is not the only visual means of conveying information) */
.article-card[data-sentiment="positive"] {
    border-left: 4px solid var(--color-success);
    border-bottom: 4px solid var(--color-success);
}

.article-card[data-sentiment="negative"] {
    border-left: 4px dashed var(--color-error);
    border-bottom: 4px dashed var(--color-error);
}

.article-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.article-card__header {
    display: flex;
    gap: var(--space-1);
    flex-wrap: nowrap;
    align-items: center;
    overflow: hidden;
}

.article-card__title {
    font-size: var(--text-base);  /* 16px - Reduced from 18px for mobile */
    font-weight: 600;
    line-height: 1.3;  /* Tighter */
    margin: 0;

    /* Prevent overflow */
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.article-card__title a {
    color: var(--color-text);
    text-decoration: none;
}

.article-card__title a:hover {
    color: var(--color-accent);
    text-decoration: underline;
}

.article-card__summary {
    font-size: var(--text-sm);
    color: var(--color-text);  /* Darker for better visibility */
    line-height: 1.5;
    margin: var(--space-1) 0;  /* Add margin for spacing */

    /* Clamp to 3 lines on mobile for more context */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

/* Sources badge with hover tooltip */
.sources-badge {
    cursor: help;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
    position: relative;
}

.sources-badge:hover {
    color: var(--color-primary-600);
}

.article-card__tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    align-items: flex-start; /* Prevent badges from stretching to match tallest badge */
}

.article-card__actions {
    display: flex;
    gap: var(--space-2);
    margin-top: auto; /* Push to bottom */
    flex-wrap: wrap;
}

/* Voting Buttons - Touch-Friendly */
.vote-buttons {
    display: flex;
    gap: var(--space-1);
}

.btn-upvote,
.btn-downvote {
    min-width: var(--touch-target);
    min-height: var(--touch-target);
    padding: 0.5rem 0.75rem;  /* Reduced padding */

    font-size: var(--text-sm);
    border-radius: 6px;
    border: 1px solid var(--color-border);
    background: white;

    display: inline-flex;
    align-items: center;
    gap: 0.375rem;  /* Tighter gap */

    cursor: pointer;
    transition: all 0.2s;
}

.btn-upvote:hover {
    border-color: var(--color-p3);
    background: var(--color-badge-p3-bg);
}

.btn-downvote:hover {
    border-color: var(--color-p1);
    background: var(--color-badge-p1-bg);
}

.btn-upvote.voted {
    background: var(--color-p3);
    color: white;
    border-color: var(--color-p3);
}

.btn-downvote.voted {
    background: var(--color-p1);
    color: white;
    border-color: var(--color-p1);
}

/* ============================================
   NAVIGATION - Mobile-First (Sticky Header)
   ============================================ */
.navbar {
    background: var(--color-text);  /* Dark background */
    color: white;
    padding: 0 var(--space-2);
    height: var(--header-height);

    /* Sticky on mobile */
    position: sticky;
    top: 0;
    z-index: 1000;

    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.navbar__container {
    max-width: var(--max-width);
    margin: 0 auto;
    height: 100%;

    display: flex;
    align-items: center;
    justify-content: space-between;
}

.navbar__brand {
    font-size: var(--text-lg);
    font-weight: 600;
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar__logo {
    height: 28px;
    width: auto;
}

/* Hamburger Menu - Touch-Friendly (44x44px) */
.navbar__toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;

    width: var(--touch-target);   /* 44px */
    height: var(--touch-target);  /* 44px */
    padding: 0;

    background: transparent;
    border: none;
    cursor: pointer;

    /* Hide on desktop */
    display: flex;
}

.navbar__toggle span {
    display: block;
    width: 24px;
    height: 3px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s;
}

/* Hamburger Animation */
.navbar__toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.navbar__toggle.active span:nth-child(2) {
    opacity: 0;
}

.navbar__toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* Mobile Menu - Hidden by default */
.navbar__menu {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;

    /* Use slate-800 token (works in both light/dark mode since links are white) */
    background: var(--color-slate-800);
    padding: var(--space-2);

    /* Hidden by default */
    transform: translateX(-100%);
    transition: transform 0.3s ease;

    overflow-y: auto;
}

.navbar__menu.active {
    transform: translateX(0);
}

.navbar__links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.navbar__link {
    display: block;
    padding: var(--space-2);
    color: white;
    font-size: var(--text-base);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);

    /* Touch-friendly */
    min-height: var(--touch-target);
    display: flex;
    align-items: center;
}

.navbar__link:hover {
    background: rgba(255, 255, 255, 0.1);
    text-decoration: none;
}

.navbar__link.active {
    background: rgba(59, 130, 246, 0.2);
    border-left: 4px solid var(--color-accent);
}

/* Dropdown menu - Mobile */
.navbar__dropdown {
    position: relative;
}

.navbar__dropdown-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    cursor: pointer;
}

.dropdown-arrow {
    margin-left: var(--space-1);
    transition: transform 0.3s;
    display: inline-block;
}

.navbar__dropdown-toggle[aria-expanded="true"] .dropdown-arrow {
    transform: rotate(180deg);
}

.navbar__dropdown-menu {
    list-style: none;
    padding-left: var(--space-4);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.navbar__dropdown-menu.show {
    max-height: 500px; /* Must fit all dropdown items (7+ items × 44px touch-target) */
}

.navbar__dropdown-item {
    display: block;
    padding: var(--space-2);
    color: rgba(255, 255, 255, 0.8);
    font-size: var(--text-sm);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    min-height: var(--touch-target);
    display: flex;
    align-items: center;
}

.navbar__dropdown-item:hover {
    background: rgba(255, 255, 255, 0.05);
    text-decoration: none;
    color: white;
}

.navbar__dropdown-item.active {
    background: rgba(59, 130, 246, 0.15);
    color: white;
}

.navbar__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-left: 8px;
    font-size: 0.7rem;
    font-weight: 600;
    color: white;
    background: var(--color-error);
    border-radius: 9999px;
    line-height: 1;
}

/* ============================================
   LAYOUT - Container
   ============================================ */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: var(--space-4);  /* 16px on mobile */
}

/* ============================================
   DASHBOARD ACTIONS - Toggle & Analyze Buttons
   ============================================ */
.dashboard-actions {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-2) 0;
    margin-bottom: var(--space-3);
}

.dashboard-actions .container {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

/* Ensure crawl dropdown button matches other buttons */
.crawl-dropdown {
    display: inline-flex;
    align-items: stretch;
}

.crawl-dropdown .btn-crawl {
    height: 100%;
}

.btn-toggle,
.btn-crawl,
.btn-analyze {
    /* Use base button styles */
    min-height: var(--touch-target);
    padding: 0.75rem 1.5rem;

    font-size: var(--text-sm);
    font-weight: 600;
    line-height: 1.5;

    border-radius: 6px;
    border: 2px solid var(--color-border);
    background: white;
    color: var(--color-text);

    display: inline-flex;
    align-items: center;
    gap: var(--space-1);

    cursor: pointer;
    transition: all 0.2s ease;

    /* No text decoration */
    text-decoration: none;

    /* Prevent user select */
    user-select: none;
}

.btn-toggle:hover,
.btn-crawl:hover,
.btn-analyze:hover {
    border-color: var(--color-accent);
    background: var(--color-accent);
    color: white;
    opacity: 0.9;
}

.btn-toggle:active,
.btn-crawl:active,
.btn-analyze:active {
    opacity: 1;
}

.btn-toggle:disabled,
.btn-crawl:disabled,
.btn-analyze:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Crawl dropdown menu */
.crawl-dropdown {
    position: relative;
    display: inline-block;
}

.crawl-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    min-width: 220px;
    margin-top: 4px;
    padding: var(--space-2);
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.crawl-dropdown.open .crawl-menu {
    display: block;
}

.crawl-option {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: background 0.15s ease;
}

.crawl-option:hover {
    background: var(--color-bg-alt);
}

.crawl-option input[type="radio"] {
    margin: 0;
    accent-color: var(--color-accent);
}

.crawl-option span {
    font-size: var(--text-sm);
    color: var(--color-text);
}

.crawl-option strong {
    color: var(--color-text);
}

.crawl-start-btn {
    width: 100%;
    margin-top: var(--space-2);
    padding: var(--space-2);
    background: var(--color-accent);
    color: white;
    border: none;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

.crawl-start-btn:hover {
    background: var(--color-accent-dark, #2563eb);
}

/* Report dropdown menu */
.report-dropdown {
    position: relative;
    display: inline-block;
}

.report-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    min-width: 240px;
    margin-top: 4px;
    padding: var(--space-2);
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.report-dropdown.open .report-menu {
    display: block;
}

.report-option {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2);
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: background 0.15s ease;
}

.report-option:hover {
    background: var(--color-bg-alt);
}

.report-option input[type="radio"] {
    margin: 0;
    accent-color: var(--color-accent);
}

.report-option span {
    font-size: var(--text-sm);
    color: var(--color-text);
}

.report-option strong {
    color: var(--color-text);
}

.report-start-btn {
    width: 100%;
    margin-top: var(--space-2);
    padding: var(--space-2);
    background: var(--color-accent);
    color: white;
    border: none;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease;
}

.report-start-btn:hover {
    background: var(--color-accent-dark, #2563eb);
}

/* Report section headers */
.report-section {
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

/* Report links (for pre-generated reports) */
.report-link {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-2);
    text-decoration: none;
    border-radius: var(--border-radius-sm);
    transition: background 0.15s ease;
}

.report-link:hover {
    background: var(--color-bg-alt);
}

.report-link span {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-text);
}

.report-link small {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

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

.report-link.disabled:hover {
    background: transparent;
}

/* Generate button for new content */
.report-generate-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    padding: var(--space-2);
    background: var(--color-blue-50);
    border: 1px dashed var(--color-blue-500);
    border-radius: var(--border-radius-sm);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-blue-700);
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
}

.report-generate-btn:hover {
    background: var(--color-blue-100);
    border-style: solid;
}

.report-generate-btn small {
    font-size: var(--text-xs);
    font-weight: normal;
    color: var(--color-text-muted);
}

/* Dashboard AI Summary Section */
.summary-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-lg);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
    position: relative;
}

.summary-section.collapsed .summary-content {
    max-height: 120px;
    overflow: hidden;
    mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
}

.summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
}

.summary-header .section-header {
    margin: 0;
}

.summary-meta {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

.summary-content {
    font-size: var(--text-base);
    line-height: 1.7;
    color: var(--color-text);
}

.summary-content h2 {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--color-text);
    margin: var(--space-4) 0 var(--space-2) 0;
    padding-bottom: var(--space-1);
    border-bottom: 2px solid var(--color-accent);
}

.summary-content h2:first-child {
    margin-top: 0;
}

.summary-content h3 {
    font-size: var(--text-md);
    font-weight: 600;
    color: var(--color-text);
    margin: var(--space-3) 0 var(--space-2) 0;
}

.summary-content h4 {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--color-text-muted);
    margin: var(--space-2) 0 var(--space-1) 0;
}

.summary-content p {
    margin: 0 0 var(--space-3) 0;
}

.summary-content strong {
    font-weight: 600;
    color: var(--color-text);
}

.summary-loading {
    color: var(--color-text-muted);
    font-style: italic;
}

.summary-empty {
    color: var(--color-text-muted);
    font-style: italic;
    padding: var(--space-4);
    text-align: center;
    background: var(--color-bg);
    border-radius: var(--border-radius-md);
}

.summary-toggle {
    display: block;
    width: 100%;
    padding: var(--space-2);
    margin-top: var(--space-2);
    background: transparent;
    border: 1px dashed var(--color-border);
    border-radius: var(--border-radius-sm);
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    cursor: pointer;
    transition: all 0.15s ease;
}

.summary-toggle:hover {
    background: var(--color-bg);
    color: var(--color-text);
    border-style: solid;
}

.toggle-icon {
    display: inline-block;
    transition: transform 0.15s ease;
}

/* Progress bar for crawl/analyze */
.progress-container {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 200px;
}

.progress-bar {
    flex: 1;
    height: 20px;
    background: var(--color-bg-alt);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--color-border);
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: var(--color-accent);
    border-radius: 10px;
    transition: width 0.3s ease;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255,255,255,0.3) 50%,
        transparent 100%
    );
    animation: shimmer 2.5s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-text {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text-light);
    min-width: 45px;
}

/* ============================================
   STATS HEADER - Mobile-First
   ============================================ */
.stats-header {
    display: grid;
    grid-template-columns: 1fr 1fr;  /* 2 columns on mobile */
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.stat-card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: var(--space-2) var(--space-1);  /* Reduced: 12px 8px */
    text-align: center;
}

.stat-card__value {
    font-size: var(--text-xl);  /* 24px - Reduced from 32px */
    font-weight: 700;
    color: var(--color-accent);
    line-height: 1.1;
    margin-bottom: 0.25rem;  /* Tighter spacing */
}

.stat-card__label {
    font-size: var(--text-xs);  /* 12px - Reduced from 14px */
    color: var(--color-text-muted);
    margin-top: 0;
}

/* ============================================
   SECTION HEADERS
   ============================================ */
.section-header {
    font-size: var(--text-xl);  /* 24px */
    font-weight: 600;
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-2);
    border-bottom: 2px solid var(--color-border);

    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* ============================================
   FILTER PANEL - Collapsible on Mobile
   ============================================ */
.filter-panel {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    margin-bottom: var(--space-3);
    overflow: hidden;
}

.filter-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: var(--space-2);
    cursor: pointer;

    /* Touch target */
    min-height: var(--touch-target);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.filter-panel__header:hover {
    background: var(--color-bg-hover);
}

.filter-panel__title {
    font-size: var(--text-base);
    font-weight: 600;
    margin: 0;
}

.filter-panel__toggle {
    font-size: var(--text-lg);
    transition: transform 0.3s;
}

.filter-panel--expanded .filter-panel__toggle {
    transform: rotate(180deg);
}

.filter-panel__content {
    /* Hidden by default on mobile */
    max-height: 0;
    overflow: hidden;
    padding: 0 var(--space-2);  /* Horizontal padding only when collapsed */
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.filter-panel--expanded .filter-panel__content {
    max-height: 1000px; /* Large enough for content */
    padding: var(--space-2);  /* Full padding when expanded */
}

/* Filter groups - 2 columns on mobile for efficiency */
.filter-groups {
    display: grid;
    grid-template-columns: 1fr 1fr;  /* 2 columns side by side */
    gap: var(--space-2);
}

.filter-group {
    margin-bottom: 0;
}

.filter-group__label {
    font-size: var(--text-sm);
    font-weight: 600;
    margin-bottom: var(--space-1);
    display: block;
}

.filter-option {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) 0;

    /* Touch-friendly */
    min-height: var(--touch-target);
}

.filter-option input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.filter-option label {
    font-size: var(--text-sm);
    cursor: pointer;
    flex: 1;
}

/* ============================================
   TOPIC SECTION
   ============================================ */
.topics-section {
    margin-bottom: var(--space-4);
}

.topics-grid {
    display: grid;
    grid-template-columns: 1fr;  /* Single column on mobile */
    gap: var(--space-2);
}

/* ============================================
   TOAST NOTIFICATIONS - Mobile Optimized
   ============================================ */
.toast {
    position: fixed;
    top: var(--space-4);
    right: var(--space-2);
    left: var(--space-2);  /* Full-width on mobile */

    background: var(--color-bg);
    color: var(--color-text);
    padding: var(--space-3) var(--space-4);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 9999;

    max-height: 80px;
    min-height: 48px;

    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-content {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.toast-icon {
    font-size: var(--text-lg);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
}

.toast-message {
    font-size: var(--text-sm);
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toast-success {
    border-left: 4px solid var(--color-p3);
}

.toast-success .toast-icon {
    background: var(--color-p3);
    color: white;
}

.toast-error {
    border-left: 4px solid var(--color-p1);
}

.toast-error .toast-icon {
    background: var(--color-p1);
    color: white;
}

.toast-warning {
    border-left: 4px solid var(--color-p2);
}

.toast-warning .toast-icon {
    background: var(--color-p2);
    color: white;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--color-text-muted);
}

.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }

.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }

.hidden {
    display: none !important;
}

/* ============================================
   TABLET - 600px+ (Progressive Enhancement)
   ============================================ */
@media (min-width: 600px) {
    /* Typography scales up */
    :root {
        --text-lg: 1.25rem;   /* 20px */
        --text-xl: 1.75rem;   /* 28px */
    }

    /* Container padding increases */
    .container {
        padding: var(--space-6);  /* 24px */
    }

    /* Stats header - 3 or 4 columns */
    .stats-header {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }

    /* Topics grid - 2 columns */
    .topics-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Toast notifications - Compact size */
    .toast {
        left: auto;
        width: 280px;
        max-height: 60px;
        padding: var(--space-2) var(--space-3);
    }

    /* Article card summary - More lines */
    .article-card__summary {
        -webkit-line-clamp: 3;  /* 3 lines on tablet */
    }

    /* Article card title - Larger on tablet */
    .article-card__title {
        font-size: var(--text-lg);  /* 20px on tablet+ */
    }
}

/* ============================================
   DESKTOP - 900px+ (Sidebar Layout)
   ============================================ */
@media (min-width: 900px) {
    /* Hide hamburger menu */
    .navbar__toggle {
        display: none;
    }

    /* Horizontal navigation */
    .navbar__menu {
        position: static;
        transform: none;
        background: transparent;
        padding: 0;
        overflow: visible;
    }

    .navbar__links {
        flex-direction: row;
        gap: var(--space-2);
    }

    .navbar__link {
        padding: var(--space-1) var(--space-2);
        border-bottom: none;
        border-radius: 6px;
    }

    .navbar__link.active {
        background: rgba(59, 130, 246, 0.2);
        border-left: none;
    }

    /* Dropdown menu - Desktop */
    .navbar__dropdown {
        position: relative;
    }

    .navbar__dropdown-menu {
        position: absolute;
        top: 100%;
        left: 0;
        min-width: 200px;

        background: var(--color-text);
        border-radius: 8px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);

        padding: var(--space-1) 0;
        margin-top: var(--space-1);

        max-height: 0;
        opacity: 0;
        pointer-events: none;
        transform: translateY(-10px);
        transition: all 0.3s ease;
    }

    .navbar__dropdown-menu.show {
        max-height: 400px;
        opacity: 1;
        pointer-events: auto;
        transform: translateY(0);
    }

    .navbar__dropdown-item {
        padding: var(--space-2) var(--space-3);
        color: rgba(255, 255, 255, 0.9);
        font-size: var(--text-sm);
        border-bottom: none;
        white-space: nowrap;
    }

    .navbar__dropdown-item:hover {
        background: rgba(255, 255, 255, 0.1);
    }

    .navbar__dropdown-item.active {
        background: rgba(59, 130, 246, 0.2);
        font-weight: 600;
    }

    .navbar__dropdown-toggle {
        padding: var(--space-1) var(--space-2);
        border-radius: 6px;
    }

    .navbar__dropdown-toggle:hover {
        background: rgba(255, 255, 255, 0.1);
    }

    .dropdown-arrow {
        font-size: 0.75rem;
    }

    /* Topics grid - Max 3 columns */
    .topics-grid {
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
        max-width: 100%;
    }

    /* Filter panel - Collapsed by default on desktop too (v2.2.16) */
    .filter-panel__content {
        max-height: 0;
        overflow: hidden;
        padding: 0 var(--space-2);
        transition: max-height 0.3s ease, padding 0.3s ease;
    }

    .filter-panel--expanded .filter-panel__content {
        max-height: 1000px;
        padding: var(--space-2);
    }

    .filter-panel__header {
        cursor: pointer;  /* Allow clicking on desktop (v2.2.16) */
    }

    .filter-panel__toggle {
        display: inline; /* Show toggle arrow on desktop (v2.2.16) */
    }

    /* Article cards - Better desktop layout */
    .article-card {
        /* Keep vertical layout, just bigger padding */
        padding: var(--space-3);
    }

    .article-card__title {
        font-size: var(--text-lg);  /* 18px on desktop */
        hyphens: none;  /* No hyphenation on desktop */
    }

    .article-card__summary {
        -webkit-line-clamp: 4;  /* 4 lines on desktop */
        font-size: var(--text-base);  /* Larger text on desktop */
    }
}

/* ============================================
   WIDE DESKTOP - 1200px+
   ============================================ */
@media (min-width: 1200px) {
    /* Topics grid - Still max 3 columns for readability */
    .topics-grid {
        grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    }

    /* Container max-width applies */
    .container {
        padding: var(--space-8);  /* 32px */
    }

    /* Article cards - Even more padding */
    .article-card {
        padding: var(--space-4);
    }
}

/* ============================================
   ABOUT PAGE - ACH & REFERENCES
   ============================================ */
.ach-benefits,
.ach-example,
.references {
    margin-top: var(--space-4);
    padding: var(--space-3);
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    border-left: 4px solid var(--color-accent);
}

.ach-benefits h3,
.ach-example h3,
.references h3 {
    margin-bottom: var(--space-2);
    color: var(--color-text);
    font-size: var(--text-lg);
}

.ach-benefits ul,
.ach-example ul {
    list-style: none;
    padding-left: 0;
}

.ach-benefits li,
.ach-example li {
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--color-border);
}

.ach-benefits li:last-child,
.ach-example li:last-child {
    border-bottom: none;
}

.ach-example p {
    margin-bottom: var(--space-2);
}

.ach-example .note {
    margin-top: var(--space-3);
    padding: var(--space-2);
    background: rgba(59, 130, 246, 0.1);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
}

.references ul {
    list-style: none;
    padding-left: 0;
}

.references li {
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--color-border);
}

.references li:last-child {
    border-bottom: none;
}

.references a {
    color: var(--color-accent);
    text-decoration: none;
    font-weight: 500;
}

.references a:hover {
    color: var(--color-accent-hover);
    text-decoration: underline;
}

.references p {
    margin-top: var(--space-2);
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    line-height: 1.6;
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .navbar,
    .filter-panel,
    .toast,
    .btn {
        display: none;
    }

    .article-card {
        page-break-inside: avoid;
        border: 1px solid var(--color-gray-300);
        margin-bottom: 1rem;
    }
}

/* ============================================
   F2: SEARCH FUNCTIONALITY
   ============================================ */

/* Search Box in Dashboard Actions */
.search-box {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: var(--color-surface, #f8fafc);
    border: 1px solid var(--color-border, #e2e8f0);
    border-radius: var(--radius-md, 8px);
    padding: 0.25rem 0.5rem;
    max-width: 300px;
}

.search-box input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0.5rem;
    font-size: var(--text-sm, 0.875rem);
    min-width: 150px;
}

.search-box input:focus {
    outline: none;
}

.search-box input::placeholder {
    color: var(--color-text-muted, #64748b);
}

.search-btn,
.search-clear-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    font-size: 1rem;
    border-radius: var(--radius-sm, 4px);
    transition: background 0.2s;
}

.search-btn:hover,
.search-clear-btn:hover {
    background: var(--color-border, #e2e8f0);
}

/* Search Results Panel */
.search-results-panel {
    background: var(--color-surface, #f8fafc);
    border-bottom: 2px solid var(--color-accent, #3b82f6);
    padding: var(--space-3, 1rem) 0;
    margin-bottom: var(--space-3, 1rem);
}

.search-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2, 0.75rem);
}

.search-results-header h3 {
    font-size: var(--text-lg, 1.125rem);
    font-weight: 600;
    color: var(--color-text, #1e293b);
}

.search-results-header .btn-close {
    background: none;
    border: 1px solid var(--color-border, #e2e8f0);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm, 4px);
    cursor: pointer;
    font-size: var(--text-sm, 0.875rem);
}

.search-results-header .btn-close:hover {
    background: var(--color-border, #e2e8f0);
}

.search-results-content {
    max-height: 60vh;
    overflow-y: auto;
}

/* Search Result Items */
.search-result-item {
    background: var(--color-bg, #ffffff);
    border: 1px solid var(--color-border, #e2e8f0);
    border-radius: var(--radius-md, 8px);
    padding: var(--space-2, 0.75rem);
    margin-bottom: var(--space-2, 0.75rem);
    transition: border-color 0.2s;
}

.search-result-item:hover {
    border-color: var(--color-accent, #3b82f6);
}

.search-result-item.priority-P1 {
    border-left: 4px solid var(--color-p1, #dc2626);
}

.search-result-item.priority-P2 {
    border-left: 4px solid var(--color-p2, #f59e0b);
}

.search-result-item.priority-P3 {
    border-left: 4px solid var(--color-p3, #10b981);
}

.search-result-header {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.search-result-source {
    font-size: var(--text-xs, 0.75rem);
    color: var(--color-text-muted, #64748b);
}

.search-result-date {
    font-size: var(--text-xs, 0.75rem);
    color: var(--color-text-muted, #64748b);
    margin-left: auto;
}

.search-result-title {
    display: block;
    font-size: var(--text-base, 1rem);
    font-weight: 500;
    color: var(--color-accent, #3b82f6);
    text-decoration: none;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.search-result-title:hover {
    text-decoration: underline;
}

.search-result-snippet {
    font-size: var(--text-sm, 0.875rem);
    color: var(--color-text-muted, #64748b);
    line-height: 1.5;
    margin-bottom: 0.5rem;
}

.search-result-meta {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.search-result-meta .score {
    font-size: var(--text-xs, 0.75rem);
    color: var(--color-text-muted, #64748b);
}

.search-result-meta .themes {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.search-result-meta .theme-tag {
    font-size: var(--text-xs, 0.75rem);
    background: var(--color-surface, #f8fafc);
    border: 1px solid var(--color-border, #e2e8f0);
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
}

/* Search States */
.search-loading {
    text-align: center;
    padding: var(--space-4, 1.5rem);
    color: var(--color-text-muted, #64748b);
}

.search-empty {
    text-align: center;
    padding: var(--space-4, 1.5rem);
}

.search-empty p:first-child {
    font-size: var(--text-base, 1rem);
    margin-bottom: 0.5rem;
}

.search-tips {
    font-size: var(--text-sm, 0.875rem);
    color: var(--color-text-muted, #64748b);
}

.search-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    padding: var(--space-3, 1rem);
    border-radius: var(--radius-md, 8px);
    text-align: center;
}

/* Mobile adjustments for search */
@media (max-width: 768px) {
    .search-box {
        max-width: 100%;
        order: -1;
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .dashboard-actions .container {
        flex-wrap: wrap;
    }
}

/* ============================================
   DARK MODE (Future Enhancement)
   ============================================ */
/* @media (prefers-color-scheme: dark) { ... } */
