/* CSS Variables for theming */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --background-color: #0f172a;
    --surface-color: #1e293b;
    --surface-hover: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --gradient-start: #6366f1;
    --gradient-end: #8b5cf6;
}

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

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

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

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

/* Header styles */
.header {
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    padding: 2rem;
    text-align: center;
    box-shadow: 0 4px 20px var(--shadow-color);
}

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

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

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.tagline {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    margin-top: 0.5rem;
}

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

/* Section styles */
section {
    margin-bottom: 2rem;
}

section h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Input section */
.input-section {
    background-color: var(--surface-color);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 12px var(--shadow-color);
}

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

.language-select {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.language-select label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.language-select select {
    background-color: var(--surface-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.language-select select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.code-input-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#code-input {
    width: 100%;
    min-height: 300px;
    background-color: var(--background-color);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#code-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

#code-input::placeholder {
    color: var(--text-secondary);
}

.input-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Button styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-icon {
    font-size: 1.1rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

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

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

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

/* Results section */
.results-section {
    background-color: var(--surface-color);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 12px var(--shadow-color);
}

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

.metric-card {
    background-color: var(--background-color);
    border-radius: 10px;
    padding: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.metric-icon {
    font-size: 2rem;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    border-radius: 10px;
}

.metric-content {
    flex: 1;
    min-width: 120px;
}

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

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

.metric-bar {
    width: 100%;
    height: 6px;
    background-color: var(--surface-hover);
    border-radius: 3px;
    overflow: hidden;
}

.metric-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease, background-color 0.3s;
    width: 0%;
}

.metric-bar-fill.excellent {
    background: linear-gradient(90deg, #22c55e, #4ade80);
}

.metric-bar-fill.good {
    background: linear-gradient(90deg, #84cc16, #a3e635);
}

.metric-bar-fill.moderate {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.metric-bar-fill.poor {
    background: linear-gradient(90deg, #f97316, #fb923c);
}

.metric-bar-fill.critical {
    background: linear-gradient(90deg, #ef4444, #f87171);
}

/* Detailed metrics */
.detailed-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.details-panel,
.visualization-panel {
    background-color: var(--background-color);
    border-radius: 10px;
    padding: 1.25rem;
    border: 1px solid var(--border-color);
}

.details-panel h3,
.visualization-panel h3,
.suggestions-panel h3,
.code-issues-panel h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

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

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.detail-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.detail-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Chart container */
.chart-container {
    position: relative;
    width: 100%;
    height: 250px;
}

#complexity-chart {
    width: 100% !important;
    height: 100% !important;
}

/* Suggestions panel */
.suggestions-panel,
.code-issues-panel {
    background-color: var(--background-color);
    border-radius: 10px;
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.suggestions-list,
.issues-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

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

.suggestion-item,
.issue-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    background-color: var(--surface-color);
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
}

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

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

.suggestion-icon,
.issue-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.suggestion-content,
.issue-content {
    flex: 1;
}

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

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

/* Score colors */
.score-excellent {
    color: #22c55e !important;
}

.score-good {
    color: #84cc16 !important;
}

.score-moderate {
    color: #f59e0b !important;
}

.score-poor {
    color: #f97316 !important;
}

.score-critical {
    color: #ef4444 !important;
}

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

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

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

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

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

.fade-in {
    animation: fadeIn 0.3s ease forwards;
}

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

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

    .logo {
        width: 36px;
        height: 36px;
    }

    .tagline {
        font-size: 0.9rem;
    }

    .main-content {
        padding: 1rem;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    #code-input {
        min-height: 200px;
        font-size: 0.85rem;
    }

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

    .btn {
        width: 100%;
    }

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

    .metric-card {
        flex-direction: column;
        text-align: center;
    }

    .metric-content {
        width: 100%;
    }

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

    .details-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .chart-container {
        height: 200px;
    }
}

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

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

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

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

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

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

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

/* Selection styling */
::selection {
    background-color: var(--primary-color);
    color: white;
}
