/* DataPulse Brand Colors */
:root {
    --purple-primary: #7178CE;
    --purple-dark: #2B365D;
    --purple-light: #9FA8DE;
    --purple-lighter: #D6D9EC;
    
    --red-primary: #FF4F42;
    --red-light: #F56F65;
    
    --yellow-primary: #FFDB45;
    --yellow-light: #FFE368;
    
    --gray-100: #F2F2F2;
    --gray-200: #E2E8F0;
    --gray-300: #CBD5E0;
    --gray-400: #A0AEC0;
    --gray-500: #718096;
    --gray-600: #4A5568;
    --gray-700: #2D3748;
    --gray-800: #1A202C;
    
    /* Light mode colors (default) */
    --bg-primary: #f0f2f5;
    --bg-secondary: white;
    --text-primary: var(--gray-800);
    --text-secondary: var(--gray-600);
    --text-tertiary: var(--gray-500);
    --border-color: var(--gray-300);
    --border-light: var(--gray-200);
}

/* Dark mode colors */
[data-theme="dark"] {
    --bg-primary: #0f1114;
    --bg-secondary: #1a1d23;
    --text-primary: #f7fafc;
    --text-secondary: #e2e8f0;
    --text-tertiary: #cbd5e0;
    --border-color: #2d3748;
    --border-light: #2d3748;
    
    --gray-100: #1a202c;
    --gray-200: #2d3748;
    --gray-300: #4a5568;
    --gray-400: #718096;
    --gray-500: #a0aec0;
    --gray-600: #cbd5e0;
    --gray-700: #e2e8f0;
    --gray-800: #f7fafc;
}

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

/* Import Inter font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

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

/* Header with DataPulse branding */
.header {
    text-align: center;
    margin-bottom: 3rem;
}

.header-top {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    margin-bottom: 0.5rem;
    position: relative;
}

.logo {
    display: inline-flex;
    align-items: baseline;
    gap: 0.25rem;
    margin-bottom: 0.5rem;
}

.logo h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--purple-primary);
}

.logo-domain {
    color: var(--purple-dark);
    font-weight: 400;
}

.tagline {
    display: inline-block;
    margin-left: 1rem;
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 300;
}

.subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
}

/* Theme toggle button */
.theme-toggle {
    position: absolute;
    right: 0;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.625rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background-color: var(--gray-100);
    transform: translateY(-1px);
}

.theme-toggle svg {
    width: 1.25rem;
    height: 1.25rem;
    color: var(--text-secondary);
}

.theme-toggle .sun-icon {
    display: block;
}

.theme-toggle .moon-icon {
    display: none;
}

[data-theme="dark"] .theme-toggle .sun-icon {
    display: none;
}

[data-theme="dark"] .theme-toggle .moon-icon {
    display: block;
}

/* Upload Section */
.upload-section {
    margin-bottom: 3rem;
}

.upload-area {
    background-color: var(--bg-secondary);
    border: 2px dashed var(--border-color);
    border-radius: 0.75rem;
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-area:hover {
    border-color: var(--purple-primary);
    background-color: rgba(113, 120, 206, 0.02);
}

.upload-area.dragging {
    background-color: rgba(113, 120, 206, 0.05);
    border-color: var(--purple-primary);
}

.upload-icon {
    width: 4rem;
    height: 4rem;
    color: var(--purple-primary);
    margin-bottom: 1rem;
}

.upload-text {
    font-size: 1.125rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.upload-hint {
    font-size: 0.875rem;
    color: var(--text-tertiary);
}

/* Metadata Form */
.metadata-section {
    background-color: var(--bg-secondary);
    border-radius: 0.75rem;
    padding: 2rem;
    margin-top: 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    animation: fadeIn 0.3s ease;
}

.metadata-section h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--purple-primary);
    box-shadow: 0 0 0 3px rgba(113, 120, 206, 0.1);
}

