/**
 * Seotrends Design System - Futuristic Blue Glow Theme
 * Clean light base with electric blue accents and glow effects
 */

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

/* ========== CSS Variables ========== */
:root {
    /* Colors - Light Theme with Blue Tint */
    --background: #f8fafc;
    --background-elevated: #ffffff;
    --foreground: #0f172a;
    --foreground-muted: #64748b;

    /* Cards & Surfaces */
    --card: #ffffff;
    --card-hover: #f8fafc;
    --card-foreground: #0f172a;

    /* Primary accent - Electric Blue */
    --primary: #0ea5e9;
    --primary-hover: #0284c7;
    --primary-foreground: #ffffff;
    --primary-light: #e0f2fe;
    --primary-glow: rgba(14, 165, 233, 0.35);
    --primary-gradient: linear-gradient(135deg, #0ea5e9 0%, #06b6d4 50%, #22d3ee 100%);

    /* Secondary */
    --secondary: #f1f5f9;
    --secondary-hover: #e2e8f0;
    --secondary-foreground: #475569;

    /* Muted/Subtle */
    --muted: #f1f5f9;
    --muted-foreground: #64748b;

    /* Accent - Cyan glow */
    --accent: #ecfeff;
    --accent-foreground: #0e7490;

    /* Semantic Colors */
    --success: #22c55e;
    --success-bg: #f0fdf4;
    --success-foreground: #16a34a;
    --success-border: #bbf7d0;

    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --warning-foreground: #d97706;
    --warning-border: #fde68a;

    --destructive: #ef4444;
    --destructive-bg: #fef2f2;
    --destructive-foreground: #dc2626;
    --destructive-border: #fecaca;

    --info: #0ea5e9;
    --info-bg: #e0f2fe;
    --info-foreground: #0284c7;
    --info-border: #7dd3fc;

    /* Borders - Subtle blue tint */
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --input: #e2e8f0;
    --ring: #0ea5e9;

    /* Radius */
    --radius: 6px;
    --radius-sm: 4px;
    --radius-lg: 8px;
    --radius-xl: 12px;

    /* Shadows - With blue glow */
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.1);
    --shadow-glow: 0 0 20px rgba(14, 165, 233, 0.15);
    --shadow-glow-strong: 0 0 30px rgba(14, 165, 233, 0.25);

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'SF Mono', SFMono-Regular, ui-monospace, Menlo, monospace;
}

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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--background);
    color: var(--foreground);
    line-height: 1.5;
    font-size: 14px;
    font-weight: 400;
    letter-spacing: -0.006em;
}

::selection {
    background: rgba(14, 165, 233, 0.2);
    color: var(--foreground);
}

/* ========== Typography ========== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 500;
    letter-spacing: -0.02em;
    color: var(--foreground);
}

h1 { font-size: 1.5rem; line-height: 1.3; }
h2 { font-size: 1.125rem; line-height: 1.4; }
h3 { font-size: 1rem; line-height: 1.4; }

p { color: var(--muted-foreground); }

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--primary-hover);
}

code {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    background: var(--muted);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    color: #e11d48;
}

/* ========== Layout ========== */
.main-content {
    padding: 24px;
    min-height: calc(100vh - 56px);
    background: linear-gradient(180deg, #f0f9ff 0%, #f8fafc 100px, #f8fafc 100%);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: var(--card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 24px;
    box-shadow: var(--shadow-sm), 0 0 40px rgba(14, 165, 233, 0.03);
}

.page-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(90deg, transparent 0%, rgba(14, 165, 233, 0.02) 50%, transparent 100%);
    margin: -24px -24px 20px -24px;
    padding: 20px 24px 16px 24px;
}

.page-header h1 {
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--foreground);
}

.page-header p {
    margin-top: 4px;
    font-size: 0.8125rem;
    color: var(--muted-foreground);
}

/* ========== Cards ========== */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
    transition: all 0.2s ease;
}

.card:hover {
    border-color: rgba(14, 165, 233, 0.3);
    box-shadow: 0 4px 20px rgba(14, 165, 233, 0.08);
}

.card-header {
    margin-bottom: 12px;
}

