/* OSINT.science Main Styles
   Dark-mode first, professional OSINT tool aesthetic
*/

/* CSS Variables */
:root {
    /* Dark mode colors (default) */
    --bg-primary: #1a1d23;
    --bg-secondary: #22262e;
    --bg-tertiary: #2a2f38;
    --bg-hover: #32383f;

    --text-primary: #e8e9eb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-muted: #1d4ed8;

    --border: #374151;
    --border-light: #4b5563;

    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 24px;

    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "SF Mono", Monaco, "Cascadia Code", monospace;

    --font-size-xs: 11px;
    --font-size-sm: 12px;
    --font-size-base: 13px;
    --font-size-lg: 14px;
    --font-size-xl: 16px;

    /* Layout */
    --sidebar-left-width: 280px;
    --sidebar-right-width: 250px;
    --toolbar-height: 48px;
    --statusbar-height: 24px;
}

/* Light mode */
body.light-mode {
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --bg-hover: #e5e7eb;

    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;

    --border: #e5e7eb;
    --border-light: #d1d5db;
}

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

/* Base */
html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-sans);
    font-size: var(--font-size-base);
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
}

/* App Container */
#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--toolbar-height);
    padding: 0 var(--space-lg);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 600;
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--accent);
    color: white;
    border-radius: 4px;
    font-size: var(--font-size-lg);
    font-weight: bold;
}

.logo-text {
    font-size: var(--font-size-lg);
}

.toolbar-btn {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}

.toolbar-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.toolbar-btn .icon {
    font-weight: bold;
    font-size: var(--font-size-xs);
}

/* Main Content */
.main-content {
    flex: 1;
    overflow: hidden;
}

/* Three Panel Layout */
.three-panel-layout {
    display: flex;
    height: calc(100vh - var(--toolbar-height) - var(--statusbar-height));
}

/* Sidebars */
.sidebar-left, .sidebar-right {
    flex-shrink: 0;
    overflow-y: auto;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
}

.sidebar-left {
    width: var(--sidebar-left-width);
}

.sidebar-right {
    width: var(--sidebar-right-width);
    border-right: none;
    border-left: 1px solid var(--border);
}

/* Panels */
.panel {
    padding: var(--space-md);
    border-bottom: 1px solid var(--border);
}

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

.panel-title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

/* Quick Search */
.search-input-wrapper {
    display: flex;
    gap: var(--space-xs);
    margin-bottom: var(--space-sm);
}

.search-input-wrapper input {
    flex: 1;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: var(--font-size-base);
}

.search-input-wrapper input:focus {
    outline: none;
    border-color: var(--accent);
}

.search-btn {
    padding: var(--space-sm) var(--space-md);
    background: var(--accent);
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    font-weight: bold;
}

.search-btn:hover {
    background: var(--accent-hover);
}

.search-options {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    margin-bottom: var(--space-sm);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    cursor: pointer;
}

.checkbox-label input {
    accent-color: var(--accent);
}

.link-btn {
    background: none;
    border: none;
    color: var(--accent);
    font-size: var(--font-size-sm);
    cursor: pointer;
    padding: 0;
}

.link-btn:hover {
    text-decoration: underline;
}

