/* Reset und Basis-Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Light Theme (Standard) */
:root {
    --primary-color: #2c3e50;
    --secondary-color: #34495e;
    --accent-color: #3498db;
    --text-color: #333;
    --text-light: #666;
    --background: #f8f9fa;
    --white: #ffffff;
    --border-color: #e1e8ed;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

/* Dark Theme */
[data-theme="dark"] {
    --primary-color: #1a252f;
    --extra-color: #989898;
    --secondary-color: #2c3e50;
    --accent-color: #3498db;
    --text-color: #e4e4e4;
    --text-light: #b0b0b0;
    --background: #121212;
    --white: #1e1e1e;
    --border-color: #2d2d2d;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Sepia Theme */
[data-theme="sepia"] {
    --primary-color: #5c4a3a;
    --extra-color: #5c4a3a;
    --secondary-color: #6d5a47;
    --accent-color: #8b6f47;
    --text-color: #3a3027;
    --text-light: #6b5d4f;
    --background: #f4ecd8;
    --white: #f9f5eb;
    --border-color: #d4c4a8;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Ocean Theme */
[data-theme="ocean"] {
    --primary-color: #1e3a5f;
    --extra-color:#1e3a5f;
    --secondary-color: #2c5282;
    --accent-color: #4299e1;
    --text-color: #2d3748;
    --text-light: #718096;
    --background: #edf2f7;
    --white: #ffffff;
    --border-color: #cbd5e0;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Forest Theme */
[data-theme="forest"] {
    --primary-color: #2d4a2b;
    --extra-color:#2d4a2b;
    --secondary-color: #3d5a3b;
    --accent-color: #68a063;
    --text-color: #2f3e2c;
    --text-light: #5a6b56;
    --background: #f0f4f0;
    --white: #ffffff;
    --border-color: #d4ddd4;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Font Settings */
[data-font="serif"] {
    --font-family: 'Georgia', 'Times New Roman', serif;
}

[data-font="sans"] {
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
}

[data-font="mono"] {
    --font-family: 'Courier New', 'Consolas', monospace;
}

body {
    font-family: var(--font-family, 'Georgia', serif);
    line-height: var(--line-height, 1.6);
    color: var(--text-color);
    background-color: var(--background);
    transition: var(--transition);
}

/* Font Size Classes */
body[data-font-size="small"] {
    font-size: 14px;
}

body[data-font-size="medium"] {
    font-size: 16px;
}

body[data-font-size="large"] {
    font-size: 18px;
}

body[data-font-size="xlarge"] {
    font-size: 20px;
}

/* Line Height Classes */
body[data-line-height="tight"] {
    --line-height: 1.4;
}

body[data-line-height="normal"] {
    --line-height: 1.6;
}

body[data-line-height="relaxed"] {
    --line-height: 1.8;
}

body[data-line-height="loose"] {
    --line-height: 2.0;
}

/* Header */
header {
    background-color: var(--primary-color);
    color: var(--white);
    padding: 2rem 0;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

header .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header .header-content h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

header .header-content p {
    font-size: 1.1rem;
    opacity: 0.9;
    color: var(--text-light);
}

/* Settings Button */
.settings-button {
    background: var(--secondary-color);
    border: none;
    color: var(--text-color);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.settings-button:hover {
    background: var(--accent-color);
    transform: translateY(-2px);
}

/* Settings Panel */
.settings-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: var(--white);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.2);
    padding: 2rem;
    overflow-y: auto;
    transition: right 0.3s ease;
    z-index: 1000;
}

.settings-panel.active {
    right: 0;
}

.settings-panel h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.settings-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.settings-section:last-child {
    border-bottom: none;
}

.settings-section h4 {
    color: var(--text-color);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.setting-option {
    margin-bottom: 1rem;
}

.setting-option label {
    display: block;
    color: var(--text-light);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.setting-option select,
.setting-option input[type="range"] {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--background);
    color: var(--text-color);
}

.theme-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.theme-button {
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--background);
    color: var(--text-color);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
}

.theme-button:hover {
    border-color: var(--accent-color);
}

.theme-button.active {
    border-color: var(--accent-color);
    background: var(--accent-color);
    color: white;
}

.close-settings {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-color);
    line-height: 1;
}

/* Settings Overlay */
.settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    z-index: 999;
}

.settings-overlay.active {
    display: block;
}

/* Navigation */
nav {
    background-color: var(--secondary-color);
    padding: 1rem 0;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: var(--transition);
}

nav .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    gap: 2rem;
    align-items: center;
    flex-wrap: wrap;
}

nav a {
    color: var(--text-color);
    text-decoration: none;
    font-size: 1rem;
    transition: opacity 0.3s;
}

nav a:hover {
    opacity: 0.8;
}

/* Search Bar */
.search-container {
    flex: 1;
    max-width: 400px;
    position: relative;
}

.search-bar {
    width: 100%;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: var(--background);
    color: var(--text-color);
    font-size: 0.9rem;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 0.5rem;
    max-height: 400px;
    overflow-y: auto;
    display: none;
    box-shadow: var(--shadow);
    z-index: 1000;
}

.search-results.active {
    display: block;
}

.search-result-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
}

.search-result-item:hover {
    background: var(--background);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-title {
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.search-result-meta {
    color: var(--text-light);
    font-size: 0.85rem;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Main Content */
main {
    padding: 3rem 0;
    min-height: calc(100vh - 300px);
}

/* Category Filter */
.filter-section {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.filter-section h3 {
    color: var(--extra-color);
    margin-bottom: 1rem;
}

.category-filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.category-filter {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 20px;
    background: var(--background);
    color: var(--text-color);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
}

.category-filter:hover {
    border-color: var(--accent-color);
}

.category-filter.active {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
}

/* Story Grid */
.story-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.story-card {
    background: var(--white);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: transform 0.3s, box-shadow 0.3s;
    cursor: pointer;
}

.story-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.story-card h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

.story-meta {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.story-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.tag {
    padding: 0.25rem 0.75rem;
    background: var(--background);
    border-radius: 12px;
    font-size: 0.8rem;
    color: var(--text-light);
}

.story-excerpt {
    color: var(--text-color);
    margin-bottom: 1rem;
    line-height: 1.6;
}

.read-more {
    display: inline-block;
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s;
}

.read-more:hover {
    color: var(--primary-color);
}

/* Series Badge */
.series-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--accent-color);
    color: white;
    border-radius: 12px;
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
}

/* Story Content */
.story-header {
    background: var(--white);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.story-header h2 {
    font-size: 2.5rem;
    color: var(--extra-color);
    margin-bottom: 1rem;
}

/* Chapter Navigation */
.chapter-nav {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.chapter-nav h4 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.chapter-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chapter-item {
    padding: 0.75rem 1rem;
    background: var(--background);
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chapter-item:hover {
    background: var(--accent-color);
    color: white;
}

.chapter-item.active {
    background: var(--accent-color);
    color: white;
    font-weight: 600;
}

.chapter-item.read {
    opacity: 0.6;
}

/* Series Navigation */
.series-nav {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.series-nav h4 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.series-links {
    display: flex;
    gap: 1rem;
    justify-content: space-between;
}

.series-link {
    flex: 1;
    padding: 1rem;
    background: var(--background);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-color);
    transition: var(--transition);
    text-align: center;
}

.series-link:hover {
    background: var(--accent-color);
    color: white;
}

.series-link.disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* Reading Mode Controls */
.reading-controls {
    background: var(--white);
    padding: 1rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    align-items: center;
}

.reading-mode-btn {
    padding: 0.5rem 1rem;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-color);
}

.reading-mode-btn:hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.reading-mode-btn.active {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

/* Focus Mode */
body.focus-mode header,
body.focus-mode nav,
body.focus-mode footer,
body.focus-mode .pagination,
body.focus-mode .chapter-nav,
body.focus-mode .series-nav,
body.focus-mode .reading-controls,
body.focus-mode .story-header .story-meta {
    display: none !important;
}

body.focus-mode .story-content {
    max-width: 800px;
    margin: 2rem auto;
    padding: 3rem;
}

body.focus-mode main {
    padding: 0;
}

/* Fullscreen Mode */
body.fullscreen-mode {
    overflow: hidden;
}

body.fullscreen-mode main {
    height: 100vh;
    overflow-y: auto;
    padding: 2rem 0;
}

/* Story Content */
.story-content {
    background: var(--white);
    padding: 3rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.story-page {
    display: none;
    animation: fadeIn 0.5s;
}

.story-page.active {
    display: block;
}

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

.story-page p {
    font-size: 1.1rem;
    line-height: var(--line-height);
    margin-bottom: 1.5rem;
    text-align: justify;
}

/* Pagination Controls */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--white);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.pagination-info {
    color: var(--text-light);
    font-size: 0.9rem;
}

.pagination-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.pagination button {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background: var(--white);
    color: var(--text-color);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s;
    font-size: 0.9rem;
}

.pagination button:hover:not(:disabled) {
    background: var(--accent-color);
    color: var(--white);
    border-color: var(--accent-color);
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination .page-numbers {
    display: flex;
    gap: 0.25rem;
}

.pagination .page-number {
    padding: 0.5rem 0.75rem;
}

.pagination .page-number.active {
    background: var(--accent-color);
    color: var(--white);
    border-color: var(--accent-color);
}

/* Page Progress Bar */
.progress-bar {
    width: 100%;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    margin-bottom: 2rem;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent-color);
    transition: width 0.3s ease;
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 50px;
    height: 50px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
    z-index: 500;
}

.back-to-top.visible {
    display: flex;
}

.back-to-top:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Footer */
footer {
    background-color: var(--primary-color);
    color: var(--text-color);
    padding: 2rem 0;
    margin-top: 4rem;
    text-align: center;
}

/* Bookmark Indicator */
.bookmark-indicator {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    background: var(--white);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    font-size: 0.9rem;
    color: var(--text-color);
    display: none;
    z-index: 500;
}

.bookmark-indicator.visible {
    display: block;
    animation: slideIn 0.3s;
}

@keyframes slideIn {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    header .container {
        flex-direction: column;
        gap: 1rem;
    }

    header h1 {
        font-size: 2rem;
    }

    .settings-panel {
        width: 100%;
        right: -100%;
    }

    nav .container {
        flex-direction: column;
        gap: 1rem;
    }

    .search-container {
        max-width: 100%;
    }

    .story-grid {
        grid-template-columns: 1fr;
    }

    .story-content {
        padding: 1.5rem;
    }

    .story-page p {
        font-size: 1rem;
    }

    .pagination {
        flex-direction: column;
        gap: 1rem;
    }

    .pagination-controls {
        flex-wrap: wrap;
        justify-content: center;
    }

    .reading-controls {
        flex-direction: column;
        gap: 0.5rem;
    }

    .series-links {
        flex-direction: column;
    }

    .back-to-top {
        bottom: 1rem;
        right: 1rem;
        width: 45px;
        height: 45px;
    }

    .bookmark-indicator {
        bottom: 1rem;
        left: 1rem;
        font-size: 0.8rem;
    }
}

/* Touch Gestures - Visual Feedback */
.story-content.swiping-left {
    transform: translateX(-20px);
    transition: transform 0.2s;
}

.story-content.swiping-right {
    transform: translateX(20px);
    transition: transform 0.2s;
}

/* Print Styles */
@media print {
    header, nav, footer, .pagination, .back-to-top, .settings-button, .reading-controls {
        display: none !important;
    }

    .story-content {
        box-shadow: none;
        padding: 0;
    }

    .story-page {
        display: block !important;
        page-break-after: always;
    }
}