.card-title {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 2px;
}

.card-description {
    font-size: 0.8125rem;
    color: var(--muted-foreground);
}

/* ========== Stats Grid ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.stat-card {
    background: transparent;
    padding: 0;
}

.stat-card h3 {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}

.stat-card .value {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--foreground);
    letter-spacing: -0.02em;
    line-height: 1;
}

.stat-card .subtext {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin-top: 4px;
    font-weight: 400;
}

/* Bordered variant */
.stats-grid.bordered {
    gap: 12px;
}

.stats-grid.bordered .stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    padding: 16px;
    border-radius: var(--radius);
    transition: border-color 0.15s ease;
}

.stats-grid.bordered .stat-card:hover {
    border-color: rgba(14, 165, 233, 0.3);
    box-shadow: 0 4px 16px rgba(14, 165, 233, 0.08);
}

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
    font-family: inherit;
}

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

.btn-primary {
    background: var(--primary-gradient);
    color: var(--primary-foreground);
    border-color: transparent;
    box-shadow: 0 1px 2px rgba(14, 165, 233, 0.2);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-gradient);
    filter: brightness(1.1);
    box-shadow: 0 4px 16px rgba(14, 165, 233, 0.35), 0 0 20px rgba(14, 165, 233, 0.2);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--card);
    color: var(--foreground);
    border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--secondary);
    border-color: rgba(14, 165, 233, 0.3);
    box-shadow: 0 0 12px rgba(14, 165, 233, 0.08);
}

.btn-outline {
    background: transparent;
    color: var(--foreground);
    border-color: var(--border);
}

.btn-outline:hover:not(:disabled) {
    background: rgba(14, 165, 233, 0.05);
    border-color: rgba(14, 165, 233, 0.3);
}

.btn-destructive {
    background: var(--destructive);
    color: #fff;
    border-color: var(--destructive);
}

.btn-destructive:hover:not(:disabled) {
    background: #dc2626;
    border-color: #dc2626;
}

.btn-success {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}

.btn-success:hover:not(:disabled) {
    background: #16a34a;
    border-color: #16a34a;
}

.btn-warning {
    background: var(--warning);
    color: #1a1a1a;
    border-color: var(--warning);
}

.btn-warning:hover:not(:disabled) {
    background: #ca8a04;
    border-color: #ca8a04;
}

.btn-sm {
    padding: 6px 10px;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 10px 18px;
    font-size: 0.875rem;
}

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

.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--foreground);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 8px 12px;
    font-size: 0.8125rem;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--foreground);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--ring);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15), 0 0 12px rgba(14, 165, 233, 0.1);
}

.form-input::placeholder {
    color: var(--muted-foreground);
}

.form-hint {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin-top: 6px;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23737373' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 36px;
}

/* ========== Messages / Alerts ========== */
.message {
    padding: 12px 14px;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    margin-bottom: 16px;
    border: 1px solid;
}

.message.success {
    background: var(--success-bg);
    color: var(--success-foreground);
    border-color: var(--success-border);
}

.message.error {
    background: var(--destructive-bg);
    color: var(--destructive-foreground);
    border-color: var(--destructive-border);
}

.message.warning {
    background: var(--warning-bg);
    color: var(--warning-foreground);
    border-color: var(--warning-border);
}

.message.info {
    background: linear-gradient(135deg, #e0f2fe 0%, #ecfeff 100%);
    color: var(--info-foreground);
    border-color: var(--info-border);
    box-shadow: 0 0 20px rgba(14, 165, 233, 0.08);
}

/* ========== Tables ========== */
.table-container {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--card);
    box-shadow: 0 0 30px rgba(14, 165, 233, 0.03);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.table th {
    background: linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%);
    padding: 10px 14px;
    text-align: left;
    font-weight: 500;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted-foreground);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.table th a {
    color: var(--muted-foreground);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
}

.table th a:hover {
    color: var(--foreground);
}

.table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--foreground);
    font-weight: 400;
}

.table tr:last-child td {
    border-bottom: none;
}

.table tbody tr {
    transition: background 0.1s ease;
}