/* Adapter Count */
.adapter-count {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

/* Common Tasks */
.task-btn {
    display: block;
    width: 100%;
    padding: var(--space-sm);
    margin-bottom: var(--space-xs);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    text-align: left;
    cursor: pointer;
    text-decoration: none;
}

.task-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Icon Button */
.icon-btn {
    width: 24px;
    height: 24px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
    cursor: pointer;
    font-size: var(--font-size-sm);
}

.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Results Panel */
.results-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.results-controls {
    display: flex;
    gap: var(--space-lg);
}

.control-group {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.control-group label {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

.control-group select {
    padding: var(--space-xs) var(--space-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: var(--font-size-sm);
}

.results-stats {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

/* Progress Bar */
.progress-bar {
    height: 40px;
    background: var(--bg-tertiary);
    position: relative;
    border-radius: 8px;
    margin: var(--space-md);
    display: flex;
    align-items: center;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent-hover) 50%, var(--accent) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite linear;
    transition: width 0.3s ease;
    width: 0%;
    border-radius: 8px 0 0 8px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.progress-text {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: var(--font-size-base);
    color: var(--text-primary);
    font-weight: 500;
    z-index: 1;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.progress-spinner {
    position: absolute;
    left: var(--space-md);
    width: 24px;
    height: 24px;
    border: 3px solid var(--bg-primary);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Results List */
.results-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
}

.results-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
}

.placeholder-icon {
    width: 80px;
    height: 80px;
    background: var(--bg-tertiary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: bold;
    color: var(--accent);
    margin-bottom: var(--space-lg);
}

.results-placeholder h2 {
    font-size: var(--font-size-xl);
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.results-placeholder .hint {
    font-size: var(--font-size-sm);
    max-width: 300px;
}

/* Folders */
.folder-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.folder-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm);
    border-radius: 4px;
    cursor: pointer;
    font-size: var(--font-size-sm);
}

.folder-item:hover {
    background: var(--bg-hover);
}

.folder-icon {
    color: var(--accent);
}

.folder-name {
    flex: 1;
}

.folder-count {
    color: var(--text-muted);
    font-size: var(--font-size-xs);
}

/* History */
.history-list {
    max-height: 200px;
    overflow-y: auto;
}

.history-item {
    padding: var(--space-sm);
    border-radius: 4px;
    cursor: pointer;
    font-size: var(--font-size-sm);
}

.history-item:hover {
    background: var(--bg-hover);
}

.history-query {
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

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

.history-empty {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
    text-align: center;
    padding: var(--space-lg);
}

/* Status Bar */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: var(--statusbar-height);
    padding: 0 var(--space-lg);
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border);
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    flex-shrink: 0;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 8px;
    width: 600px;
    max-width: 90vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.modal-small {
    width: 300px;
}

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

.modal-header h2 {
    font-size: var(--font-size-lg);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    flex: 1;
    padding: var(--space-lg);
    overflow-y: auto;
}

.modal-footer {
    padding: var(--space-lg);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
}

/* Buttons */
.btn-primary {
    padding: var(--space-sm) var(--space-lg);
    background: var(--accent);
    border: none;
    border-radius: 4px;
    color: white;
    font-size: var(--font-size-sm);
    cursor: pointer;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

/* Analysis Modes */
.analysis-modes {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
}

.mode-btn {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    cursor: pointer;
}

.mode-btn:hover {
    background: var(--bg-hover);
}

.mode-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

#question-input {
    margin-bottom: var(--space-lg);
}

#question-input input {
    width: 100%;
    padding: var(--space-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
}

#analysis-content {
    min-height: 150px;
    max-height: 400px;
    overflow-y: auto;
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border-radius: 4px;
    line-height: 1.6;
}

/* Analysis sections (multiple analyses) */
.analysis-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: var(--space-md);
    overflow: hidden;
}

.analysis-section.error {
    border-color: var(--error);
}

.analysis-section.loading {
    opacity: 0.7;
}

.analysis-section-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
}

.analysis-mode-badge {
    background: var(--accent);
    color: white;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: var(--font-size-xs);
    font-weight: 500;
}

.analysis-time {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    flex: 1;
}

.analysis-remove-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
    line-height: 1;
}

.analysis-remove-btn:hover {
    color: var(--error);
}

.analysis-question {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-hover);
    font-style: italic;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.analysis-section-content {
    padding: var(--space-md);
    white-space: pre-wrap;
}

.analysis-section-content p {
    margin-bottom: var(--space-sm);
}

.analysis-section-content ul,
.analysis-section-content ol {
    margin-left: var(--space-lg);
    margin-bottom: var(--space-sm);
}

.analysis-citations-inline {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border);
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.analysis-citations-inline a {
    color: var(--accent);
    margin-right: var(--space-xs);
}

/* Button secondary style */
.btn-secondary {
    padding: var(--space-sm) var(--space-lg);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    cursor: pointer;
}

.btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Network Graph Visualization */
#network-container {
    margin-top: var(--space-lg);
}

#network-graph {
    width: 100%;
    height: 400px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    border: 1px solid var(--border);
    overflow: hidden;
}

#network-graph svg {
    width: 100%;
    height: 100%;
}

#network-legend {
    display: flex;
    gap: var(--space-lg);
    padding: var(--space-sm);
    justify-content: center;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.legend-item .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.legend-item .dot.person { background: #ef4444; }
.legend-item .dot.org { background: #3b82f6; }
.legend-item .dot.location { background: #10b981; }
.legend-item .dot.event { background: #f59e0b; }
.legend-item .dot.concept { background: #8b5cf6; }

/* Network graph node styles */
.node-label {
    font-size: 10px;
    fill: var(--text-primary);
    pointer-events: none;
}

.link {
    stroke: var(--border);
    stroke-opacity: 0.6;
}

.link-label {
    font-size: 8px;
    fill: var(--text-muted);
}

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

/* Export Options */
.export-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
}

.export-btn {
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: var(--font-size-base);
    cursor: pointer;
}

.export-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

/* AI Summary Panel */
.ai-summary-panel {
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

.ai-summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    cursor: pointer;
}

.ai-summary-content {
    padding: var(--space-md);
    max-height: 200px;
    overflow-y: auto;
}

.collapse-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transform: rotate(180deg);
}

.ai-summary-panel.collapsed .collapse-btn {
    transform: rotate(0);
}

.ai-summary-panel.collapsed .ai-summary-content {
    display: none;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

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

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

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

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

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Advanced Search Form */
.advanced-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.form-group label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.form-group input,
.form-group select {
    padding: 0.5rem 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent);
    outline: none;
}

.form-group select {
    cursor: pointer;
}

.btn-secondary {
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.btn-secondary:hover {
    background: var(--bg-secondary);
}

.modal-footer {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
    margin-top: 1rem;
}

/* Category Actions */
.category-actions {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--border);
}

.category-actions .link-btn.small {
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--font-size-xs);
}

/* Citation Links */
.citation {
    color: var(--accent);
    text-decoration: none;
    cursor: pointer;
    font-weight: 500;
}

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