/* ===========================
   Lead Finder — CSS
   Тёмная тема, минимализм, синие акценты
   =========================== */

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #161821;
    --bg-card: #1c1e2a;
    --bg-card-hover: #222436;
    --bg-input: #12131d;

    --text-primary: #e2e4ed;
    --text-secondary: #8a8ea0;
    --text-muted: #555870;

    --accent: #4a7cff;
    --accent-hover: #5d8bff;
    --accent-glow: rgba(74, 124, 255, 0.15);

    --danger: #ff4a6e;
    --danger-hover: #ff6384;
    --success: #34d399;
    --warning: #fbbf24;

    --border: #262838;
    --border-light: #2e3045;

    --radius: 10px;
    --radius-sm: 6px;

    --font-body: 'Manrope', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --sidebar-width: 240px;
    --transition: 0.2s ease;
}

/* === Reset === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
}

a {
    color: var(--accent);
    text-decoration: none;
}
a:hover {
    color: var(--accent-hover);
}

/* === Sidebar === */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 24px 20px 20px;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 24px;
    color: var(--accent);
}

.logo-text {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.nav-list {
    list-style: none;
    padding: 12px 8px;
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
    margin-bottom: 2px;
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}

.nav-link.active {
    color: var(--accent);
    background: var(--accent-glow);
}

.nav-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: background var(--transition);
}

.dot.online {
    background: var(--success);
    box-shadow: 0 0 8px rgba(52, 211, 153, 0.5);
}

.dot.offline {
    background: var(--danger);
    box-shadow: 0 0 8px rgba(255, 74, 110, 0.5);
}

/* === Mobile Header === */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    align-items: center;
    padding: 0 16px;
    z-index: 99;
    justify-content: space-between;
}

.burger {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 22px;
    cursor: pointer;
    padding: 4px;
}

.mobile-title {
    font-weight: 700;
    font-size: 16px;
}

.mobile-status .dot {
    width: 10px;
    height: 10px;
}

/* === Main Content === */
.content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 32px 40px;
    max-width: 960px;
}

.section {
    display: none;
}

.section.active {
    display: block;
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.section-header {
    margin-bottom: 28px;
}

.section-header h1 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.section-subtitle {
    color: var(--text-muted);
    font-size: 14px;
}

/* === Cards === */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}

.card h2 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
}

/* === Stats Grid === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
}

.stat-card.accent {
    border-color: var(--accent);
    background: linear-gradient(135deg, var(--bg-card), var(--accent-glow));
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 32px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.stat-card.accent .stat-value {
    color: var(--accent);
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

/* === Forms === */
.form-row {
    display: flex;
    gap: 12px;
}

.input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition);
}

.input:focus {
    border-color: var(--accent);
}

.input::placeholder {
    color: var(--text-muted);
}

.btn {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: none;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-card-hover);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border-light);
    color: var(--text-primary);
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid transparent;
    padding: 6px 12px;
    font-size: 13px;
}

.btn-danger:hover {
    background: rgba(255, 74, 110, 0.1);
    border-color: var(--danger);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* === Items List (chats, keywords, stopwords) === */
.items-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}

.list-item:hover {
    background: var(--bg-card-hover);
}

.list-item-info {
    flex: 1;
    min-width: 0;
}

.list-item-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.list-item-sub {
    font-size: 12px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.list-item-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 20px;
    background: var(--accent-glow);
    color: var(--accent);
    font-weight: 600;
    margin-right: 12px;
}

/* === Matches List === */
.matches-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.match-item {
    padding: 16px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent);
    transition: background var(--transition);
}

.match-item:hover {
    background: var(--bg-card-hover);
}

.match-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    gap: 8px;
}

.match-chat {
    font-weight: 600;
    font-size: 14px;
    color: var(--accent);
}

.match-time {
    font-size: 12px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    flex-shrink: 0;
}

.match-author {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.match-text {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 1.5;
    margin-bottom: 8px;
}

.match-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.match-keyword {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 20px;
    background: rgba(52, 211, 153, 0.1);
    color: var(--success);
    font-family: var(--font-mono);
}

.match-link {
    font-size: 13px;
    color: var(--accent);
    font-weight: 500;
}

.matches-controls {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 16px;
}

/* === Empty state === */
.empty-state {
    text-align: center;
    padding: 32px;
    color: var(--text-muted);
    font-size: 14px;
}

/* === Toast notifications === */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    animation: slideIn 0.3s ease;
    max-width: 360px;
}

.toast.success {
    background: rgba(52, 211, 153, 0.15);
    color: var(--success);
    border: 1px solid rgba(52, 211, 153, 0.3);
}

.toast.error {
    background: rgba(255, 74, 110, 0.15);
    color: var(--danger);
    border: 1px solid rgba(255, 74, 110, 0.3);
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* === Responsive === */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .mobile-header {
        display: flex;
    }

    .content {
        margin-left: 0;
        padding: 72px 16px 24px;
        max-width: 100%;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-row {
        flex-direction: column;
    }

    .match-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* === Overlay for mobile sidebar === */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}