.table tbody tr:hover td {
    background: rgba(14, 165, 233, 0.04);
}

/* Sortable columns */
.table th.sortable {
    cursor: pointer;
    user-select: none;
}

.table th.sortable:hover {
    background: var(--secondary-hover);
}

.sort-arrows {
    display: inline-flex;
    flex-direction: column;
    font-size: 0.5rem;
    line-height: 0.6;
    opacity: 0.4;
}

.sort-arrow.active {
    color: var(--primary);
    opacity: 1;
    text-shadow: 0 0 8px rgba(14, 165, 233, 0.5);
}

/* ========== Badges ========== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 0.6875rem;
    font-weight: 500;
    border-radius: 9999px;
    letter-spacing: 0;
}

.badge-default {
    background: var(--secondary);
    color: var(--muted-foreground);
}

.badge-success, .badge-top3 {
    background: var(--success-bg);
    color: var(--success-foreground);
}

.badge-warning, .badge-top5 {
    background: var(--warning-bg);
    color: var(--warning-foreground);
}

.badge-error, .badge-difficulty {
    background: var(--destructive-bg);
    color: var(--destructive-foreground);
}

.badge-dr-easy {
    background: #ecfccb;
    color: #4d7c0f;
}

.badge-dr-hard {
    background: #fff1f2;
    color: #c2410c;
}

.badge-info, .badge-top10 {
    background: #fff7ed;
    color: #ea580c;
}

/* Position badges */
.badge-position {
    min-width: 24px;
    justify-content: center;
    font-weight: 500;
}

/* Category Badge */
.category-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    font-size: 0.6875rem;
    background: var(--background) !important;
    font-weight: 500;
    border-radius: var(--radius);
    border: 1px solid var(--border) !important;
    text-decoration: none;
    transition: all 0.15s ease;
    white-space: nowrap;
    color: var(--muted-foreground) !important;
    letter-spacing: 0.01em;
}

.category-badge svg {
    flex-shrink: 0;
    stroke: var(--muted-foreground) !important;
    opacity: 0.7;
}

.category-badge:hover {
    border-color: var(--primary) !important;
    color: var(--primary) !important;
    background: var(--primary-light) !important;
}

.category-badge:hover svg {
    stroke: var(--primary) !important;
    opacity: 1;
}

.category-badge-inline {
    margin-left: 8px;
    vertical-align: middle;
}

/* ========== Progress Bar ========== */
.progress {
    height: 4px;
    background: var(--muted);
    border-radius: 9999px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--primary-gradient);
    border-radius: 9999px;
    transition: width 0.3s ease;
    box-shadow: 0 0 8px rgba(14, 165, 233, 0.4);
}

.progress-bar.success {
    background: var(--success);
}

.progress-bar.warning {
    background: var(--warning);
}

.progress-bar.info {
    background: var(--info);
}

/* ========== Divider ========== */
.divider {
    height: 1px;
    background: var(--border);
    margin: 16px 0;
}

/* ========== Drop Zone ========== */
.drop-zone {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    padding: 40px 24px;
    text-align: center;
    transition: all 0.2s ease;
    cursor: pointer;
    background: var(--secondary);
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 30px rgba(14, 165, 233, 0.15), inset 0 0 20px rgba(14, 165, 233, 0.05);
}

.drop-zone-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.3;
}

.drop-zone-text {
    font-size: 0.8125rem;
    color: var(--muted-foreground);
}

.drop-zone-text strong {
    color: var(--foreground);
    font-weight: 500;
}

/* ========== Pipeline / Steps ========== */
.pipeline {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pipeline-step {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: border-color 0.15s ease;
}

.pipeline-step:hover {
    border-color: rgba(14, 165, 233, 0.25);
    box-shadow: 0 4px 20px rgba(14, 165, 233, 0.08);
}

.pipeline-step-number {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--secondary);
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--muted-foreground);
    flex-shrink: 0;
}

.pipeline-step.completed .pipeline-step-number {
    background: var(--success-bg);
    color: var(--success-foreground);
}

.pipeline-step.active .pipeline-step-number {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 0 12px rgba(14, 165, 233, 0.4);
}

