/* CSS Variables */
:root {
    --primary-color: #3b82f6;
    --primary-dark: #2563eb;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-elevated: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #334155;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s ease;
}

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

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

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

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

/* Header */
.header {
    text-align: center;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, var(--surface) 0%, var(--background) 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: 1.75rem;
    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;
    padding: 2rem 1rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

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

.input-wrapper {
    display: flex;
    gap: 0.75rem;
    max-width: 700px;
    margin: 0 auto;
}

.url-input {
    flex: 1;
    padding: 1rem 1.25rem;
    font-size: 1rem;
    background: var(--surface);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    transition: var(--transition);
}

.url-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.url-input::placeholder {
    color: var(--text-muted);
}

.analyze-btn {
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border: none;
    border-radius: var(--radius);
    color: white;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

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

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

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

.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.8s linear infinite;
    margin-right: 0.5rem;
    vertical-align: middle;
}

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

.input-hint {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 0.75rem;
}

/* Results Container */
.results-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Section Styling */
.results-container section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.results-container h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.metric-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--surface-elevated);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.metric-icon {
    font-size: 2rem;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background);
    border-radius: var(--radius-sm);
}

.metric-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.metric-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.metric-status {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.metric-status.good {
    background: var(--success-color);
    box-shadow: 0 0 8px var(--success-color);
}

.metric-status.needs-improvement {
    background: var(--warning-color);
    box-shadow: 0 0 8px var(--warning-color);
}

.metric-status.poor {
    background: var(--danger-color);
    box-shadow: 0 0 8px var(--danger-color);
}

/* Timeline Section */
.timeline-container {
    background: var(--background);
    border-radius: var(--radius-sm);
    padding: 1.5rem;
}

.timeline-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.timeline-track {
    position: relative;
    height: 200px;
    background: var(--surface-elevated);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 1rem;
}

.timeline-event {
    position: absolute;
    height: 30px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    padding: 0 8px;
    font-size: 0.75rem;
    color: white;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: var(--transition);
    cursor: pointer;
}

.timeline-event:hover {
    transform: scaleY(1.1);
    z-index: 10;
}

.timeline-event .event-time {
    margin-left: auto;
    opacity: 0.8;
    font-size: 0.65rem;
}

.timeline-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
}

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

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

/* Resource Section */
.resource-chart-container {
    height: 250px;
    margin-bottom: 1rem;
}

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

.resource-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--surface-elevated);
    border-radius: var(--radius-sm);
}

.resource-type {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.resource-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

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

.resource-value {
    font-weight: 600;
    color: var(--text-primary);
}

/* Issues Section */
.issues-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.issue-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    background: var(--surface-elevated);
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--danger-color);
}

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

.issue-item.info {
    border-left-color: var(--primary-color);
}

.issue-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.issue-content {
    flex: 1;
}

.issue-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

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

.no-issues {
    text-align: center;
    padding: 2rem;
    color: var(--success-color);
}

.no-issues .check-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

/* Suggestions Section */
.suggestions-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.suggestion-item {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    background: var(--surface-elevated);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.suggestion-item:hover {
    background: var(--background);
}

.suggestion-priority {
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    flex-shrink: 0;
}

.suggestion-priority.high {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger-color);
}

.suggestion-priority.medium {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning-color);
}

.suggestion-priority.low {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success-color);
}

.suggestion-content {
    flex: 1;
}

.suggestion-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

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

/* History Section */
.history-chart-container {
    height: 200px;
    margin-bottom: 1rem;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--surface-elevated);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.history-item:hover {
    background: var(--background);
}

.history-url {
    font-size: 0.875rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

.history-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.history-score {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 600;
}

.history-score.good {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success-color);
}

.history-score.needs-improvement {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning-color);
}

.history-score.poor {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger-color);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.features-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    max-width: 600px;
    margin: 0 auto;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--surface);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
}

.feature-icon {
    font-size: 1.5rem;
}

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

.footer a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
}

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

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 1rem 1.5rem;
    background: var(--surface-elevated);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    color: var(--text-primary);
    font-size: 0.875rem;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.error {
    border-left: 4px solid var(--danger-color);
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

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

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

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

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

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        padding: 1.5rem 1rem;
    }

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

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

    .input-wrapper {
        flex-direction: column;
    }

    .analyze-btn {
        width: 100%;
    }

    .main-content {
        padding: 1rem;
    }

    .results-container section {
        padding: 1rem;
    }

    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .metric-card {
        padding: 1rem;
    }

    .metric-icon {
        width: 48px;
        height: 48px;
        font-size: 1.5rem;
    }

    .metric-value {
        font-size: 1.25rem;
    }

    .timeline-track {
        height: 250px;
    }

    .timeline-legend {
        gap: 0.5rem;
        font-size: 0.75rem;
    }

    .resource-details {
        grid-template-columns: 1fr;
    }

    .history-url {
        max-width: 150px;
    }

    .features-list {
        grid-template-columns: 1fr;
    }
}

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

    .tagline {
        font-size: 0.875rem;
    }

    .url-input {
        padding: 0.875rem 1rem;
        font-size: 0.875rem;
    }

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

    .results-container h2 {
        font-size: 1.1rem;
    }

    .empty-icon {
        font-size: 3rem;
    }

    .empty-state h3 {
        font-size: 1.25rem;
    }
}

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

.results-container section {
    animation: fadeIn 0.3s ease forwards;
}

.results-container section:nth-child(2) { animation-delay: 0.1s; }
.results-container section:nth-child(3) { animation-delay: 0.2s; }
.results-container section:nth-child(4) { animation-delay: 0.3s; }
.results-container section:nth-child(5) { animation-delay: 0.4s; }
.results-container section:nth-child(6) { animation-delay: 0.5s; }

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

    .results-container {
        display: block;
    }

    .results-container section {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
