/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --accent-color: #f59e0b;
    --background-color: #f8fafc;
    --surface-color: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --border-radius: 8px;
    --font-main: 'Inter', sans-serif;
    --font-code: 'Fira Code', monospace;
}

body {
    font-family: var(--font-main);
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--background-color);
    min-height: 100vh;
}

/* App container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 100%;
}

/* Header styles */
.app-header {
    background: var(--surface-color);
    padding: 1rem 2rem;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
}

.controls {
    display: flex;
    gap: 0.5rem;
}

/* Button styles */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

.btn-primary:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

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

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

.btn-small {
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
}

/* Main editor container */
.editor-container {
    display: flex;
    flex: 1;
    gap: 1rem;
    padding: 1rem;
    height: calc(100vh - 120px);
}

/* Pane styles */
.editor-pane,
.preview-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.pane-header {
    padding: 1rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pane-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.word-count {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Textarea styles */
#markdownInput {
    flex: 1;
    padding: 1rem;
    border: none;
    resize: none;
    font-family: var(--font-code);
    font-size: 0.875rem;
    line-height: 1.5;
    background: var(--surface-color);
    color: var(--text-primary);
}

#markdownInput:focus {
    outline: none;
    background: #fafbfc;
}

/* Preview styles */
.preview-content {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    background: var(--surface-color);
}

/* Markdown preview styles */
#markdownPreview h1 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
}

#markdownPreview h2 {
    font-size: 1.5rem;
    margin: 1.5rem 0 1rem 0;
    color: var(--text-primary);
}

#markdownPreview h3 {
    font-size: 1.25rem;
    margin: 1rem 0 0.5rem 0;
    color: var(--text-primary);
}

#markdownPreview p {
    margin-bottom: 1rem;
    line-height: 1.6;
}

#markdownPreview ul,
#markdownPreview ol {
    margin: 0 0 1rem 2rem;
}

#markdownPreview li {
    margin-bottom: 0.25rem;
}

#markdownPreview blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 1rem;
    margin: 1rem 0;
    color: var(--text-secondary);
    font-style: italic;
}

#markdownPreview code {
    background: #f1f5f9;
    padding: 0.125rem 0.25rem;
    border-radius: 3px;
    font-family: var(--font-code);
    font-size: 0.875rem;
}

#markdownPreview pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1rem;
    border-radius: var(--border-radius);
    overflow-x: auto;
    margin: 1rem 0;
}

#markdownPreview pre code {
    background: none;
    padding: 0;
    color: inherit;
}

#markdownPreview table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

#markdownPreview th,
#markdownPreview td {
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    text-align: left;
}

#markdownPreview th {
    background: #f8fafc;
    font-weight: 600;
}

#markdownPreview a {
    color: var(--primary-color);
    text-decoration: none;
}

#markdownPreview a:hover {
    text-decoration: underline;
}

#markdownPreview img {
    max-width: 100%;
    height: auto;
    border-radius: var(--border-radius);
}

/* Footer styles */
.app-footer {
    text-align: center;
    padding: 1rem;
    background: var(--surface-color);
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Media queries for responsive design */
@media (max-width: 768px) {
    .editor-container {
        flex-direction: column;
        height: auto;
        padding: 0.5rem;
    }

    .editor-pane,
    .preview-pane {
        min-height: 400px;
    }

    .app-header {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
    }

    .app-header h1 {
        font-size: 1.25rem;
    }

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

    .pane-header {
        padding: 0.75rem;
    }

    .pane-header h2 {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .editor-container {
        gap: 0.5rem;
    }

    .app-header {
        padding: 0.75rem;
    }

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

    #markdownInput {
        padding: 0.75rem;
        font-size: 0.75rem;
    }

    .preview-content {
        padding: 0.75rem;
    }
}

/* Fullscreen styles */
.app-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1000;
    background: var(--surface-color);
}

.app-container.fullscreen .editor-container {
    height: calc(100vh - 80px);
}

/* Utility classes */
.hidden {
    display: none !important;
}

.visible {
    display: flex;
}

/* Animation for smooth transitions */
.editor-pane,
.preview-pane,
.btn {
    transition: all 0.3s ease;
}

/* Scrollbar styling */
.preview-content::-webkit-scrollbar {
    width: 6px;
}

.preview-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.preview-content::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.preview-content::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}