:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --danger-color: #dc2626;
    
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --input-bg: #ffffff;
    --input-border: #d1d5db;
    --input-focus: #2563eb;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    font-size: 14px;
}

.admin-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styles */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 1000;
    overflow-y: auto;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed {
    width: 80px;
}

.logo {
    padding: 1.5rem;
    border-bottom: 1px solid #334155;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo a {
    font-size: 1.5rem;
    font-weight: 700;
    color: #ffffff;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo .dots {
    color: var(--primary-light);
    animation: pulse 2s infinite;
}

.admin-label {
    background: var(--primary-color);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar-toggle {
    position: absolute;
    top: 1.5rem;
    right: -12px;
    background: var(--primary-color);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 1001;
}

.sidebar-toggle:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
}

.sidebar nav {
    padding: 1rem 0;
}

.sidebar nav ul {
    list-style: none;
}

.sidebar nav li {
    margin: 0.25rem 1rem;
}

.sidebar nav li.nav-divider {
    height: 1px;
    background: #334155;
    margin: 1rem;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: #cbd5e1;
    text-decoration: none;
    border-radius: var(--radius);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
}

.sidebar nav a:hover {
    background: var(--sidebar-hover);
    color: #ffffff;
    transform: translateX(4px);
}

.sidebar nav li.active a {
    background: var(--primary-color);
    color: #ffffff;
    box-shadow: var(--shadow);
}

.menu-icon {
    min-width: 18px;
    height: 18px;
}

.menu-text {
    transition: opacity 0.2s;
}

