/* ============================================================================
   Industrial Production Query App - Styles
   ============================================================================ */

:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --secondary: #64748b;
    --success: #22c55e;
    --error: #ef4444;
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #475569;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

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

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

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

header .subtitle {
    color: var(--text-muted);
    font-size: 1rem;
}

/* Query Section */
.query-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.input-group {
    display: flex;
    gap: 0.75rem;
}

textarea {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    color: var(--text);
    font-size: 1rem;
    resize: vertical;
    min-height: 80px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

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

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

button[type="submit"] {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    padding: 0 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 100px;
}

button[type="submit"]:hover:not(:disabled) {
    background: var(--primary-dark);
}

button[type="submit"]:active:not(:disabled) {
    transform: scale(0.98);
}

button[type="submit"]:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.spinner {
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
}

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

/* Status */
.status {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: var(--radius);
    color: var(--primary);
    font-weight: 500;
}

.status.error {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--error);
}

/* Response */
.response {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.response h3 {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.answer {
    background: var(--bg-input);
    border-radius: var(--radius);
    padding: 1rem;
    line-height: 1.8;
}

.answer code {
    background: rgba(59, 130, 246, 0.2);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.9em;
}

/* Chart Container */
.chart-container {
    margin-top: 1.5rem;
    background: white;
    border-radius: var(--radius);
    padding: 1rem;
    min-height: 400px;
}

#chart {
    width: 100%;
    height: 400px;
}

/* Raw Data Section */
.raw-data-section {
    margin-top: 1rem;
}

.toggle-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.toggle-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.toggle-icon {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    transition: transform 0.2s;
}

.raw-data {
    margin-top: 1rem;
    background: var(--bg);
    border-radius: var(--radius);
    padding: 1rem;
    border: 1px solid var(--border);
}

.pattern-info {
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
}

.pattern-info .label {
    color: var(--text-muted);
}

.pattern-info .value {
    color: var(--primary);
    font-weight: 600;
    margin-left: 0.5rem;
}

.raw-data pre {
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 0.8rem;
    color: var(--text-muted);
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 300px;
    overflow-y: auto;
}

/* Examples Section */
.examples-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.examples-section h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text);
}

.examples-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.75rem;
}

.example-btn {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    text-align: left;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.example-btn:hover {
    border-color: var(--primary);
    color: var(--text);
    background: rgba(59, 130, 246, 0.1);
}

/* History Section */
.history-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

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

.history-header h3 {
    font-size: 1rem;
    color: var(--text);
}

.clear-btn {
    background: transparent;
    border: 1px solid var(--error);
    color: var(--error);
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.clear-btn:hover {
    background: var(--error);
    color: white;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.history-item {
    background: var(--bg-input);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    transition: border-color 0.2s;
}

.history-item:hover {
    border-color: var(--primary);
}

.history-question {
    cursor: pointer;
    color: var(--text);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.history-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.history-pattern {
    background: rgba(59, 130, 246, 0.2);
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    color: var(--primary);
}

/* Footer */
footer {
    text-align: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 640px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

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

    button[type="submit"] {
        width: 100%;
        padding: 1rem;
    }

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