/* Theme Variables */
:root {
    --bg: #ffffff;
    --bg-alt: #f9fafb;
    --text: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --accent: #2563eb;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #059669;
    --error: #dc2626;
}

/* Base Styles */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Headings - reduce default margins slightly */
h1,
h2 {
    margin-top: 0.4em;
    margin-bottom: 0.4em;
    line-height: 1.2;
}

/* Layout */
.main-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.content-wrapper {
    flex: 1;
    display: flex;
    padding: 20px;
    gap: 20px;
    overflow: hidden;
    position: relative;
}

@media (max-width: 768px) {
    .content-wrapper {
        flex-direction: column;
    }
}

/* Header */
.header {
    background-color: var(--bg);
    padding: 12px 40px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.title {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text);
    margin-bottom: 4px;
}

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

/* Panels */
.left-panel,
.right-panel {
    background-color: var(--bg);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.left-panel {
    width: 100%;
}

.right-panel {
    flex: 1;
}

@media (min-width: 768px) {
    .left-panel {
        width: 320px;
    }
}

/* Panel Headers */
.panel-header {
    padding: 24px;
    border-bottom: 1px solid var(--border);
    background-color: var(--bg-alt);
    border-radius: 12px 12px 0 0;
}

.panel-title {
    color: var(--text);
    font-size: 1.125rem;
    font-weight: 600;
}

/* Panel Content */
.panel-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border);
    padding: 32px;
    border-radius: 12px;
    background-color: var(--bg-alt);
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
}

.upload-area:hover,
.upload-area.hover-border-blue-400 {
    border-color: #60a5fa;
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
}

.file-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 50%;
    opacity: 0;
    cursor: pointer;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    font-size: inherit;
    background: transparent;
    color: inherit;
}

.file-input:focus {
    outline: none;
}

.file-display {
    text-align: center;
    color: var(--text-muted);
    margin-top: 2px;
}

.file-display.selected {
    color: var(--accent);
}

/* Titles and Text */
.section-title,
.validation-title,
.placeholder-title,
.footer-title,
.footer-section-title,
.chart-title,
.prediction-title,
.prediction-list-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.placeholder-title,
.footer-title {
    font-size: 1.25rem;
    margin-bottom: 16px;
}

.chart-title,
.prediction-title {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 16px;
}

.prediction-list-title {
    font-size: 1.25rem;
    margin-bottom: 12px;
}

.validation-title {
    margin-bottom: 12px;
}

/* Lists */
.section-list,
.placeholder-box-list,
.prediction-list {
    font-size: 0.875rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-left: 0;
    margin-left: 0;
}

.section-list li {
    list-style-position: inside;
    padding-left: 0;
    margin-left: 0;
}

/* Placeholder */
.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 1rem;
    background-color: var(--bg-alt);
    border-radius: 12px;
    border: 2px dashed var(--border);
    min-height: 200px;
}

.placeholder-content {
    text-align: center;
}

.placeholder-text {
    color: var(--text-muted);
    margin-bottom: 16px;
}

.placeholder-box {
    background-color: var(--bg-alt);
    padding: 16px;
    border-radius: 8px;
    text-align: left;
}

