/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* Header */
header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 2rem 0;
    text-align: center;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 2.5rem;
    color: #4a5568;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

header p {
    font-size: 1.1rem;
    color: #718096;
    font-weight: 400;
}

/* Container */
.container {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 1rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    min-height: 70vh;
}

/* Editor and Preview Sections */
.editor-section,
.preview-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e2e8f0;
}

.section-header h2 {
    font-size: 1.5rem;
    color: #2d3748;
    font-weight: 600;
}

/* Textarea */
#markdownInput {
    width: 100%;
    min-height: 500px;
    padding: 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
    background: #f7fafc;
    transition: all 0.3s ease;
}

#markdownInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    background: white;
}

#markdownInput::placeholder {
    color: #a0aec0;
    font-style: italic;
}

/* Preview Content */
.preview-content {
    min-height: 500px;
    padding: 1rem;
    background: #f7fafc;
    border-radius: 8px;
    border: 2px solid #e2e8f0;
    overflow-y: auto;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.7;
}

.preview-content h1,
.preview-content h2,
.preview-content h3,
.preview-content h4,
.preview-content h5,
.preview-content h6 {
    color: #2d3748;
    margin: 1.5rem 0 1rem 0;
    font-weight: 600;
}

.preview-content h1 { font-size: 2.2rem; border-bottom: 2px solid #e2e8f0; padding-bottom: 0.5rem; }
.preview-content h2 { font-size: 1.8rem; }
.preview-content h3 { font-size: 1.5rem; }
.preview-content h4 { font-size: 1.3rem; }
.preview-content h5 { font-size: 1.1rem; }
.preview-content h6 { font-size: 1rem; }

.preview-content p {
    margin-bottom: 1rem;
    color: #4a5568;
}

.preview-content code {
    background: #edf2f7;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
    color: #e53e3e;
}

.preview-content pre {
    background: #2d3748;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1rem 0;
}

.preview-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.preview-content blockquote {
    border-left: 4px solid #667eea;
    padding-left: 1rem;
    margin: 1rem 0;
    font-style: italic;
    color: #718096;
    background: rgba(102, 126, 234, 0.05);
    padding: 1rem 1rem 1rem 1.5rem;
    border-radius: 0 8px 8px 0;
}

.preview-content ul,
.preview-content ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

.preview-content li {
    margin-bottom: 0.5rem;
    color: #4a5568;
}

.preview-content a {
    color: #667eea;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.3s ease;
}

.preview-content a:hover {
    border-bottom-color: #667eea;
}

.preview-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin: 1rem 0;
}

.preview-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.preview-content th,
.preview-content td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.preview-content th {
    background: #667eea;
    color: white;
    font-weight: 600;
}

.preview-content tr:hover {
    background: #f7fafc;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5a67d8;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
}

.btn-secondary:hover {
    background: #cbd5e0;
    transform: translateY(-1px);
}

/* Word Count */
.word-count {
    margin-top: 0.5rem;
    display: flex;
    gap: 1rem;
    font-size: 0.9rem;
    color: #718096;
    font-style: italic;
}

/* AdSense Containers */
.ad-container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
    text-align: center;
}

/* Footer */
footer {
    background: rgba(45, 55, 72, 0.95);
    color: white;
    text-align: center;
    padding: 2rem 0;
    margin-top: 3rem;
}

footer p {
    font-size: 1rem;
    opacity: 0.8;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin: 1rem auto;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .section-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
    }
    
    .section-header h2 {
        text-align: center;
        margin-bottom: 0.5rem;
    }
    
    #markdownInput,
    .preview-content {
        min-height: 300px;
    }
    
    .word-count {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 0.5rem;
    }
    
    .editor-section,
    .preview-section {
        padding: 1rem;
    }
    
    header {
        padding: 1.5rem 0;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
}

/* Loading Animation */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Syntax Highlighting Overrides */
.hljs {
    background: #2d3748 !important;
    color: #e2e8f0 !important;
    padding: 1rem !important;
    border-radius: 8px !important;
}

/* Custom Scrollbar */
.preview-content::-webkit-scrollbar {
    width: 8px;
}

.preview-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.preview-content::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

.preview-content::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}