/* LinkScout - Production-grade SEO platform UI */

:root {
    --primary: #667eea;
    --primary-dark: #5568d8;
    --secondary: #764ba2;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --sidebar-width: 240px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* === SIDEBAR === */
.sidebar {
    position: fixed;
    left: 0; top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    color: white;
    padding: 24px 0;
    overflow-y: auto;
    z-index: 100;
}

.logo {
    padding: 0 24px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.4em;
    font-weight: 700;
}

.logo-icon {
    font-size: 1.5em;
}

.nav-section {
    padding: 16px 0;
}

.nav-label {
    padding: 0 24px 8px;
    font-size: 0.7em;
    font-weight: 700;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.nav-link, .nav-button {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    font-size: 0.95em;
}

.nav-link:hover, .nav-button:hover {
    background: rgba(255,255,255,0.05);
    color: white;
}

.nav-link.active {
    background: linear-gradient(90deg, rgba(102,126,234,0.2) 0%, transparent 100%);
    color: white;
    border-left: 3px solid var(--primary);
}

.pipeline-status {
    position: absolute;
    bottom: 20px;
    left: 24px;
    right: 24px;
    padding: 12px;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85em;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gray-500);
}

.status-dot.running {
    background: var(--success);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* === CONTENT === */
.content {
    margin-left: var(--sidebar-width);
    padding: 32px 40px;
    min-height: 100vh;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 28px;
}

.page-header h1 {
    font-size: 2em;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.subtitle {
    color: var(--gray-500);
}

.header-actions {
    display: flex;
    gap: 10px;
}

/* === STATS GRID === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    gap: 14px;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4em;
}

.stat-icon.blue   { background: #dbeafe; color: #1e40af; }
.stat-icon.purple { background: #ede9fe; color: #5b21b6; }
.stat-icon.green  { background: #d1fae5; color: #065f46; }
.stat-icon.orange { background: #fed7aa; color: #9a3412; }
.stat-icon.pink   { background: #fce7f3; color: #9d174d; }
.stat-icon.teal   { background: #ccfbf1; color: #115e59; }

.stat-number {
    font-size: 1.8em;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1;
}

.stat-label {
    color: var(--gray-500);
    font-size: 0.85em;
    margin-top: 4px;
}

/* === CARDS === */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    overflow: hidden;
}

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

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2 {
    font-size: 1.1em;
    color: var(--gray-800);
}

.card-body {
    padding: 20px 24px;
}

/* === TABLES === */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    padding: 12px 8px;
    text-align: left;
    font-size: 0.75em;
    color: var(--gray-500);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--gray-200);
}

.data-table td {
    padding: 14px 8px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.9em;
}

.data-table.compact td {
    padding: 8px;
}

.data-table tr:hover {
    background: var(--gray-50);
}

.data-table td.empty {
    text-align: center;
    color: var(--gray-400);
    padding: 32px;
}

/* === BADGES === */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
}

