/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Color Palette */
    --bg-primary: #0f0c29;
    --bg-secondary: #302b63;
    --bg-tertiary: #24243e;
    --accent-primary: #667eea;
    --accent-secondary: #764ba2;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;

    /* Text Colors */
    --text-primary: #ffffff;
    --text-secondary: #a0aec0;
    --text-muted: #718096;

    /* Glass Effect */
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.3);

    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 50%, var(--bg-tertiary) 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 2rem 1rem;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Header */
.header {
    margin-bottom: 3rem;
    animation: fadeInDown 0.6s ease;
}

.title {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
    text-align: center;
}

.subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    font-weight: 300;
    text-align: center;
}

.back-link {
    display: block;
    text-align: center;
}

/* Tool Cards */
.tool-card {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 0;
    margin-bottom: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    transition: all var(--transition-normal);
}

.tool-card:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 12px 48px rgba(139, 92, 246, 0.15);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2rem;
    cursor: pointer;
    user-select: none;
}

.card-header:hover {
    background: rgba(255, 255, 255, 0.03);
}

.card-header h2 {
    margin: 0;
}

.collapse-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform var(--transition-fast);
    padding: 0.5rem;
}

.collapse-btn.collapsed {
    transform: rotate(-90deg);
}

.card-content {
    padding: 0 2rem 2rem 2rem;
    max-height: 2000px;
    overflow: hidden;
    transition: max-height var(--transition-normal), padding var(--transition-normal);
}

.card-content.collapsed {
    max-height: 0;
    padding: 0 2rem;
}

/* Card */
.card {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-lg);
    animation: fadeInUp 0.6s ease;
    transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

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

.card-title {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.card-description {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

/* Form Elements */
.form-group {
    margin-bottom: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
}

.input,
.select,
.textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    transition: all var(--transition-normal);
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.textarea {
    resize: vertical;
    font-family: 'JetBrains Mono', monospace;
    line-height: 1.5;
}

.select {
    cursor: pointer;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.75rem;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

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

/* Spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.hidden {
    display: none !important;
}

/* Progress Bar */
.progress-container {
    margin-top: 1.5rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 4px;
    transition: width var(--transition-normal);
    width: 0%;
}

.progress-text {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Results */
.results-container {
    margin-top: 2rem;
    animation: fadeInUp 0.4s ease;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.results-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.results-actions {
    display: flex;
    gap: 0.5rem;
}

.table-wrapper {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
}

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

.results-table thead {
    background: rgba(255, 255, 255, 0.08);
}

.results-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--glass-border);
}

.results-table td {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.results-table tbody tr {
    transition: background var(--transition-fast);
}

.results-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Result Type Badges */
.result-type {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    margin: 0.125rem;
}

.result-type.homepage {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.result-type.subpage {
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
}

/* Expandable Rows */
.expand-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    transition: transform var(--transition-fast);
}

.expand-btn:hover {
    color: var(--text-primary);
}

.expand-btn.expanded {
    transform: rotate(90deg);
}

.detail-row {
    background: rgba(0, 0, 0, 0.2);
}

.detail-content {
    padding: 1.5rem;
}

/* Detail Table */
.detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    overflow: hidden;
}

.detail-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    font-weight: 600;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid var(--glass-border);
}

.detail-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
}

.detail-table td:first-child {
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-secondary);
}

.detail-link {
    color: var(--accent-primary);
    text-decoration: none;
    display: block;
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.metric-cell {
    font-family: 'JetBrains Mono', monospace;
}

/* Recommendation Badge */
.recommendation {
    font-size: 0.9rem;
    text-align: center;
    font-weight: 500;
}

.recommendation.yes {
    color: var(--accent-success);
}

.recommendation.no {
    color: var(--text-secondary);
    opacity: 0.7;
}

/* Keyword Cell */
.keyword-cell {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 500;
}

/* Volume & KD Cells */
.volume-cell,
.kd-cell {
    font-family: 'JetBrains Mono', monospace;
    width: auto;
    white-space: nowrap;
    text-align: center;
    padding: 0 1rem;
}

.est-backlinks-cell {
    font-family: 'JetBrains Mono', monospace;
    width: auto;
    white-space: nowrap;
    text-align: center;
    padding: 0 1rem;
}

.kd-easy {
    color: var(--accent-success);
}

.kd-medium {
    color: var(--accent-warning);
}

.kd-hard {
    color: var(--accent-danger);
}

/* Footer */
.footer {
    text-align: center;
    margin-top: 3rem;
    padding-top: 2rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .title {
        font-size: 2rem;
    }

    .card {
        padding: 1.5rem;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .table-wrapper {
        font-size: 0.8rem;
    }

    .results-table th,
    .results-table td {
        padding: 0.75rem 0.5rem;
    }
}

/* Settings Button */
.settings-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 0.75rem;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent-primary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: linear-gradient(135deg, rgba(30, 30, 40, 0.95), rgba(20, 20, 30, 0.95));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 2rem;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.3s ease;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
}

.modal-close:hover {
    opacity: 1;
}

/* Table Horizontal & Vertical Scroll */
.domain-results {
    width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    /* Enable vertical scroll */
    max-height: 600px;
    /* Limit height to show ~10-12 rows */
    -webkit-overflow-scrolling: touch;
    margin-top: 1rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.results-table {
    width: 100%;
    min-width: 1000px;
    border-collapse: separate;
    /* Required for sticky header */
    border-spacing: 0;
}

.results-table thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #1e1e28;
    /* Match card background */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Tooltip Styles */
.truncated-cell {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: help;
}

/* Custom Scrollbar for Results Table */
.domain-results::-webkit-scrollbar {
    height: 12px;
}

.domain-results::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
}

.domain-results::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    border: 2px solid rgba(30, 30, 40, 0.8);
    /* Match background to create padding effect */
}

.domain-results::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Refactored Table Styles (Backlinks Only) */
.domain-results .results-table th:nth-child(1) {
    width: 60px;
    text-align: center;
}

/* DR */
.domain-results .results-table th:nth-child(2) {
    width: 45%;
}

/* Referring Page */
.domain-results .results-table th:nth-child(3) {
    width: 45%;
}

/* Anchor & Target */
.domain-results .results-table th:nth-child(4) {
    width: 100px;
    text-align: center;
}

/* Vuln Check */

.cell-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
}

.cell-title {
    color: #60a5fa;
    /* Blue-400 */
    font-weight: 500;
    font-size: 0.95rem;
    text-decoration: none;
    line-height: 1.4;
}

.cell-title:hover {
    text-decoration: underline;
}

.cell-url {
    color: #34d399;
    /* Emerald-400 */
    font-size: 0.85rem;
    word-break: break-all;
    text-decoration: none;
    line-height: 1.3;
}

.cell-url:hover {
    text-decoration: underline;
}

.cell-anchor {
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.4;
}

.modal-body {
    padding: 1.5rem;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}