/* CSS Variables */
:root {
    --color-primary: #6366f1;
    --color-primary-hover: #4f46e5;
    --color-secondary: #64748b;
    --color-secondary-hover: #475569;
    --color-background: #f8fafc;
    --color-surface: #ffffff;
    --color-border: #e2e8f0;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --color-success: #10b981;
    --color-error: #ef4444;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --transition: 150ms ease;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* Container */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 0.5rem;
}

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

/* Main Content */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Sections */
section {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
}

section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--color-text);
}

/* Input Section */
.input-methods {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.upload-area {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-md);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--color-background);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--color-primary);
    background: rgba(99, 102, 241, 0.05);
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: var(--color-text-muted);
}

.upload-area:hover .upload-icon {
    color: var(--color-primary);
}

.upload-content p {
    color: var(--color-text-muted);
}

.browse-link {
    color: var(--color-primary);
    font-weight: 500;
    text-decoration: underline;
}

/* Divider */
.divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--color-text-muted);
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--color-border);
}

/* Paste Area */
.paste-area textarea {
    width: 100%;
    min-height: 150px;
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: 0.875rem;
    resize: vertical;
    transition: border-color var(--transition);
}

.paste-area textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

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

/* Actions */
.actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

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

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

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

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

/* Preview Section */
.preview-box {
    min-height: 150px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: repeating-conic-gradient(#e2e8f0 0% 25%, white 0% 50%) 50% / 20px 20px;
    overflow: hidden;
}

.preview-box svg {
    max-width: 100%;
    max-height: 300px;
}

.preview-placeholder {
    color: var(--color-text-muted);
    padding: 2rem;
    background: var(--color-surface);
    border-radius: var(--radius-sm);
}

/* Output Section */
.output-options {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    color: var(--color-text);
    font-size: 0.9rem;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--color-primary);
    cursor: pointer;
}

/* Tabs */
.output-tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 1rem;
}

.tab-btn {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    position: relative;
    transition: color var(--transition);
}

.tab-btn:hover {
    color: var(--color-text);
}

.tab-btn.active {
    color: var(--color-primary);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--color-primary);
}

/* Tab Panels */
.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* Code Block */
.code-block {
    position: relative;
    background: #1e293b;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.code-block pre {
    padding: 1rem;
    padding-right: 4rem;
    color: #e2e8f0;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: 0.8rem;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 200px;
    margin: 0;
}

.copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    color: #94a3b8;
    font-size: 0.75rem;
    transition: all var(--transition);
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.copy-btn svg {
    width: 16px;
    height: 16px;
}

.copy-btn.copied {
    background: var(--color-success);
    color: white;
}

/* Stats */
.stats {
    display: flex;
    gap: 2rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.stat-item {
    display: flex;
    gap: 0.5rem;
}

.stat-label {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.stat-value {
    font-weight: 600;
    font-size: 0.875rem;
}

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

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

footer a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
}

footer a:hover {
    text-decoration: underline;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1e293b;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Hidden output section initially */
#outputSection {
    display: none;
}

#outputSection.visible {
    display: block;
}

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

    header h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    section {
        padding: 1.25rem;
    }

    .upload-area {
        padding: 1.5rem;
    }

    .upload-icon {
        width: 40px;
        height: 40px;
    }

    .actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .output-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tab-btn {
        padding: 0.6rem 0.75rem;
        font-size: 0.8rem;
        white-space: nowrap;
    }

    .stats {
        flex-direction: column;
        gap: 0.5rem;
    }

    .output-options {
        flex-direction: column;
        gap: 0.75rem;
    }
}

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

    .paste-area textarea {
        min-height: 120px;
        font-size: 0.8rem;
    }

    .code-block pre {
        font-size: 0.7rem;
        padding: 0.75rem;
        padding-right: 3rem;
    }

    .copy-btn span {
        display: none;
    }
}
