/* Premium Modern Dark Theme Design */
:root {
    --bg-base: #0f172a;
    --bg-surface: rgba(30, 41, 59, 0.7);
    --bg-surface-hover: rgba(30, 41, 59, 0.9);
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    
    --accent-primary: #8b5cf6;
    --accent-secondary: #3b82f6;
    --accent-gradient: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 8px;
    
    --transition-fast: 0.2s ease;
    --transition-normal: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Light Mode Theme */
[data-theme="light"] {
    --bg-base: #f8fafc;
    --bg-surface: rgba(255, 255, 255, 0.7);
    --bg-surface-hover: rgba(255, 255, 255, 0.9);
    
    --text-main: #0f172a;
    --text-muted: #475569;
    
    --glass-border: rgba(0, 0, 0, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .markdown-body {
    color: #334155;
}
[data-theme="light"] .markdown-body code {
    background: rgba(0, 0, 0, 0.05);
    color: #ef4444;
}
[data-theme="light"] .markdown-body pre {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid var(--glass-border);
    box-shadow: none;
}
[data-theme="light"] .markdown-body pre code {
    color: #334155;
}
[data-theme="light"] .markdown-body th {
    background: rgba(0, 0, 0, 0.03);
}
[data-theme="light"] .markdown-body tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.01);
}
[data-theme="light"] .markdown-body blockquote {
    background: rgba(139, 92, 246, 0.1);
}

.theme-toggle {
    position: fixed;
    top: 2rem;
    right: 2rem;
    background: var(--bg-surface);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 100;
    color: var(--text-main);
    box-shadow: var(--glass-shadow);
    transition: var(--transition-fast);
}

.theme-toggle:hover {
    transform: scale(1.1);
    background: var(--bg-surface-hover);
}

/* Hide toggle icons based on theme */
:root:not([data-theme="light"]) #icon-moon { display: none; }
[data-theme="light"] #icon-sun { display: none; }

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

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    line-height: 1.6;
}

/* Background Blobs for Visual Aesthetics */
.background-elements {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.blob {
    position: absolute;
    filter: blur(100px);
    border-radius: 50%;
    opacity: 0.4;
    animation: float 20s infinite alternate;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 500px;
    height: 500px;
    background: var(--accent-primary);
}

.blob-2 {
    bottom: -20%;
    right: -10%;
    width: 600px;
    height: 600px;
    background: var(--accent-secondary);
    animation-delay: -5s;
}

.blob-3 {
    top: 40%;
    left: 40%;
    width: 400px;
    height: 400px;
    background: #ec4899;
    opacity: 0.2;
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(100px, 50px) scale(1.2); }
}

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

/* Header */
.app-header {
    text-align: center;
    margin-bottom: 3rem;
    animation: fadeDown 0.8s ease-out forwards;
}

.logo {
    font-size: 3rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -1px;
    margin-bottom: 0.5rem;
}

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

/* Upload Area */
.upload-area {
    display: none;
    flex: 1;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.5s ease-out forwards;
}

.upload-area.active {
    display: flex;
}

.drop-zone {
    width: 100%;
    max-width: 600px;
    padding: 4rem 2rem;
    background: var(--bg-surface);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px dashed rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
    text-align: center;
    transition: var(--transition-normal);
    cursor: pointer;
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--accent-primary);
    background: var(--bg-surface-hover);
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(139, 92, 246, 0.15);
}

.upload-icon {
    color: var(--accent-primary);
    margin-bottom: 1.5rem;
    transition: var(--transition-normal);
}

.drop-zone:hover .upload-icon {
    transform: scale(1.1) translateY(-10px);
}

.drop-zone h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.drop-zone p {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

/* Buttons */
.primary-btn, .secondary-btn {
    padding: 0.8rem 1.8rem;
    border-radius: 999px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition-fast);
    border: none;
}

.primary-btn {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.6);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

/* Preview Area */
.preview-area {
    display: none;
    flex-direction: column;
    background: var(--bg-surface);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--glass-shadow);
    overflow: hidden;
    animation: slideUp 0.6s ease-out forwards;
}

.preview-area.active {
    display: flex;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(15, 23, 42, 0.4);
}

.file-name {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.file-name::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent-primary);
    box-shadow: 0 0 10px var(--accent-primary);
}

.header-actions {
    display: flex;
    gap: 1rem;
}

/* Markdown Body Styles */
.markdown-body {
    padding: 2.5rem;
    max-width: 100%;
    overflow-x: auto;
    font-size: 1.05rem;
    color: #e2e8f0;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
    color: var(--text-main);
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-weight: 600;
    line-height: 1.3;
}

.markdown-body h1:first-child, .markdown-body h2:first-child {
    margin-top: 0;
}

.markdown-body h1 {
    font-size: 2.5rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.5rem;
}

.markdown-body h2 {
    font-size: 2rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.5rem;
}

.markdown-body h3 { font-size: 1.5rem; }
.markdown-body h4 { font-size: 1.25rem; }

.markdown-body p {
    margin-bottom: 1.2rem;
}

.markdown-body a {
    color: var(--accent-secondary);
    text-decoration: none;
    transition: color 0.2s;
    border-bottom: 1px dashed var(--accent-secondary);
}

.markdown-body a:hover {
    color: var(--accent-primary);
    border-bottom-style: solid;
}

.markdown-body ul, .markdown-body ol {
    margin-bottom: 1.2rem;
    padding-left: 2rem;
}

.markdown-body li {
    margin-bottom: 0.5rem;
}

.markdown-body li > p {
    margin-bottom: 0.5rem;
}

.markdown-body blockquote {
    border-left: 4px solid var(--accent-primary);
    padding: 0.8rem 1.2rem;
    background: rgba(139, 92, 246, 0.05);
    margin: 1.5rem 0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-muted);
    font-style: italic;
}

.markdown-body code {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 0.9em;
    color: #fca5a5;
}

.markdown-body pre {
    background: rgba(0, 0, 0, 0.4);
    padding: 1.5rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 1.5rem 0;
    border: 1px solid var(--glass-border);
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.2);
}

.markdown-body pre code {
    background: none;
    padding: 0;
    color: #e2e8f0;
    font-size: 0.9em;
    border-radius: 0;
}

.markdown-body img {
    max-width: 100%;
    border-radius: var(--radius-sm);
    margin: 1.5rem 0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    display: block;
}

.markdown-body hr {
    height: 1px;
    background-color: var(--glass-border);
    border: none;
    margin: 2rem 0;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
}

.markdown-body th, .markdown-body td {
    padding: 0.8rem 1rem;
    border: 1px solid var(--glass-border);
    text-align: left;
}

.markdown-body th {
    background: rgba(255, 255, 255, 0.05);
    font-weight: 600;
}

.markdown-body tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

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

/* Markdown Rendering Items Micro animation */
.markdown-item-entered {
    animation: slideUp 0.5s ease-out forwards;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .app-container {
        padding: 1.5rem 1rem;
    }
    
    .logo {
        font-size: 2.2rem;
    }
    
    .drop-zone {
        padding: 3rem 1rem;
    }
    
    .markdown-body {
        padding: 1.5rem 1rem;
    }
    
    .preview-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
}
