/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --bg-color: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #475569;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.2);
    --radius: 12px;
    --radius-sm: 8px;
}

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

/* Base Styles */
html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    text-align: center;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-color) 100%);
    border-bottom: 1px solid var(--border-color);
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.logo {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Input Section */
.input-section {
    margin-bottom: 2rem;
}

.input-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.input-group {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.input-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.input-type-toggle {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.toggle-btn {
    flex: 1;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.toggle-btn:hover {
    background: var(--bg-color);
}

.toggle-btn.active {
    background: var(--primary-color);
    color: var(--text-primary);
    border-color: var(--primary-color);
}

.url-input, .html-input {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

.url-input:focus, .html-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.html-input {
    min-height: 150px;
    resize: vertical;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
}

.hidden {
    display: none !important;
}

/* Compare Button */
.compare-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--text-primary);
    border: none;
    border-radius: var(--radius);
    font-size: 1.125rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: var(--shadow);
}

.compare-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.compare-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.btn-loader {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Results Section */
.results-section {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Overall Score */
.overall-score {
    text-align: center;
    padding: 2rem;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.score-circle {
    width: 180px;
    height: 180px;
    margin: 0 auto 1rem;
    position: relative;
}

.score-circle svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.score-bg {
    fill: none;
    stroke: var(--bg-card);
    stroke-width: 8;
}

.score-progress {
    fill: none;
    stroke: url(#gradient);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 283;
    transition: stroke-dashoffset 1s ease;
}

.score-circle svg {
    filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.3));
}

.score-circle svg defs {
    display: block;
}

.score-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
    font-weight: 700;
}

.overall-score h2 {
    color: var(--text-secondary);
    font-size: 1.125rem;
    font-weight: 500;
}

/* Score Breakdown */
.score-breakdown {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.score-card {
    background: var(--bg-secondary);
    padding: 1.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.score-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.score-icon {
    font-size: 1.25rem;
}

.score-card h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.score-bar {
    height: 8px;
    background: var(--bg-card);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.score-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 4px;
    width: 0%;
    transition: width 0.8s ease;
}

.score-percent {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-size: 0.875rem;
    font-weight: 500;
}

.tab-btn:hover {
    background: var(--bg-card);
}

.tab-btn.active {
    background: var(--primary-color);
    color: var(--text-primary);
    border-color: var(--primary-color);
}

/* Tab Content */
.tab-content {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.tab-panel h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

/* Differences List */
.differences-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.difference-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--warning-color);
}

.difference-item.added {
    border-left-color: var(--success-color);
}

.difference-item.removed {
    border-left-color: var(--error-color);
}

.difference-item.changed {
    border-left-color: var(--warning-color);
}

.difference-icon {
    font-size: 1.25rem;
}

.difference-content {
    flex: 1;
}

.difference-type {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.difference-text {
    color: var(--text-primary);
    font-size: 0.875rem;
}

/* Comparison View */
.comparison-view {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.comparison-column {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.comparison-column h4 {
    padding: 0.75rem 1rem;
    background: var(--bg-color);
    font-size: 0.875rem;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
}

.content-display, .structure-display, .images-display {
    padding: 1rem;
    max-height: 400px;
    overflow-y: auto;
    font-size: 0.875rem;
}

.content-display {
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.8;
}

/* Highlighted text */
.highlight-added {
    background: rgba(16, 185, 129, 0.2);
    padding: 0.125rem 0.25rem;
    border-radius: 2px;
}

.highlight-removed {
    background: rgba(239, 68, 68, 0.2);
    padding: 0.125rem 0.25rem;
    border-radius: 2px;
    text-decoration: line-through;
}

.highlight-changed {
    background: rgba(245, 158, 11, 0.2);
    padding: 0.125rem 0.25rem;
    border-radius: 2px;
}

/* Structure Display */
.structure-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    margin-bottom: 0.25rem;
    border-radius: var(--radius-sm);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.8125rem;
}

.structure-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.structure-tag {
    color: var(--primary-color);
}

.structure-count {
    background: var(--bg-secondary);
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Images Display */
.images-display {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.5rem;
}

.image-item {
    aspect-ratio: 1;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid transparent;
    transition: border-color 0.2s ease;
}

.image-item.matched {
    border-color: var(--success-color);
}

.image-item img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.image-placeholder {
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-align: center;
    padding: 0.5rem;
    word-break: break-all;
}

/* Matching Images */
.matching-images {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.matching-images h4 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.matching-images-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.matching-image-pair {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
}

.matching-image-pair img {
    width: 60px;
    height: 60px;
    object-fit: contain;
    background: var(--bg-secondary);
    border-radius: 4px;
}

.match-indicator {
    color: var(--success-color);
    font-size: 1.25rem;
}

.no-matches {
    color: var(--text-secondary);
    font-style: italic;
}

/* Error Section */
.error-section {
    text-align: center;
    padding: 3rem;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--error-color);
}

.error-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
}

.error-content h3 {
    color: var(--error-color);
    margin-bottom: 0.5rem;
}

.error-content p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.retry-btn {
    padding: 0.75rem 1.5rem;
    background: var(--error-color);
    color: var(--text-primary);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    transition: opacity 0.2s ease;
}

.retry-btn:hover {
    opacity: 0.9;
}

/* Footer */
.footer {
    text-align: center;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.footer p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.footer a:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

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

::-webkit-scrollbar-track {
    background: var(--bg-card);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .score-breakdown {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 1.5rem;
    }

    .input-container {
        grid-template-columns: 1fr;
    }

    .comparison-view {
        grid-template-columns: 1fr;
    }

    .score-breakdown {
        grid-template-columns: 1fr 1fr;
    }

    .tabs {
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .tab-btn {
        padding: 0.625rem 1rem;
        font-size: 0.8125rem;
    }

    .score-circle {
        width: 150px;
        height: 150px;
    }

    .score-value {
        font-size: 2rem;
    }
}

@media (max-width: 480px) {
    .main-content {
        padding: 1rem;
    }

    .input-group {
        padding: 1rem;
    }

    .score-breakdown {
        grid-template-columns: 1fr;
    }

    .logo-container {
        flex-direction: column;
        gap: 0.5rem;
    }

    .header h1 {
        font-size: 1.25rem;
    }

    .tagline {
        font-size: 0.875rem;
    }

    .compare-btn {
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }
}

/* Print Styles */
@media print {
    .input-section,
    .tabs,
    .footer {
        display: none;
    }

    .results-section {
        display: block !important;
    }

    .tab-panel {
        display: block !important;
        page-break-inside: avoid;
    }
}
