* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #f5f5f5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px;
}

header {
    margin-bottom: 50px;
    padding: 30px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-content > div {
    text-align: center;
    flex: 1;
}

header h1 {
    font-size: 2.5em;
    color: #2c3e50;
    margin-bottom: 8px;
}

.theme-toggle-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.theme-label {
    font-size: 0.75em;
    color: #7f8c8d;
    font-weight: 500;
}

.theme-toggle {
    background: transparent;
    border: 2px solid #ddd;
    padding: 10px 14px;
    font-size: 1.5em;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s;
}

.theme-toggle:hover {
    background: #f0f0f0;
    border-color: #3498db;
}

.subtitle {
    color: #7f8c8d;
    margin-top: 0;
    font-size: 1.1em;
}

main {
    display: grid;
    gap: 40px;
}

section {
    background: white;
    padding: 35px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

section > p {
    margin-bottom: 20px;
    color: #555;
}

h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    border-bottom: 2px solid #3498db;
    padding-bottom: 12px;
    font-size: 1.75em;
}

.metrics-label {
    display: block;
    font-weight: 500;
    margin-bottom: 10px;
    margin-top: 15px;
    color: #2c3e50;
}

textarea {
    width: 100%;
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    margin-bottom: 8px;
    resize: vertical;
}

.textarea-helper {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 20px;
}

textarea:focus {
    outline: none;
    border-color: #3498db;
}

button {
    background: #3498db;
    color: white;
    padding: 14px 32px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

button:hover {
    background: #2980b9;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
}

button:disabled {
    background: #95a5a6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.secondary-button {
    background: transparent;
    color: #3498db;
    border: 2px solid #3498db;
    padding: 10px 18px;
    font-size: 14px;
}

.secondary-button:hover {
    background: #3498db;
    color: white;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-top: 25px;
}

.loading-indicator {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: #e8f4f8;
    border-radius: 4px;
    border: 2px solid #3498db;
}

.loading-indicator.htmx-request {
    display: flex !important;
}

form.htmx-request .loading-indicator {
    display: flex !important;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid #e8f4f8;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-indicator span {
    color: #2c3e50;
    font-weight: 500;
}

.results-container {
    margin-top: 35px;
}

.results-placeholder {
    padding: 40px;
    text-align: center;
    color: #7f8c8d;
    background: #f8f9fa;
    border: 2px dashed #ddd;
    border-radius: 8px;
    font-style: italic;
    font-size: 1.05em;
}

.evaluation-result {
    padding: 25px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 5px solid #3498db;
}

.verdict {
    padding: 18px 20px;
    border-radius: 6px;
    margin-bottom: 25px;
    font-weight: 600;
    font-size: 1.1em;
}

.verdict-good {
    background: #d4edda;
    color: #155724;
    border-left: 5px solid #28a745;
}

.verdict-needs {
    background: #fff3cd;
    color: #856404;
    border-left: 5px solid #ffc107;
}

.verdict-poor {
    background: #f8d7da;
    color: #721c24;
    border-left: 5px solid #dc3545;
}

.metric-display pre,
.improved-code {
    background: #2c3e50;
    color: #ecf0f1;
    padding: 15px;
    border-radius: 4px;
    overflow-x: auto;
    font-size: 14px;
}

.cardinality-section,
.issues-section,
.recommendations-section,
.improved-section {
    margin: 25px 0;
}

.cardinality-section h3,
.issues-section h3,
.recommendations-section h3,
.improved-section h3 {
    margin-bottom: 12px;
    font-size: 1.2em;
}

.issues-section ul,
.recommendations-section ul {
    list-style: none;
    padding-left: 0;
}

.issue {
    padding: 10px 12px;
    margin: 8px 0;
    background: #fee;
    border-left: 4px solid #e74c3c;
    border-radius: 4px;
}

.recommendation {
    padding: 10px 12px;
    margin: 8px 0;
    background: #e8f4f8;
    border-left: 4px solid #3498db;
    border-radius: 4px;
}

.raw-response {
    margin-top: 20px;
    cursor: pointer;
}

.raw-response summary {
    font-weight: bold;
    padding: 10px;
    background: #ecf0f1;
    border-radius: 4px;
}

.raw-response pre {
    margin-top: 10px;
    padding: 15px;
    background: #2c3e50;
    color: #ecf0f1;
    border-radius: 4px;
    overflow-x: auto;
}

.examples-grid {
    display: grid;
    gap: 25px;
    margin-top: 10px;
}

.example-card {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 25px;
    background: white;
    transition: box-shadow 0.2s ease;
}

.example-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.example-header {
    margin-bottom: 18px;
}

.example-verdict {
    display: inline-block;
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 14px;
}

.verdict-good .example-verdict {
    background: #28a745;
    color: white;
}

.verdict-needs .example-verdict {
    background: #ffc107;
    color: #333;
}

.verdict-poor .example-verdict {
    background: #dc3545;
    color: white;
}

.example-metric pre {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 4px;
    font-size: 13px;
    margin: 10px 0;
}

.example-analysis {
    margin: 15px 0;
    padding: 10px;
    background: #e8f4f8;
    border-radius: 4px;
}

.example-issues ul,
.example-recommendations ul {
    margin-top: 10px;
    padding-left: 20px;
}

.error-result {
    padding: 20px;
    background: #f8d7da;
    color: #721c24;
    border-left: 4px solid #dc3545;
    border-radius: 4px;
}

footer {
    text-align: center;
    margin-top: 60px;
    padding: 30px 20px;
    color: #7f8c8d;
    font-size: 0.95em;
}

@media (max-width: 768px) {
    .container {
        padding: 20px 15px;
    }

    header {
        padding: 25px 20px;
        margin-bottom: 35px;
    }

    header h1 {
        font-size: 2em;
    }

    section {
        padding: 25px 20px;
    }

    h2 {
        font-size: 1.5em;
    }

    button {
        padding: 12px 24px;
    }

    .form-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }

    .form-actions button {
        width: 100%;
    }

    .loading-indicator {
        justify-content: center;
    }
}

/* Dark Mode */
body.dark-mode {
    background: #0d1117;
    color: #f0f0f0;
}

body.dark-mode header,
body.dark-mode section,
body.dark-mode .example-card {
    background: #1c2128;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

body.dark-mode header h1,
body.dark-mode h2 {
    color: #f0f0f0;
}

body.dark-mode p {
    color: #c9d1d9;
}

body.dark-mode section > p {
    color: #c9d1d9;
}

body.dark-mode h2 {
    border-bottom-color: #58a6ff;
}

body.dark-mode .subtitle,
body.dark-mode footer {
    color: #c9d1d9;
}

body.dark-mode .theme-toggle {
    border-color: #444c56;
    color: #f0f0f0;
}

body.dark-mode .theme-toggle:hover {
    background: #2d333b;
    border-color: #58a6ff;
}

body.dark-mode .theme-label {
    color: #8b949e;
}

body.dark-mode .metrics-label {
    color: #f0f0f0;
}

body.dark-mode textarea {
    background: #0d1117;
    color: #f0f0f0;
    border-color: #444c56;
}

body.dark-mode textarea::placeholder {
    color: #8b949e;
}

body.dark-mode textarea:focus {
    border-color: #58a6ff;
}

body.dark-mode .results-placeholder {
    background: #0d1117;
    color: #8b949e;
    border-color: #444c56;
}

body.dark-mode .evaluation-result {
    background: #0d1117;
}

body.dark-mode .loading-indicator {
    background: #0d1117;
    border-color: #58a6ff;
}

body.dark-mode .loading-indicator span {
    color: #f0f0f0;
}

body.dark-mode .spinner {
    border-color: #0d1117;
    border-top-color: #58a6ff;
}

body.dark-mode .issue {
    background: #3d1f1f;
    border-left-color: #f85149;
    color: #ffa198;
}

body.dark-mode .recommendation {
    background: #1f3a52;
    border-left-color: #58a6ff;
    color: #a5d6ff;
}

body.dark-mode .raw-response summary {
    background: #2d333b;
    color: #f0f0f0;
}

body.dark-mode .example-metric pre {
    background: #0d1117;
    color: #f0f0f0;
}

body.dark-mode .example-analysis {
    background: #1f3a52;
    color: #f0f0f0;
}

body.dark-mode .example-card {
    border-color: #444c56;
}

body.dark-mode .error-result {
    background: #3d1f1f;
    color: #ffa198;
}

body.dark-mode .secondary-button {
    color: #58a6ff;
    border-color: #58a6ff;
}

body.dark-mode .secondary-button:hover {
    background: #58a6ff;
    color: #0d1117;
}