.pipeline-step-content {
    flex: 1;
    min-width: 0;
}

.pipeline-step-title {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--foreground);
    margin-bottom: 2px;
}

.pipeline-step-description {
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

.pipeline-step-stats {
    display: flex;
    gap: 20px;
    margin-left: auto;
    flex-shrink: 0;
}

.pipeline-step-stat {
    text-align: right;
}

.pipeline-step-stat-value {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--foreground);
    line-height: 1;
}

.pipeline-step-stat-label {
    font-size: 0.625rem;
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 3px;
}

/* ========== Action Groups ========== */
.action-group {
    padding: 16px;
    background: linear-gradient(135deg, var(--secondary) 0%, rgba(14, 165, 233, 0.03) 100%);
    border-radius: var(--radius);
    margin-bottom: 10px;
    border: 1px solid rgba(14, 165, 233, 0.06);
}

.action-group:last-child {
    margin-bottom: 0;
}

.action-group-title {
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 4px;
}

.action-group-description {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin-bottom: 12px;
}

/* ========== Results Grid ========== */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
}

.result-item {
    text-align: center;
    padding: 16px 12px;
    background: var(--card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: border-color 0.15s ease;
}

.result-item:hover {
    border-color: rgba(14, 165, 233, 0.3);
    box-shadow: 0 4px 16px rgba(14, 165, 233, 0.08);
}

.result-item .number {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--foreground);
    line-height: 1;
}

.result-item .label {
    font-size: 0.625rem;
    color: var(--muted-foreground);
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ========== Favorites ========== */
.favorite-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    font-size: 0.875rem;
    opacity: 0.3;
    transition: all 0.15s ease;
}

.favorite-btn:hover {
    opacity: 0.6;
}

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

.favorite-btn.active .star {
    color: #f59e0b;
}

/* ========== Pagination ========== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 20px;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    font-size: 0.8125rem;
    font-weight: 400;
    border-radius: var(--radius);
    transition: all 0.15s ease;
}

.pagination a {
    color: var(--muted-foreground);
    background: var(--card);
    border: 1px solid var(--border);
    text-decoration: none;
}

.pagination a:hover {
    background: rgba(14, 165, 233, 0.08);
    color: var(--primary);
    border-color: rgba(14, 165, 233, 0.2);
}

.pagination span.current {
    background: var(--primary-gradient);
    color: white;
    border: 1px solid transparent;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
}

.pagination span.ellipsis {
    color: var(--muted-foreground);
    background: transparent;
}

/* ========== Quick Filters ========== */
.quick-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.quick-filter {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--muted-foreground);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 9999px;
    text-decoration: none;
    transition: all 0.15s ease;
}

.quick-filter:hover {
    background: rgba(14, 165, 233, 0.06);
    color: var(--primary);
    border-color: rgba(14, 165, 233, 0.2);
}

.quick-filter.active {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.1) 0%, rgba(6, 182, 212, 0.1) 100%);
    color: var(--primary);
    border-color: rgba(14, 165, 233, 0.3);
    box-shadow: 0 0 12px rgba(14, 165, 233, 0.1);
}

/* ========== Category Chips (Multi-select) ========== */
.category-chips,
.category-chips-wide {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.category-chips {
    padding: 8px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 80px;
    overflow-y: auto;
}

.category-chips-wide {
    /* Full width, no scroll, no box */
}

.category-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--muted-foreground);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 9999px;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.category-chip input[type="checkbox"] {
    display: none;
}

.category-chip:hover {
    background: rgba(14, 165, 233, 0.06);
    color: var(--primary);
    border-color: rgba(14, 165, 233, 0.2);
}

.category-chip.selected {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.12) 0%, rgba(6, 182, 212, 0.08) 100%);
    color: var(--primary);
    border-color: rgba(14, 165, 233, 0.4);
    box-shadow: 0 0 10px rgba(14, 165, 233, 0.12);
}

.category-chip.selected::before {
    content: '✓ ';
    font-size: 0.7rem;
    margin-right: 2px;
}

/* ========== Domain age indicators ========== */
.age-star {
    color: #f59e0b;
}

