/* Dashboard redesign — layout shell, hero, summary, toolbar */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ── Base overrides ── */
body {
    font-family: var(--font-sans);
    color: var(--text-primary);
    background: var(--bg-page);
}

/* ── Top navigation ── */
.top-nav {
    position: sticky;
    top: 0;
    z-index: 200;
    height: 56px;
    background: rgba(255,255,255,0.95);
    border-bottom: 1px solid rgba(148,163,184,0.16);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04);
}

.top-nav-inner {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 20px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.brand-logo {
    width: 100px;
    margin-top: 25px;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.brand-tagline {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.nav-btn:hover,
.nav-btn:focus-visible {
    background: var(--bg-muted);
    border-color: var(--brand-300);
    transform: translateY(-1px);
}

.nav-btn-icon {
    padding: 8px 10px;
}

.nav-btn-icon span {
    display: inline-block;
}

/* ── Dashboard main ── */
.dashboard {
    max-width: 1440px;
    margin: 0 auto;
    padding: 32px 24px 48px;
    flex: 1;
    width: 100%;
}

/* ── Hero search ── */
.search-hero {
    text-align: center;
    padding: 48px 24px 32px;
    max-width: 720px;
    margin: 0 auto 24px;
}

.search-hero.compact {
    padding: 24px 0 16px;
    text-align: left;
    max-width: none;
}

.search-hero.compact .hero-title,
.search-hero.compact .hero-subtitle,
.search-hero.compact .trust-badges {
    display: none;
}

.hero-title {
    font-size: clamp(1.75rem, 4vw, 2.25rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.hero-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 28px;
    line-height: 1.5;
}

.search-bar {
    display: flex;
    gap: 10px;
    background: var(--bg-surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 6px 6px 6px 18px;
    box-shadow: var(--shadow-md);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.search-bar:focus-within {
    border-color: var(--brand-600);
    box-shadow: 0 0 0 4px rgba(74, 144, 164, 0.15);
}

.search-bar-icon {
    display: flex;
    align-items: center;
    color: var(--text-muted);
    font-size: 16px;
}

.search-bar input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 16px;
    font-family: inherit;
    color: var(--text-primary);
    background: transparent;
    min-width: 0;
}

.search-bar input::placeholder {
    color: var(--text-muted);
}

.btn-research {
    padding: 12px 24px;
    background: var(--brand-800);
    color: var(--text-inverse);
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    transition: all var(--transition);
}

.btn-research:hover:not(:disabled) {
    background: var(--brand-900);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-research:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.advanced-toggle {
    margin-top: 16px;
    background: none;
    border: none;
    color: var(--brand-600);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}

.advanced-toggle:hover {
    background: var(--brand-100);
}

.advanced-panel {
    margin-top: 20px;
    padding: 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    text-align: left;
    box-shadow: var(--shadow-sm);
}

.advanced-panel[hidden] {
    display: none;
}

.advanced-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.advanced-field label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.advanced-field input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    transition: border-color var(--transition);
}

.advanced-field input:focus {
    outline: none;
    border-color: var(--brand-600);
    box-shadow: 0 0 0 3px rgba(74, 144, 164, 0.12);
}

.advanced-field.full-width {
    grid-column: 1 / -1;
}

.advanced-hint {
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.example-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
}

.example-chip {
    padding: 6px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.example-chip:hover {
    border-color: var(--brand-600);
    color: var(--brand-800);
    background: var(--brand-100);
}

.trust-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.trust-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.trust-badge i {
    color: var(--brand-600);
}

.recent-searches {
    margin-top: 28px;
    text-align: left;
}

.recent-searches-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.recent-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.recent-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.recent-item:hover {
    border-color: var(--brand-600);
    color: var(--brand-800);
}

.recent-item i {
    color: var(--text-muted);
    font-size: 11px;
}

/* ── Inline progress ── */
.inline-progress {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.inline-progress[hidden] {
    display: none;
}

.inline-progress-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.inline-progress-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.inline-progress-title .spinner-sm {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-left-color: var(--brand-600);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.inline-progress-message {
    font-size: 13px;
    color: var(--text-muted);
}

.progress-steps-inline {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 12px 8px;
    border-radius: var(--radius-sm);
    background: var(--bg-muted);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    transition: all var(--transition);
}

.progress-step i {
    font-size: 14px;
}

.progress-step.active {
    background: var(--brand-100);
    color: var(--brand-800);
}

.progress-step.completed {
    background: var(--success-bg);
    color: var(--success);
}

/* Info bubble on light panel header */
.dashboard-grid .info-bubble-trigger {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 28px;
    height: 28px;
}

.dashboard-grid .info-bubble-trigger:hover {
    background: var(--bg-muted);
    color: var(--brand-800);
}

.insight-sources h5 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.insight-sources.sources-collapsed .sources-list {
    display: none;
}

.insights-content {
    padding: 16px;
    overflow-y: auto;
    max-height: 70vh;
}

.dashboard-grid .tab-content {
    max-height: 60vh;
    overflow-y: auto;
}

/* ── Company summary bar ── */
.company-summary {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.company-summary[hidden] {
    display: none;
}

.summary-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.company-identity {
    display: flex;
    align-items: center;
    gap: 16px;
}

.company-avatar {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--brand-800), var(--brand-600));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    flex-shrink: 0;
}

.company-info h2 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0 0 4px;
}

.company-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 13px;
    color: var(--text-muted);
}

.company-meta a {
    color: var(--brand-600);
    text-decoration: none;
}

.company-meta a:hover {
    text-decoration: underline;
}

.summary-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.kpi-card {
    padding: 16px;
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    text-align: center;
}

.kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    font-feature-settings: "tnum";
    line-height: 1;
    margin-bottom: 4px;
}

.kpi-value.accent {
    color: var(--brand-800);
}

.kpi-value.success {
    color: var(--success);
}

.kpi-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

/* ── Dashboard grid (results) ── */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 480px;
    gap: 20px;
    align-items: start;
}

.dashboard-grid .sources-panel,
.dashboard-grid .insights-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.dashboard-grid .panel-header {
    background: var(--bg-muted);
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
}

.dashboard-grid .panel-header h2 {
    font-size: 14px;
    font-weight: 700;
    text-shadow: none;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.dashboard-grid .panel-header h2 i {
    color: var(--brand-600);
}

.dashboard-grid .source-stats,
.dashboard-grid .insights-stats {
    background: var(--bg-surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    font-size: 11px;
    padding: 4px 10px;
}

.dashboard-grid .sources-tabs {
    background: var(--bg-muted);
}

.dashboard-grid .tab-btn {
    font-size: 12px;
    padding: 12px 16px;
}

.dashboard-grid .tab-btn.active {
    color: var(--brand-800);
    border-bottom-color: var(--brand-600);
}

/* ── Insights toolbar ── */
.insights-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-muted);
    flex-wrap: wrap;
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.filter-chip {
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg-surface);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.filter-chip:hover {
    border-color: var(--brand-600);
    color: var(--brand-800);
}

.filter-chip.active {
    background: var(--brand-800);
    border-color: var(--brand-800);
    color: white;
}

.sort-select {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: inherit;
    color: var(--text-secondary);
    background: var(--bg-surface);
    cursor: pointer;
}

/* ── Insight card redesign ── */
.dashboard-grid .insight-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    box-shadow: none;
}

.dashboard-grid .insight-card:hover {
    box-shadow: var(--shadow-md);
    transform: none;
}

.dashboard-grid .insight-card.multi-source {
    border-left: 3px solid var(--success);
    background: var(--success-bg);
}

.dashboard-grid .insight-type {
    background: var(--brand-800);
    font-size: 10px;
}

.dashboard-grid .insight-sources {
    background: var(--bg-muted);
}

.dashboard-grid .insight-actions {
    padding: 12px 16px;
    gap: 8px;
}

.insight-actions-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-outreach {
    flex: 1;
    min-width: 140px;
}

.action-dropdown {
    position: relative;
}

.action-dropdown-menu {
    position: absolute;
    bottom: calc(100% + 4px);
    right: 0;
    min-width: 180px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 4px;
    z-index: 50;
    display: none;
}

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

.action-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: none;
    font-size: 13px;
    font-family: inherit;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    text-align: left;
}

.action-dropdown-item:hover {
    background: var(--bg-muted);
    color: var(--text-primary);
}

.action-dropdown-item i {
    width: 16px;
    color: var(--text-muted);
}

.sources-collapsed .sources-list {
    display: none;
}

.sources-toggle {
    background: none;
    border: none;
    color: var(--brand-600);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ── Action drawer ── */
.action-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 1100;
    display: none;
    backdrop-filter: blur(2px);
}

.action-drawer-overlay.open {
    display: flex;
    justify-content: flex-end;
}

.action-drawer {
    width: 420px;
    max-width: 100vw;
    height: 100%;
    background: var(--bg-surface);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    animation: slideInRight 0.25s ease;
}

@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.action-drawer-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.action-drawer-header h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.action-drawer-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.drawer-field {
    margin-bottom: 16px;
}

.drawer-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.drawer-field input,
.drawer-field textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
}

.drawer-field textarea {
    min-height: 160px;
    line-height: 1.6;
}

.drawer-preview {
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
}

/* ── Toast notifications ── */
.toast-container {
    position: fixed;
    top: calc(var(--nav-height) + 12px);
    right: 24px;
    z-index: 1200;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    background: var(--text-primary);
    color: white;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
}

.toast.success {
    background: var(--success);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Footer redesign ── */
.app-footer {
    background: var(--bg-surface);
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
    padding: 18px 20px;
    position: sticky;
    bottom: 0;
    z-index: 100;
}

.app-footer::before {
    display: none;
}

.footer-content {
    max-width: 1440px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 14px;
    align-items: center;
}

.footer-brand {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.footer-brand h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.footer-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
    max-width: 520px;
}

.footer-right {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--text-muted);
}

.footer-link {
    color: var(--brand-600);
    text-decoration: none;
}

.footer-link:hover,
.footer-link:focus-visible {
    text-decoration: underline;
}

@media (max-width: 900px) {
    .footer-content {
        grid-template-columns: 1fr;
        text-align: left;
    }
    .footer-right {
        justify-content: flex-start;
    }
}

/* ── Responsive ── */
@media (max-width: 1100px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-grid .insights-panel {
        order: -1;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .dashboard {
        padding: 16px 16px 32px;
    }

    .search-hero {
        padding: 24px 0 16px;
    }

    .search-bar {
        flex-direction: column;
        padding: 12px;
    }

    .btn-research {
        width: 100%;
        justify-content: center;
    }

    .advanced-grid {
        grid-template-columns: 1fr;
    }

    .progress-steps-inline {
        grid-template-columns: repeat(2, 1fr);
    }

    .summary-top {
        flex-direction: column;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .nav-btn span {
        display: none;
    }

    .action-drawer {
        width: 100%;
    }

    .trust-badges {
        flex-direction: column;
        align-items: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    .action-drawer {
        animation: none;
    }
}
