/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-color: #fafafa;
    --text-color: #2c3e50;
    --header-bg: #ffffff;
    --nav-bg: #ffffff;
    --nav-border: #e0e0e0;
    --button-hover: #f5f5f5;
    --shadow: rgba(0, 0, 0, 0.1);
    --accent-color: #3498db;
    --input-bg: #ffffff;
    --input-border: #ddd;
}

body {
    font-family: 'Georgia', serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.8;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Theme Variations */
body.sepia {
    --bg-color: #f4ecd8;
    --text-color: #5c4a3a;
    --header-bg: #f9f3e3;
    --nav-bg: #f9f3e3;
    --nav-border: #d8cdb5;
    --button-hover: #efe4cc;
    --shadow: rgba(92, 74, 58, 0.1);
    --input-bg: #f9f3e3;
    --input-border: #d8cdb5;
}

body.dark {
    --bg-color: #1a1a1a;
    --text-color: #e4e4e4;
    --header-bg: #2c2c2c;
    --nav-bg: #2c2c2c;
    --nav-border: #404040;
    --button-hover: #383838;
    --shadow: rgba(0, 0, 0, 0.3);
    --input-bg: #2c2c2c;
    --input-border: #404040;
}

/* Font Family Classes */
body.font-serif {
    font-family: 'Georgia', serif;
}

body.font-sans-serif {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
}

body.font-georgia {
    font-family: 'Georgia', 'Times New Roman', serif;
}

body.font-palatino {
    font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, serif;
}

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

/* Global Language Switcher (Top-Right) */
.global-lang-switcher {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
}

.global-language-select {
    padding: 0.5rem 0.75rem;
    background: var(--header-bg);
    border: 2px solid var(--accent-color);
    border-radius: 6px;
    color: var(--text-color);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px var(--shadow);
}

.global-language-select:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

.global-language-select:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

/* URL Input Section */
.url-input-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, var(--bg-color) 0%, var(--button-hover) 100%);
}

.url-input-container {
    max-width: 600px;
    width: 100%;
    background: var(--header-bg);
    padding: 3rem;
    border-radius: 16px;
    box-shadow: 0 10px 40px var(--shadow);
}

.url-input-container h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    text-align: center;
    color: var(--accent-color);
}

.subtitle {
    text-align: center;
    color: var(--text-color);
    opacity: 0.7;
    margin-bottom: 2rem;
}

.input-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.url-input {
    flex: 1;
    padding: 1rem 1.5rem;
    border: 2px solid var(--input-border);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--input-bg);
    color: var(--text-color);
    transition: all 0.3s ease;
}

.url-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.load-button {
    padding: 1rem 2rem;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.load-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.load-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.features {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin: 1.5rem 0;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    background: var(--bg-color);
    border-radius: 6px;
    font-size: 0.9rem;
}

.feature-icon {
    font-size: 1.25rem;
}

.keyboard-hint {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--bg-color);
    border-radius: 6px;
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-color);
    opacity: 0.7;
}

.hint-icon {
    font-size: 1.2rem;
}

.supported-sites {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-color);
    opacity: 0.6;
    padding-top: 1rem;
    border-top: 1px solid var(--nav-border);
}

.social-proof {
    margin: 1.5rem 0;
    padding: 1.5rem;
    background: var(--bg-color);
    border-radius: 8px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    text-align: center;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent-color);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-color);
    opacity: 0.7;
    font-weight: 500;
}

.donate-section {
    margin: 1.5rem 0;
    padding: 1.5rem 0;
    border-top: 1px solid var(--nav-border);
    display: flex;
    justify-content: center;
}

.donate-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.donate-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.donate-button svg {
    animation: heartbeat 1.5s ease-in-out infinite;
}

@keyframes heartbeat {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

.footer-info {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--nav-border);
    text-align: center;
}

.footer-info .version {
    font-size: 0.85rem;
    color: var(--text-color);
    opacity: 0.6;
    margin-bottom: 0.5rem;
}

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