.form-group textarea {
    resize: vertical;
    line-height: 1.5;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.generate-btn {
    width: 100%;
    background-color: var(--purple-primary);
    color: white;
    border: none;
    padding: 0.875rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.generate-btn:hover {
    background-color: var(--purple-dark);
    transform: translateY(-1px);
}

/* Chart Section */
.chart-section {
    animation: fadeIn 0.5s ease;
}

.chart-controls {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-bottom: 2rem;
}

.reset-btn,
.download-btn,
.embed-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.625rem 1.25rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.reset-btn:hover,
.download-btn:hover,
.embed-btn:hover {
    background-color: var(--gray-100);
    border-color: var(--gray-400);
    transform: translateY(-1px);
}

.download-btn {
    background-color: var(--purple-primary);
    color: white;
    border-color: var(--purple-primary);
}

.download-btn:hover {
    background-color: var(--purple-dark);
    border-color: var(--purple-dark);
}

.reset-btn svg,
.download-btn svg,
.embed-btn svg {
    width: 1rem;
    height: 1rem;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-content {
    background-color: var(--bg-secondary);
    border-radius: 0.75rem;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    animation: slideUp 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0.5rem;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-close svg {
    width: 1.25rem;
    height: 1.25rem;
}

.modal-body {
    padding: 1.5rem;
}

.embed-instructions {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.embed-preview {
    margin-bottom: 1.5rem;
}

.embed-preview label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

#embedCode {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-family: monospace;
    font-size: 0.8125rem;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    resize: vertical;
}

.copy-btn {
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--purple-primary);
    color: white;
    border: none;
    padding: 0.625rem 1.25rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copy-btn:hover {
    background-color: var(--purple-dark);
}

.copy-btn.copied {
    background-color: #10b981;
}

.copy-btn svg {
    width: 1rem;
    height: 1rem;
}

.embed-note {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    padding: 1rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.embed-note code {
    display: block;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background-color: var(--bg-secondary);
    border-radius: 0.25rem;
    font-size: 0.75rem;
    overflow-x: auto;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Chart Box - Datawrapper Style */
.chart-box {
    background-color: var(--bg-secondary);
    border-radius: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

.chart-inner {
    padding: 2rem;
}

.chart-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

.chart-description {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 1.5rem;
}

.chart-canvas-container {
    position: relative;
    height: 450px;
    margin: 0 -0.5rem 1.5rem -0.5rem;
}

canvas {
    max-height: 100%;
}

/* Chart Footer */
.chart-footer {
    border-top: 1px solid var(--border-light);
    padding-top: 1rem;
    margin-top: 1.5rem;
}

.chart-notes {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 0.75rem;
    font-style: italic;
}

.chart-attribution {
    font-size: 0.6875rem;
    color: var(--text-tertiary);
    line-height: 1.4;
}

.attribution-text {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.source-label {
    font-weight: 500;
}

.source-name {
    color: var(--text-primary);
}

.divider {
    color: var(--gray-400);
}

.source-link {
    color: var(--purple-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.source-link:hover {
    color: var(--purple-dark);
    text-decoration: underline;
}

.branding {
    color: var(--text-tertiary);
}

.branding strong {
    color: var(--purple-primary);
    font-weight: 600;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .logo h1 {
        font-size: 2rem;
    }
    
    .tagline {
        display: block;
        margin-left: 0;
        margin-top: 0.25rem;
    }
    
    .upload-area {
        padding: 2rem;
    }
    
    .chart-inner {
        padding: 1.5rem;
    }
    
    .chart-canvas-container {
        height: 350px;
    }
    
    .chart-controls {
        flex-direction: column;
    }
    
    .reset-btn,
    .download-btn,
    .embed-btn {
        width: 100%;
        justify-content: center;
    }
    
    .chart-title {
        font-size: 1.25rem;
    }
    
    .metadata-section {
        padding: 1.5rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .attribution-text {
        font-size: 0.625rem;
    }
    
    .header-top {
        flex-direction: column;
        gap: 1rem;
    }
    
    .theme-toggle {
        position: static;
        margin-top: 0.5rem;
    }
}