/* ==========================================================================
   1. Base & Variables
   ========================================================================== */

:root {
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-serif: 'Noto Serif', Georgia, serif;

    /* Light Theme (Default) */
    --color-bg: #f8f9fa;
    --color-text: #212529;
    --color-text-muted: #6c757d;
    --color-primary: #0d6efd;
    --color-surface: #ffffff;
    --color-border: #dee2e6;
    --color-code-bg: #e9ecef;
}

.theme-dark {
    --color-bg: #121212;
    --color-text: #e0e0e0;
    --color-text-muted: #a0a0a0;
    --color-primary: #4dabf7;
    --color-surface: #1e1e1e;
    --color-border: #333333;
    --color-code-bg: #2c2c2c;
}

.theme-sepia {
    --color-bg: #f4f0e8;
    --color-text: #5b4636;
    --color-text-muted: #8d6e63;
    --color-primary: #8c5e4a;
    --color-surface: #fdfaf3;
    --color-border: #dcd1c0;
    --color-code-bg: #e9e2d5;
}


/* ==========================================================================
   2. General Styles
   ========================================================================== */

body {
    font-family: var(--font-sans);
    line-height: 1.6;
    background-color: var(--color-bg);
    color: var(--color-text);
    transition: background-color 0.3s ease, color 0.3s ease;
    margin: 0;
}

.container {
    max-width: 800px;
    margin: 2rem auto;
    background: var(--color-surface);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--color-border);
}

/* ==========================================================================
   3. Form & UI Elements
   ========================================================================== */

textarea {
    width: 100%;
    padding: 10px;
    border-radius: 5px;
    border: 1px solid var(--color-border);
    background-color: var(--color-bg);
    color: var(--color-text);
    margin-bottom: 10px;
    min-height: 200px;
    box-sizing: border-box;
    font-family: var(--font-sans);
}

.btn {
    display: inline-block;
    background-color: var(--color-primary);
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.btn:hover {
    background-color: #0b5ed7;
    transform: translateY(-2px);
}

.btn-danger {
    background-color: #dc3545;
}

.btn-danger:hover {
    background-color: #c82333;
}

/* ==========================================================================
   4. Markdown Reading View (.markdown-body)
   ========================================================================== */

.markdown-body {
    background-color: var(--color-surface);
    color: var(--color-text);
    box-sizing: border-box;
    max-width: 800px; /* Optimal reading width */
    margin: 0 auto;
    padding: 3rem 4rem;
    font-family: var(--font-serif); /* Default to serif for reading */
    font-size: 1.1rem;
    line-height: 1.8;
    transition: all 0.3s ease; /* Smooth transition for font-size and colors */
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    font-family: var(--font-sans); /* Sans-serif for titles */
    font-weight: 700;
    line-height: 1.3;
    margin-top: 2.5rem;
    margin-bottom: 1.2rem;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 0.5rem;
    color: var(--color-text);
}

.markdown-body h1 { font-size: 2.5em; } /* Use em for scalability */
.markdown-body h2 { font-size: 2em; }
.markdown-body h3 { font-size: 1.75em; }

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

.markdown-body a {
    color: var(--color-primary);
    text-decoration: none;
    transition: border-bottom-color 0.2s ease-in-out;
    border-bottom: 1px solid transparent;
}

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

.markdown-body blockquote {
    margin: 1.5rem 0;
    padding: 0.5rem 1.5rem;
    color: var(--color-text-muted);
    border-left: 0.25rem solid var(--color-border);
    background-color: var(--color-bg);
    border-radius: 0 5px 5px 0;
}

.markdown-body blockquote p:last-child {
    margin-bottom: 0;
}

.markdown-body code {
    font-family: var(--font-sans);
    background-color: var(--color-code-bg);
    color: var(--color-text);
    padding: .2em .4em;
    margin: 0;
    font-size: 85%;
    border-radius: 3px;
}

.markdown-body pre {
    font-family: var(--font-sans);
    background-color: var(--color-code-bg);
    padding: 1rem;
    border-radius: 5px;
    overflow-x: auto;
    line-height: 1.45;
}

.markdown-body pre code {
    background: none;
    padding: 0;
    font-size: 100%;
}

.markdown-body img {
    max-width: 100%;
    height: auto;
    border-radius: 5px;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    display: block;
    overflow-x: auto;
    white-space: nowrap;
}

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

.markdown-body th {
    font-family: var(--font-sans);
    font-weight: 700;
    background-color: var(--color-bg);
}

/* ==========================================================================
   5. Admin Table
   ========================================================================== */

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.table th, .table td {
    border: 1px solid var(--color-border);
    padding: 12px 15px;
    text-align: left;
}

.table th {
    background-color: var(--color-bg);
    font-weight: bold;
}

/* ==========================================================================
   6. Reader Settings
   ========================================================================== */

.reader-settings {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 50px;
    padding: 8px;
    display: flex;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    z-index: 1000;
    transition: all 0.3s ease;
}

.setting-group {
    display: flex;
    gap: 5px;
}

.control-btn, .theme-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--color-border);
    cursor: pointer;
    background-color: var(--color-bg);
    color: var(--color-text);
    font-size: 1rem;
    font-weight: bold;
    transition: all 0.2s ease;
}

.control-btn:hover, .theme-btn:hover {
    transform: translateY(-2px);
    border-color: var(--color-primary);
}

.theme-btn[data-theme="light"] { background-color: #ffffff; }
.theme-btn[data-theme="sepia"] { background-color: #f4f0e8; }
.theme-btn[data-theme="dark"]  { background-color: #1e1e1e; }


@media (max-width: 768px) {
    .markdown-body {
        padding: 2rem 1.5rem;
        font-size: 1rem;
    }
    .container {
        margin: 1rem;
        padding: 1.5rem;
    }
    .reader-settings {
        bottom: 10px;
        right: 10px;
    }
}

/* ==========================================================================
   7. Drag and Drop Zone
   ========================================================================== */

#drop-zone {
    border: 2px dashed var(--color-border);
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.3s ease, background-color 0.3s ease;
}

#drop-zone.drag-over {
    border-color: var(--color-primary);
    background-color: var(--color-bg);
}

#drop-zone p {
    margin: 0;
    color: var(--color-text-muted);
}

#file-name {
    margin-top: 10px;
    font-weight: bold;
    color: var(--color-primary);
}