.age-rising {
    color: #22c55e;
}

/* ========== Utility Classes ========== */
.text-muted { color: var(--muted-foreground); }
.text-success { color: var(--success-foreground); }
.text-warning { color: var(--warning-foreground); }
.text-error { color: var(--destructive-foreground); }
.text-info { color: var(--info-foreground); }

.font-mono { font-family: var(--font-mono); }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 600; }

.text-sm { font-size: 0.8125rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1rem; }

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }

.flex { display: flex; }
.inline-flex { display: inline-flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #cbd5e1 0%, #94a3b8 100%);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #94a3b8 0%, #64748b 100%);
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .main-content {
        padding: 10px;
    }

    .container {
        padding: 12px;
        border-radius: var(--radius);
    }

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

    .pipeline-step {
        flex-wrap: wrap;
    }

    .pipeline-step-stats {
        width: 100%;
        margin-left: 0;
        margin-top: 12px;
        padding-top: 12px;
        border-top: 1px solid var(--border);
    }

    .quick-filters {
        justify-content: center;
    }
}

/* ========== Skeleton Loading ========== */
.skeleton {
    background: linear-gradient(90deg, var(--secondary) 25%, rgba(14, 165, 233, 0.08) 50%, var(--secondary) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius-sm);
}

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

/* ========== Number formatting ========== */
.number-cell {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum";
}

/* ========== Domain Link Styling ========== */
.domain-link {
    color: var(--foreground);
    font-weight: 400;
    text-decoration: none;
    transition: all 0.15s ease;
}

.domain-link:hover {
    color: var(--primary);
    text-shadow: 0 0 12px rgba(14, 165, 233, 0.3);
}

/* ========== Hero Header ========== */
.hero-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.hero-content {
    flex: 1;
}

.hero-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--foreground);
    margin: 0 0 6px 0;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.hero-subtitle {
    font-size: 0.9rem;
    color: var(--muted-foreground);
    margin: 0;
    line-height: 1.5;
    max-width: 600px;
}

/* Compact filter section */
.filter-section.compact {
    margin-bottom: 12px;
    position: relative;
}

.filter-section.compact .filter-bar {
    margin-bottom: 0;
    align-items: center;
}

/* Results count */
.results-count {
    font-size: 0.8125rem;
    color: var(--muted-foreground);
    font-weight: 500;
}

/* Compact favorite item in dropdown */
.favorite-item-compact {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 0.8125rem;
}

.favorite-item-compact a {
    color: var(--foreground);
    text-decoration: none;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.favorite-item-compact a:hover {
    color: var(--primary);
}

.favorite-item-compact .remove-favorite {
    background: none;
    border: none;
    color: var(--muted-foreground);
    cursor: pointer;
    font-size: 1rem;
    padding: 0 4px;
    line-height: 1;
}

.favorite-item-compact .remove-favorite:hover {
    color: var(--destructive-foreground);
}

@media (max-width: 768px) {
    .hero-header {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 12px;
        padding-bottom: 10px;
    }

    .hero-title {
        font-size: 1.25rem;
    }

    .hero-subtitle {
        display: none;
    }
}

/* ========== Filter Dropdowns ========== */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.filter-dropdown {
    position: relative;
    display: inline-block;
}

.filter-dropdown-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--foreground);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.filter-dropdown-btn:hover {
    border-color: var(--primary);
    background: rgba(14, 165, 233, 0.04);
}

.filter-dropdown-btn.active {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.08) 0%, rgba(6, 182, 212, 0.04) 100%);
    color: var(--primary);
}

.filter-dropdown-btn .arrow {
    font-size: 0.625rem;
    transition: transform 0.2s ease;
    opacity: 0.6;
}

.filter-dropdown.open .filter-dropdown-btn .arrow {
    transform: rotate(180deg);
}

.filter-dropdown-btn .filter-value {
    color: var(--primary);
    font-weight: 600;
}

/* Checkbox-style filter buttons (for multi-select quick filters) */
.filter-checkbox-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--foreground);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.filter-checkbox-btn input[type="checkbox"] {
    display: none;
}