.badge.da { background: #dbeafe; color: #1e40af; }
.badge.rel-high { background: #d1fae5; color: #065f46; }
.badge.rel-mid { background: #fef3c7; color: #92400e; }
.badge.rel-low { background: #fee2e2; color: #991b1b; }

.badge.niche-fitness { background: #fee2e2; color: #991b1b; }
.badge.niche-ai { background: #ede9fe; color: #5b21b6; }

.badge.status-new { background: #dbeafe; color: #1e40af; }
.badge.status-contacted { background: #fef3c7; color: #92400e; }
.badge.status-responded { background: #d1fae5; color: #065f46; }
.badge.status-accepted { background: #d1fae5; color: #065f46; }
.badge.status-completed { background: #d1fae5; color: #065f46; }
.badge.status-ignored { background: var(--gray-200); color: var(--gray-600); }

/* === BUTTONS === */
.btn, button {
    padding: 8px 16px;
    border: 1px solid var(--gray-300);
    background: white;
    color: var(--gray-700);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.15s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn:hover, button:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.btn-primary, button.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-warn, button.btn-warn {
    background: white;
    color: var(--danger);
    border-color: var(--gray-300);
}

.btn-warn:hover {
    background: #fee2e2;
    border-color: var(--danger);
}

.btn-small {
    padding: 4px 10px;
    font-size: 0.8em;
    border-radius: 6px;
}

/* === FILTERS === */
.filters-bar {
    background: white;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 140px;
}

.filter-group label {
    font-size: 0.8em;
    color: var(--gray-600);
    font-weight: 500;
}

.filter-group select, .filter-group input[type="text"] {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 0.9em;
    background: white;
}

.filter-group input[type="range"] {
    width: 140px;
}

.result-count {
    margin-bottom: 12px;
    color: var(--gray-600);
    font-size: 0.9em;
}

/* === OPPORTUNITY CARDS === */
.opportunities-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.opp-card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    padding: 16px;
    display: grid;
    grid-template-columns: 80px 1fr auto auto;
    gap: 16px;
    align-items: center;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid transparent;
}

.opp-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border-color: var(--primary);
}

.opp-priority {
    text-align: center;
}

.priority-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4em;
    font-weight: 700;
    color: white;
    margin: 0 auto;
}

.priority-very-high { background: linear-gradient(135deg, #ef4444 0%, #f59e0b 100%); }
.priority-high { background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%); }
.priority-medium { background: linear-gradient(135deg, #3b82f6 0%, #60a5fa 100%); }
.priority-low { background: var(--gray-400); }

.priority-label {
    font-size: 0.75em;
    color: var(--gray-500);
    margin-top: 4px;
}

.opp-main {
    min-width: 0;
}

.opp-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.domain-link {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
    font-size: 1em;
}

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

.opp-page {
    color: var(--gray-700);
    font-size: 0.9em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.opp-broken, .opp-suggestion {
    font-size: 0.82em;
    color: var(--gray-500);
    margin-top: 3px;
}

.opp-broken code {
    background: var(--gray-100);
    padding: 1px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
}

.opp-metrics {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-end;
}

.opp-metrics .metric.small {
    font-size: 0.75em;
    color: var(--gray-500);
}

.opp-actions {
    display: flex;
    gap: 6px;
}

/* === MODALS === */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active { display: flex; }

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 85vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-content.large {
    max-width: 900px;
}

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

.modal-header h2 {
    font-size: 1.2em;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.6em;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.close-btn:hover { color: var(--gray-700); }

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

/* === DETAIL SECTIONS === */
.detail-section {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--gray-100);
}

.detail-section h3 {
    font-size: 0.95em;
    color: var(--gray-700);
    margin-bottom: 12px;
}

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

.score-item {
    background: var(--gray-50);
    padding: 14px;
    border-radius: 8px;
    text-align: center;
}

.score-value {
    font-size: 1.6em;
    font-weight: 700;
    color: var(--gray-900);
}

.score-label {
    font-size: 0.75em;
    color: var(--gray-500);
    margin-top: 2px;
}

.info-row {
    margin-bottom: 8px;
    font-size: 0.9em;
}

.info-row code {
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
}

.wayback-content {
    background: var(--gray-50);
    padding: 12px;
    border-radius: 8px;
    margin-top: 8px;
    font-size: 0.85em;
    color: var(--gray-600);
    max-height: 200px;
    overflow-y: auto;
    border-left: 3px solid var(--primary);
}

.detail-section.wayback {
    background: #faf5ff;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #e9d5ff;
}

.email-history-item {
    padding: 10px;
    background: var(--gray-50);
    border-radius: 6px;
    margin-bottom: 8px;
}

.email-meta {
    font-size: 0.8em;
    color: var(--gray-500);
    margin-top: 4px;
}

.detail-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* === FORMS === */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85em;
    color: var(--gray-700);
    margin-bottom: 6px;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 0.9em;
    font-family: inherit;
}

.form-group textarea {
    resize: vertical;
    font-family: 'Monaco', 'Menlo', monospace;
    line-height: 1.5;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-100);
}

/* === METRICS === */
.metric-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-100);
}

.metric-label {
    color: var(--gray-600);
}

.metric-value {
    font-weight: 600;
    color: var(--gray-900);
}

/* === FUNNEL === */
.funnel {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.funnel-stage {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.funnel-bar {
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    min-width: 50px;
    transition: width 0.5s;
}

.funnel-value {
    color: white;
    font-weight: 600;
    font-size: 0.9em;
}

.funnel-label {
    font-size: 0.8em;
    color: var(--gray-600);
}

/* === EMPTY STATE === */
.empty-state {
    padding: 60px 20px;
    text-align: center;
    color: var(--gray-400);
}

.link {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.9em;
}

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

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }
    .logo-text, .nav-label, .nav-link span:last-child {
        display: none;
    }
    .content {
        margin-left: 60px;
        padding: 20px;
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .opp-card {
        grid-template-columns: 60px 1fr;
    }
    .opp-metrics, .opp-actions {
        grid-column: 1 / -1;
        flex-direction: row;
    }
    .score-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
