/* CSS Scope Visualizer - Styles */

/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --background: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --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: 8px;
    --radius-lg: 12px;
    --transition: all 0.2s ease;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --background: #0f172a;
        --surface: #1e293b;
        --border: #334155;
        --text-primary: #f1f5f9;
        --text-secondary: #94a3b8;
        --text-muted: #64748b;
    }
}

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

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
    width: 100%;
}

/* Header */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1.5rem 0;
    box-shadow: var(--shadow-sm);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-img {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.tagline {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem 0;
}

/* Panels Grid */
.panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 900px) {
    .panels {
        grid-template-columns: 1fr;
    }
}

/* Panel Styles */
.panel {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--background);
}

.panel-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.panel-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.panel-content {
    padding: 0;
}

.panel-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    background: var(--background);
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Textarea */
textarea {
    width: 100%;
    min-height: 200px;
    padding: 1rem 1.25rem;
    border: none;
    background: var(--surface);
    color: var(--text-primary);
    font-family: 'Fira Code', 'Monaco', 'Consolas', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
    resize: vertical;
}

textarea:focus {
    outline: none;
    background: var(--surface);
}

textarea::placeholder {
    color: var(--text-muted);
}

/* Input */
input[type="text"] {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: var(--transition);
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

input[type="text"]::placeholder {
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

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

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

.btn-secondary {
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

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

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
}

/* Preview Section */
.preview-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    display: none;
}

.preview-section.visible {
    display: block;
}

.preview-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.match-count {
    font-size: 0.875rem;
    color: var(--primary-color);
    font-weight: 500;
}

.preview-container {
    padding: 1rem;
    background: white;
    min-height: 200px;
}

#previewFrame {
    width: 100%;
    min-height: 200px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: white;
}

/* Results Section */
.results-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.selector-list {
    padding: 1rem 1.25rem;
    max-height: 400px;
    overflow-y: auto;
}

.placeholder-text {
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    padding: 2rem;
}

/* Selector Card */
.selector-card {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
    transition: var(--transition);
    cursor: pointer;
}

.selector-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

.selector-card.active {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.selector-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
    gap: 1rem;
}

.selector-name {
    font-family: 'Fira Code', 'Monaco', 'Consolas', monospace;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary-color);
    word-break: break-all;
}

.selector-specificity {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

.spec-badge {
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: 'Fira Code', monospace;
}

.spec-badge.inline { background: #fef3c7; color: #92400e; }
.spec-badge.ids { background: #fee2e2; color: #991b1b; }
.spec-badge.classes { background: #dbeafe; color: #1e40af; }
.spec-badge.elements { background: #dcfce7; color: #166534; }

.selector-details {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.selector-scope {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.scope-label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.scope-description {
    color: var(--text-primary);
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

/* Conflicts Panel */
.conflicts-panel {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
}

.conflicts-panel h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
}

.conflicts-list {
    max-height: 300px;
    overflow-y: auto;
}

.conflict-card {
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
}

.conflict-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--danger-color);
    margin-bottom: 0.25rem;
}

.conflict-selectors {
    font-family: 'Fira Code', monospace;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.conflict-property {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Calculator Section */
.calculator-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.calculator-content {
    padding: 1.5rem 1.25rem;
}

.calculator-input {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 600px) {
    .calculator-input {
        flex-direction: column;
    }
}

.specificity-result {
    text-align: center;
}

.specificity-display {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

@media (max-width: 500px) {
    .specificity-display {
        gap: 0.5rem;
    }
}

.specificity-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    background: var(--background);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    min-width: 70px;
}

.specificity-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    font-family: 'Fira Code', monospace;
}

.specificity-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.specificity-score {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.specificity-score strong {
    color: var(--text-primary);
    font-family: 'Fira Code', monospace;
}

/* Legend Section */
.legend-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.legend-section h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

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

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    flex-shrink: 0;
}

.legend-color.inline { background: #f59e0b; }
.legend-color.ids { background: #ef4444; }
.legend-color.classes { background: #3b82f6; }
.legend-color.elements { background: #22c55e; }

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

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

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

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

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

::-webkit-scrollbar-track {
    background: var(--background);
}

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

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

/* Highlight Styles for Preview */
.css-scope-highlight {
    outline: 2px solid var(--primary-color) !important;
    outline-offset: 2px !important;
    background-color: rgba(99, 102, 241, 0.1) !important;
}

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

.selector-card {
    animation: fadeIn 0.3s ease;
}

/* Print Styles */
@media print {
    .header, .footer, .panel-footer, button {
        display: none !important;
    }

    .main-content {
        padding: 0;
    }

    .panel, .results-section, .calculator-section {
        box-shadow: none;
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }
}