.filter-checkbox-btn:hover {
    border-color: var(--primary);
    background: rgba(14, 165, 233, 0.04);
}

.filter-checkbox-btn.active {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.12) 0%, rgba(6, 182, 212, 0.06) 100%);
    color: var(--primary);
}

.filter-checkbox-btn svg {
    flex-shrink: 0;
}

.filter-remove-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-left: 4px;
    border-radius: 50%;
    background: var(--muted);
    color: var(--muted-foreground);
    text-decoration: none;
    font-size: 14px;
    line-height: 1;
    transition: all 0.15s ease;
}

.filter-remove-btn:hover {
    background: var(--destructive);
    color: white;
}

.filter-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 200px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    display: none;
    padding: 8px 0;
    color: var(--foreground);
}

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

.filter-dropdown-menu.right {
    left: auto;
    right: 0;
}

.filter-menu-section {
    padding: 8px 12px;
}

.filter-menu-section label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--foreground-muted);
    margin-bottom: 6px;
}

.filter-menu-input {
    width: 100%;
    padding: 8px 10px;
    font-size: 0.875rem;
    background: var(--background);
    border: 1px solid var(--input);
    border-radius: var(--radius-sm);
    color: var(--foreground);
}

.filter-menu-input:focus {
    outline: none;
    border-color: var(--primary);
}

.filter-menu-footer {
    padding: 8px 12px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
}

/* Category checkbox list in dropdown */
.filter-checkbox-list {
    max-height: 250px;
    overflow-y: auto;
    padding: 4px 0;
}

/* Filter dropdown anchor items (used by adult filter and similar option lists) */
.filter-menu-item {
    display: block;
    padding: 8px 12px;
    text-decoration: none;
    color: var(--foreground);
    transition: background 0.1s ease;
}
.filter-menu-item:hover {
    background: var(--secondary);
}
.filter-menu-item.selected {
    background: var(--primary-light);
}
.filter-menu-item-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.filter-menu-item-label {
    color: var(--foreground);
    font-size: 0.875rem;
    font-weight: 500;
}
.filter-menu-item.selected .filter-menu-item-label {
    color: var(--primary);
    font-weight: 600;
}
.filter-menu-item-desc {
    font-size: 0.75rem;
    color: var(--foreground-muted);
    margin-top: 0.125rem;
}
.filter-menu-badge-adult {
    background: #ef4444;
    color: white;
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    font-size: 0.65rem;
    font-weight: 600;
}

.filter-checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.1s ease;
}

.filter-checkbox-item:hover {
    background: var(--secondary);
}

.filter-checkbox-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 500;
}

.filter-checkbox-item.active span {
    color: var(--primary);
}

.filter-checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

.filter-checkbox-item span {
    font-size: 0.875rem;
    color: var(--foreground);
}

/* Country selector button (prominent) */
.country-selector {
    position: relative;
}

.country-selector-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    font-size: 0.9375rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    border: none;
    border-radius: 9999px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.country-selector-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.country-selector-btn .globe-icon {
    width: 20px;
    height: 20px;
}

.country-selector-btn .arrow {
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}

.country-selector.open .country-selector-btn .arrow {
    transform: rotate(180deg);
}

.country-selector-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 180px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    display: none;
    padding: 8px 0;
    color: var(--foreground);
}

.country-selector.open .country-selector-menu {
    display: block;
}

.country-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    font-size: 0.875rem;
    color: var(--foreground);
    text-decoration: none;
    transition: background 0.1s ease;
}

.country-menu-item:hover {
    background: var(--muted);
}

.country-menu-item.active {
    background: rgba(14, 165, 233, 0.08);
    color: var(--primary);
    font-weight: 500;
}

.country-menu-item .flag {
    display: inline-flex;
    align-items: center;
}

/* Flag icon images from CDN */
.flag-icon {
    display: inline-block;
    vertical-align: middle;
    border-radius: 2px;
    object-fit: cover;
    margin: 1px;
}

/* Filter actions row */
.filter-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.filter-clear-btn {
    padding: 8px 14px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--muted-foreground);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s ease;
}

