/* Modern LaTeX Renderer Styles */
:root {
    /* Light theme colors */
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #818cf8;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;

    --bg-color: #f8fafc;
    --surface-color: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;

    --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark theme */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #818cf8;
        --primary-hover: #a5b4fc;
        --primary-light: #c7d2fe;
        --success-color: #34d399;
        --warning-color: #fbbf24;
        --error-color: #f87171;

        --bg-color: #0f172a;
        --surface-color: #1e293b;
        --border-color: #334155;
        --text-primary: #f1f5f9;
        --text-secondary: #cbd5e1;
        --text-muted: #94a3b8;

        --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.5);
        --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
        --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.4);
        --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.5), 0 8px 10px -6px rgb(0 0 0 / 0.5);
    }
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.2s ease, color 0.2s ease;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

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

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.125rem;
    font-weight: 400;
    margin-top: 0.5rem;
}

/* Panel */
.panel {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.panel:hover {
    box-shadow: var(--shadow-md);
}

/* Screen reader only */
.sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Textarea */
textarea {
    width: 100%;
    padding: 1.125rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-color);
    color: var(--text-primary);
    font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Monaco, 'Cascadia Code', monospace;
    font-size: 1rem;
    line-height: 1.7;
    resize: vertical;
    transition: var(--transition-fast);
    min-height: 150px;
}

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

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

/* Button row */
.row {
    display: flex;
    gap: 0.875rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    white-space: nowrap;
    letter-spacing: -0.01em;
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn:hover {
    background: var(--primary-hover);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Output/Preview section */
.output {
    min-height: 180px;
    padding: 2rem;
    background: var(--bg-color);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    transition: var(--transition);
}

.output:empty::before {
    content: 'Preview will appear here...';
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.9375rem;
}

.output .katex-display {
    margin: 0;
}

/* Preview section heading */
#preview-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.25rem;
    letter-spacing: -0.015em;
}

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

    header h1 {
        font-size: 1.875rem;
    }

    .subtitle {
        font-size: 0.9375rem;
    }

    .panel {
        padding: 1.25rem;
    }

    .row {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    textarea {
        font-size: 0.875rem;
        min-height: 120px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 1rem 0.75rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .panel {
        padding: 1rem;
        border-radius: var(--radius-lg);
    }

    textarea {
        font-size: 0.8125rem;
    }

    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.8125rem;
    }
}

/* Focus visible for accessibility */
*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Selection styling */
::selection {
    background-color: rgba(79, 70, 229, 0.2);
    color: var(--text-primary);
}

::-moz-selection {
    background-color: rgba(79, 70, 229, 0.2);
    color: var(--text-primary);
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