.footer-info .contact a {
    color: var(--accent-color);
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.footer-info .contact a:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.help-text {
    font-size: 0.85rem;
    color: var(--text-color);
    opacity: 0.65;
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-color);
    border-radius: 6px;
    border-left: 3px solid var(--accent-color);
    font-style: italic;
}

.language-switcher {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--nav-border);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.lang-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-color);
    justify-content: center;
}

.lang-label svg {
    color: var(--accent-color);
}

.language-select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--input-bg);
    border: 2px solid var(--nav-border);
    border-radius: 8px;
    color: var(--text-color);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.language-select:hover {
    border-color: var(--accent-color);
}

.language-select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.language-select-footer {
    padding: 0.25rem 0.5rem;
    background: var(--nav-bg);
    border: 1px solid var(--nav-border);
    border-radius: 4px;
    color: var(--text-color);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.language-select-footer:hover {
    border-color: var(--accent-color);
    background: var(--button-hover);
}

.language-select-footer:focus {
    outline: none;
    border-color: var(--accent-color);
}

/* Error Toast */
.error-toast {
    position: fixed;
    top: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(-150%);
    background: #ff4757;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(255, 71, 87, 0.3);
    z-index: 10000;
    transition: transform 0.3s ease;
    max-width: 90%;
    width: auto;
}

.error-toast.show {
    transform: translateX(-50%) translateY(0);
}

.error-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.error-icon {
    font-size: 1.5rem;
}

.error-message {
    flex: 1;
    font-weight: 500;
}

.error-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.error-close:hover {
    opacity: 1;
}

.recent-links {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.recent-link-item {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: var(--bg-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.recent-link-item:hover {
    background: var(--button-hover);
    transform: translateX(4px);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 9999;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-overlay p {
    color: white;
    margin-top: 1rem;
    font-size: 1.1rem;
}

/* Header */
.header {
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--nav-border);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px var(--shadow);
}

.header-content {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.back-button {
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid var(--nav-border);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-color);
    transition: all 0.2s ease;
    font-weight: 500;
}

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

.home-text {
    font-size: 0.95rem;
}

.header-text {
    flex: 1;
}

.book-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-color);
}

.chapter-info {
    font-size: 0.95rem;
    color: var(--accent-color);
    opacity: 0.8;
}

/* Reading Area */
.reading-area {
    flex: 1;
    padding: 3rem 2rem;
    display: flex;
    justify-content: center;
}

.content {
    max-width: 800px;
    width: 100%;
    font-size: 18px;
    line-height: 1.8;
}

.content p {
    margin-bottom: 1.5em;
    text-align: justify;
}

.content h2,
.content h3 {
    margin: 2em 0 1em;
    font-weight: 600;
}

.loading {
    text-align: center;
    padding: 4rem 0;
    color: var(--accent-color);
    font-style: italic;
}

/* Navigation */
.navigation {
    background-color: var(--nav-bg);
    border-top: 1px solid var(--nav-border);
    padding: 1.5rem 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    position: sticky;
    bottom: 0;
    box-shadow: 0 -2px 8px var(--shadow);
}

.nav-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: 2px solid var(--nav-border);
    border-radius: 8px;
    color: var(--text-color);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.nav-button:hover:not(:disabled) {
    background-color: var(--button-hover);
    border-color: var(--accent-color);
    transform: translateY(-2px);
}

.nav-button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.chapter-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chapter-list-btn {
    padding: 0.75rem;
    background: transparent;
    border: 2px solid var(--nav-border);
    border-radius: 8px;
    color: var(--text-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chapter-list-btn:hover {
    background: var(--button-hover);
    border-color: var(--accent-color);
}

/* Settings */
.settings-toggle {
    position: fixed;
    bottom: 120px;
    right: 2rem;
    width: 50px;
    height: 50px;
    background-color: var(--accent-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px var(--shadow);
    transition: all 0.3s ease;
    z-index: 1001;
}

.settings-toggle:hover {
    transform: scale(1.1) rotate(90deg);
}

.settings-toggle svg {
    color: white;
}

.settings-panel {
    position: fixed;
    top: 50%;
    right: 2rem;
    transform: translateY(-50%) translateX(120%);
    background-color: var(--header-bg);
    border: 1px solid var(--nav-border);
    border-radius: 12px;
    padding: 2rem;
    width: 300px;
    box-shadow: 0 8px 24px var(--shadow);
    transition: transform 0.3s ease;
    z-index: 1002;
}

.settings-panel.active {
    transform: translateY(-50%) translateX(0);
}

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

.setting-group {
    margin-bottom: 1.5rem;
}

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

.setting-group input[type="range"] {
    width: 100%;
    margin-bottom: 0.25rem;
}

.setting-group select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--nav-border);
    border-radius: 6px;
    background-color: var(--input-bg);
    color: var(--text-color);
    font-family: inherit;
    font-size: 0.95rem;
}

.setting-group span {
    font-size: 0.85rem;
    color: var(--accent-color);
}

/* Reader Footer */
.reader-footer {
    background-color: var(--header-bg);
    border-top: 1px solid var(--nav-border);
    padding: 1rem 2rem;
    margin-top: 2rem;
}

.footer-content {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--text-color);
    opacity: 0.7;
}

.divider {
    opacity: 0.5;
}

.email-link {
    color: var(--accent-color);
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.email-link:hover {
    opacity: 1;
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 768px) {
    .url-input-container {
        padding: 2rem 1.5rem;
    }

    .url-input-container h1 {
        font-size: 2rem;
    }

    .input-group {
        flex-direction: column;
    }

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

    .features {
        grid-template-columns: 1fr;
        gap: 0.5rem;
        margin: 1rem 0;
    }

    .feature-item {
        padding: 0.5rem 0.6rem;
        font-size: 0.85rem;
    }

    .feature-icon {
        font-size: 1.1rem;
    }

    .header {
        padding: 1rem 1.5rem;
    }

    .book-title {
        font-size: 1.2rem;
    }

    .reading-area {
        padding: 2rem 1.5rem;
    }

    .content {
        font-size: 16px;
    }

    .navigation {
        gap: 0.5rem;
        padding: 1rem 1.5rem;
    }

    .nav-button span {
        display: none;
    }

    .nav-button {
        padding: 0.75rem;
        min-width: 48px;
        justify-content: center;
    }

    .settings-toggle {
        bottom: 100px;
        right: 1rem;
        width: 45px;
        height: 45px;
    }

    .settings-panel {
        right: 1rem;
        width: 280px;
    }

    .home-text {
        display: none;
    }

    .back-button {
        padding: 0.5rem;
    }

    .footer-content {
        flex-direction: column;
        gap: 0.5rem;
    }

    .divider {
        display: none;
    }

    .language-select {
        font-size: 0.9rem;
        padding: 0.6rem 0.8rem;
    }

    .global-lang-switcher {
        top: 0.5rem;
        right: 0.5rem;
    }

    .global-language-select {
        font-size: 0.85rem;
        padding: 0.4rem 0.6rem;
    }

    .keyboard-hint {
        font-size: 0.75rem;
    }

    .stats {
        gap: 0.5rem;
    }

    .stat-number {
        font-size: 1.5rem;
    }

    .donate-button {
        font-size: 0.9rem;
        padding: 0.65rem 1.5rem;
    }
}

/* Print Styles */
@media print {

    .header,
    .navigation,
    .settings-toggle,
    .settings-panel,
    .url-input-section,
    .reader-footer {
        display: none !important;
    }

    .reading-area {
        padding: 0;
    }

    .content {
        max-width: 100%;
    }

    body {
        background: white;
        color: black;
    }
}

/* Selection Color */
::selection {
    background-color: var(--accent-color);
    color: white;
}

html {
    scroll-behavior: smooth;
}