.filter-clear-btn:hover {
    color: var(--destructive-foreground);
    border-color: var(--destructive-foreground);
}

/* Active filter badge */
.filter-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 0.6875rem;
    font-weight: 600;
    color: white;
    background: var(--primary);
    border-radius: 9999px;
    margin-left: 4px;
}

/* Responsive filter bar */
@media (max-width: 768px) {
    /* Filter bar: 2-column compact grid */
    .filter-bar {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        align-items: stretch;
        margin-bottom: 0.5rem;
    }

    /* Filter buttons: compact, fill grid cell */
    .filter-dropdown {
        display: flex !important;
        width: 100%;
    }

    .filter-dropdown-btn,
    .country-selector-btn {
        width: 100%;
        justify-content: space-between;
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    .filter-dropdown-btn .filter-value {
        font-size: 0.75rem;
    }

    .filter-dropdown-btn .arrow {
        font-size: 0.6rem;
    }

    /* Dropdown menus: absolute, full width of parent */
    .filter-dropdown-menu,
    .country-selector-menu {
        position: absolute;
        left: 0;
        right: auto;
        width: max(200px, 100%);
        max-height: 60vh;
        overflow-y: auto;
        z-index: 200;
    }

    /* Filter actions: full width row */
    .filter-actions {
        grid-column: 1 / -1;
        margin-left: 0;
        margin-top: 4px;
        display: flex;
        gap: 6px;
    }

    .filter-actions .filter-clear-btn {
        flex: 1;
        text-align: center;
        padding: 8px;
        font-size: 0.8rem;
    }

    /* Quick filter rows: horizontal scroll */
    .quick-filters-row {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 0.5rem !important;
        padding-bottom: 4px;
    }

    .quick-filters-row::-webkit-scrollbar {
        display: none;
    }

    .quick-filters-row {
        margin-top: 0.4rem !important;
        padding-top: 0.4rem !important;
    }

    .quick-filters-row > span:first-child {
        display: none;
    }

    .quick-filters-row span {
        white-space: nowrap;
        font-size: 0.7rem !important;
        flex-shrink: 0;
    }

    .quick-filters-row .filter-checkbox-btn {
        padding: 8px 14px;
        font-size: 0.8125rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* Country selector: full width */
    .country-selector {
        grid-column: 1 / -1;
    }
}

/* Extra small screens: single column filters */
@media (max-width: 400px) {
    .filter-bar {
        grid-template-columns: 1fr;
    }
}

/* ========== Mobile Table ========== */
/* Columns: 1=#, 2=Domain(+category), 3=Age, 4=Traffic, 5=Value, 6=G&V, 7=GrowthScore, 8=Keywords, 9=Top3, 10=DA, 11=DR, 12=TF */
@media (max-width: 768px) {
    /* Horizontal scroll for extra columns */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table {
        min-width: 580px;
    }

    /* Compact all cells */
    .table th, .table td {
        padding: 7px 4px;
        font-size: 0.72rem;
        white-space: nowrap;
    }

    .table th {
        font-size: 0.6rem;
    }

    /* # column: narrow */
    .table th:nth-child(1), .table td:nth-child(1) {
        padding: 7px 3px;
        width: 22px;
    }

    /* Domain column: constrained so key data fits on screen */
    .table th:nth-child(2), .table td:nth-child(2) {
        max-width: 120px;
        white-space: normal;
    }

    .table td:nth-child(2) .domain-name {
        font-size: 0.72rem;
        word-break: break-all;
        line-height: 1.3;
    }

    /* Hide external links, flags on mobile */
    .table td:nth-child(2) .domain-link,
    .table td:nth-child(2) .domain-kw-link {
        display: none;
    }

    .table td:nth-child(2) .flag-icon {
        display: none;
    }

    /* Category badge: below domain on mobile */
    .table td:nth-child(2) .category-badge-inline {
        display: flex;
        width: fit-content;
        margin-left: 0;
        margin-top: 3px;
        font-size: 0.5625rem;
        padding: 2px 5px;
        gap: 3px;
    }

    .table td:nth-child(2) .category-badge svg {
        display: none;
    }
}