.placeholder-box-title {
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

/* Footer */
.footer {
    background-color: var(--bg-alt);
    border-top: 1px solid var(--border);
    padding: 16px 40px;
    text-align: center;
    flex-shrink: 0;
}

.footer-content {
    max-width: 1024px;
    margin: 0 auto;
}

.footer-text {
    color: var(--text-muted);
    margin-bottom: 12px;
    font-size: 0.9rem;
}

.footer-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

@media (min-width: 768px) {
    .footer-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.footer-section {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Validation Checklist */
.validation-checklist {
    display: none;
}

.validation-checklist.visible {
    display: block;
}

.checklist-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    animation: fadeIn 0.5s ease-out;
}

.checklist-item.success {
    color: var(--success);
}

.checklist-item.error {
    color: var(--error);
}

.checklist-item.warning {
    color: #d97706;
}

.checklist-item.loading {
    color: var(--accent);
}

/* Results */
.result-content {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.processing-message {
    color: var(--accent);
    font-size: 1.125rem;
    font-weight: 500;
    animation: pulse 2s infinite;
}

.error-message {
    background: linear-gradient(to right, #ef4444, #dc2626);
    color: #ffffff;
    padding: 20px;
    border-radius: 16px;
    animation: fadeIn 0.5s ease-out;
}

/* Chart and Prediction Containers */
.chart-container,
.prediction-results {
    background-color: var(--bg-alt);
    color: var(--text);
    padding: 24px;
    border-radius: 16px;
    border: 1px solid #bfdbfe;
    animation: fadeIn 0.5s ease-out;
}

.chart-description {
    margin-bottom: 16px;
    color: var(--text-muted);
}

.chart-canvas {
    height: 400px;
    flex: 1;
}

.chart-container {
    display: flex;
    align-items: center;
    gap: 20px;
}

.prediction-metrics {
    margin-bottom: 0;
}

.prediction-title {
    display: inline-block;
    margin: 0 8px 0 0;
    vertical-align: middle;
}

.prediction-metrics {
    display: inline-block;
    vertical-align: middle;
}

.prediction-metrics p {
    display: inline;
    margin: 0;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.prediction-list {
    text-align: left;
    max-width: 320px;
    margin: 0 auto;
}

.prediction-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.prediction-item:last-child {
    border-bottom: none;
}

.prediction-header {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    justify-content: space-between;
}

.prediction-metrics {
    flex: 1 1 auto;
    min-width: 0;
}

.prediction-actions {
    flex: 0 0 auto;
}

.prediction-header .download-btn {
    margin-top: 2px;
    margin-bottom: 2px;
}

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

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

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

.text-left {
    text-align: left;
}

.space-y-2 > * + * {
    margin-top: 8px;
}

.space-y-6 > * + * {
    margin-top: 24px;
}

.mb-4 {
    margin-bottom: 16px;
}

/* CSV Examples Styles */
.csv-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 20px;
}

.csv-example {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    flex: 0 0 auto;
    min-width: 200px;
}

.csv-example-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.csv-preview {
    overflow-x: auto;
}

.csv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10px;
    font-family: 'Courier New', monospace;
}

.csv-table th,
.csv-table td {
    padding: 4px 6px;
    text-align: left;
    border: 1px solid var(--border);
}

.csv-table th {
    background-color: var(--bg-alt);
    font-weight: 600;
    color: var(--text);
}

.csv-table td {
    background-color: var(--bg);
    color: var(--text);
}

.csv-table tr:nth-child(even) td {
    background-color: #f8f9fa;
}

.title-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.title-link:hover {
    color: #1d4ed8;
    text-decoration: underline;
}

.title-link:visited {
    color: var(--accent);
}

.loading-message {
    text-align: center;
    color: var(--text-muted);
    padding: 20px;
    font-style: italic;
}

.download-btn {
    display: inline-block;
    background-color: var(--primary);
    color: white;
    padding: 10px 20px;
    text-decoration: none;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 8px;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.download-btn:hover {
    background-color: var(--primary-dark);
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

.download-section {
    margin-top: 16px;
    text-align: left;
}

.csv-description {
    color: var(--text-muted);
    font-size: 14px;
    margin: 8px 0;
    line-height: 1.4;
}

/* Align CSV examples section to the left inside results */
.result-content .placeholder-content {
    text-align: left;
}

/* Hint / Workflow UI */
.hint-button {
    position: absolute;
    top: 20px;
    padding: 6px 10px;
    font-size: 12px;
    background: #6b7280; /* gray-500 */
    color: #ffffff;
    border-radius: 4px;
    border: 1px solid #6b7280;
    cursor: pointer;
    user-select: none;
    z-index: 1001;
}

#workflowHintBtn {
    left: 0px;
    top: 20px;
}

#articlesBtn {
    left: 0px;
    top: 58px;
}

#feedbackBtn {
    left: 0px;
    top: 96px;
}

#trySampleBtn {
    left: 0px;
    top: 134px;
}

.hint-button:hover {
    background: #4b5563; /* gray-600 */
}

/* Language switcher container: keep inside header on wide screens */
.lang-switcher {
    position: absolute;
    right: 48px;
    top: 8px;
    display: flex;
    gap: 8px;
    align-items: center;
    max-width: calc(100% - 48px);
}

/* Prevent overflow and move below titles on smaller screens */
@media (max-width: 640px) {
    .lang-switcher {
        position: static;
        margin: 8px auto 0 auto;
        justify-content: center;
    }
}

/* Dedicated style for the language <select>, not absolutely positioned */
.lang-select {
    padding: 4px 8px;
    font-size: 12px;
    background: #6b7280;
    color: #ffffff;
    border-radius: 4px;
    border: 1px solid #6b7280;
    cursor: pointer;
}

.lang-select:hover {
    background: #4b5563;
}

.workflow-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    display: inline-block;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    box-shadow: 0 6px 16px rgba(0,0,0,0.18);
    padding: 0;
    transform-origin: top left;
    transform: translate(-50%, -50%) scale(0.92);
    opacity: 0;
    transition: transform 220ms ease, opacity 220ms ease;
    z-index: 1000;
    pointer-events: none;
}

.workflow-modal.visible {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
    pointer-events: auto;
}

.workflow-modal img {
    display: block;
    width: auto;
    height: auto;
    max-width: 65vw;
    max-height: 65vh;
}

.workflow-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    transition: opacity 180ms ease;
    z-index: 999;
    pointer-events: none;
}

.workflow-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

/* Add inner spacing for feedback modal content only */
#feedbackModal {
    padding: 16px 20px;
}

/* Feedback button placement next to Help */
.feedback-button {
    left: 0px;
    top: 56px;
}

/* Try sample button placement under Feedback */
.try-sample-button {
    left: 0px;
    top: 92px;
}

/* Minimal form button styling reuse */
.controlButton {
    display: inline-block;
    background-color: var(--primary);
    color: #ffffff;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.controlButton:hover {
    background-color: var(--primary-dark);
}