.sidebar.collapsed .menu-text,
.sidebar.collapsed .admin-label {
    opacity: 0;
    display: none;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 2rem;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed + .main-content {
    margin-left: 80px;
}

h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

h1::before {
    content: '';
    width: 4px;
    height: 2rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    border-radius: 2px;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.form-container,
.table-card,
.chart-card,
.scrape-controls,
.progress-container {
    @extend .card;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-container h3,
.table-card h3,
.chart-card h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-container h3::before,
.table-card h3::before,
.chart-card h3::before {
    content: '';
    width: 3px;
    height: 1.25rem;
    background: var(--primary-color);
    border-radius: 2px;
}

/* Stats Cards */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.stat-label {
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.875rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.875rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--input-border);
    border-radius: var(--radius);
    background: var(--input-bg);
    color: var(--text-color);
    font-size: 0.875rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
}

.form-group input:disabled,
.form-group select:disabled {
    background: #f3f4f6;
    color: var(--text-muted);
    cursor: not-allowed;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.875rem;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.primary-btn,
.btn-primary {
    background: var(--primary-color);
    color: white;
}

.primary-btn:hover:not(:disabled),
.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.secondary-btn {
    background: var(--secondary-color);
    color: white;
}

.secondary-btn:hover:not(:disabled) {
    background: #475569;
    transform: translateY(-1px);
}

.danger-btn {
    background: var(--danger-color);
    color: white;
}

.danger-btn:hover:not(:disabled) {
    background: #b91c1c;
    transform: translateY(-1px);
}

.small-btn {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
}

.btn-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
}

table thead {
    background: #f8fafc;
}

table th,
table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
}

table th {
    font-weight: 600;
    color: var(--text-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.75rem;
}

table tbody tr {
    transition: background-color 0.2s;
}

table tbody tr:hover {
    background: #f8fafc;
}

table a {
    color: var(--primary-color);
    text-decoration: none;
}

table a:hover {
    text-decoration: underline;
}

/* Progress */
.progress-container {
    background: var(--card-bg);
}

.progress-bar-container {
    margin-bottom: 1.5rem;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-color);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.status-container {
    display: grid;
    gap: 0.75rem;
}

.status-item {
    display: flex;
    justify-content: space-between;
    padding: 0.75rem;
    background: #f8fafc;
    border-radius: var(--radius);
    border-left: 4px solid var(--primary-color);
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.alert.success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert.error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert.warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fed7aa;
}

/* Search Results */
.result-card {
    background: var(--card-bg);
    padding: 1.5rem;
    margin-bottom: 1rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}

.result-card:hover {
    box-shadow: var(--shadow-md);
}

.accuracy-score {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}

.high-relevance {
    background: var(--success-color);
}

.medium-relevance {
    background: var(--warning-color);
}

.low-relevance {
    background: var(--error-color);
}

/* Search Details */
.search-details {
    background: #f8fafc;
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    margin: 1.5rem 0;
    border: 1px solid var(--border-color);
}

.search-detail-item {
    margin-bottom: 1rem;
}

.search-detail-item:last-child {
    margin-bottom: 0;
}

.search-detail-item ul {
    margin-left: 1.5rem;
    margin-top: 0.5rem;
}

.search-detail-item li {
    margin-bottom: 0.25rem;
}

/* Scrape Logs */
.scrape-log {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    margin: 1rem 0;
    border-left: 4px solid var(--primary-color);
    max-height: 400px;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.scrape-log h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.scrape-log .success {
    color: var(--success-color);
}

.scrape-log .error {
    color: var(--error-color);
}

.scrape-log .warning {
    color: var(--warning-color);
}

.scrape-log .summary {
    color: var(--primary-color);
    font-weight: 600;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Enhanced Scrape Logs */
.scrape-container {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin: 2rem 0;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

.scrape-container h2 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.scrape-log {
    background: #f8fafc;
    padding: 1.5rem;
    border-radius: var(--radius);
    margin: 1rem 0;
    border-left: 4px solid var(--primary-color);
    max-height: 600px;
    overflow-y: auto;
    box-shadow: var(--shadow);
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.4;
}

.scrape-log h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.125rem;
    font-weight: 600;
}

.scrape-log h4 {
    color: var(--text-color);
    margin: 1rem 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 600;
}

.scrape-log p {
    margin: 0.25rem 0;
    padding: 0.25rem 0;
}

.scrape-log .success {
    color: var(--success-color);
    font-weight: 500;
}

.scrape-log .error {
    color: var(--error-color);
    font-weight: 500;
}

.scrape-log .warning {
    color: var(--warning-color);
    font-weight: 500;
}

.scrape-log .summary {
    background: #e0f2fe;
    padding: 1rem;
    border-radius: var(--radius-sm);
    margin-top: 1rem;
    border: 1px solid #b3e5fc;
}

.scrape-log .summary h4 {
    color: var(--primary-color);
    margin-top: 0;
}

.scrape-log .summary ul {
    margin: 0.5rem 0 0 1.5rem;
}

.scrape-log .summary li {
    margin: 0.25rem 0;
}

/* Progress indicators */
.scrape-log p[class*="success"]::before { content: ""; }
.scrape-log p[class*="error"]::before { content: ""; }
.scrape-log p[class*="warning"]::before { content: ""; }

/* Responsive Design */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .stats-container {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 1rem;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    .btn-group .btn {
        width: 100%;
    }
    
    .stats-container {
        grid-template-columns: 1fr;
    }
    
    table {
        font-size: 0.75rem;
    }
    
    table th,
    table td {
        padding: 0.5rem;
    }
    
    .summary-stats {
        grid-template-columns: 1fr;
    }
    
    .result-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .result-badges {
        width: 100%;
        justify-content: flex-start;
    }
    
    .table-responsive {
        font-size: 0.75rem;
    }
    
    .url-cell,
    .website-cell,
    .headings-preview {
        max-width: none;
    }
    
    table th,
    table td {
        padding: 0.5rem;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    .btn-group .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .empty-state {
        padding: 2rem 1rem;
    }
    
    .empty-state-content svg {
        width: 32px;
        height: 32px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #0f172a;
        --card-bg: #1e293b;
        --text-color: #f1f5f9;
        --text-muted: #94a3b8;
        --border-color: #334155;
        --input-bg: #1e293b;
        --input-border: #475569;
    }
    
    table thead {
        background: #334155;
    }
    
    table tbody tr:hover {
        background: #334155;
    }
    
    .search-details {
        background: #334155;
    }
    
    .status-item {
        background: #334155;
    }
}

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mt-4 { margin-top: 1rem; }
.hidden { display: none; }
