/* Base Styles */
:root {
    --primary-color: #4361ee;
    --primary-hover: #3a56d4;
    --text-color: #333;
    --text-light: #666;
    --bg-color: #f8f9fa;
    --bg-secondary: #fff;
    --border-color: #e0e0e0;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --page-bg: #fff;
    --highlight-color: #ffdd00;
}

body.dark {
    --primary-color: #4361ee;
    --primary-hover: #3a56d4;
    --text-color: #f0f0f0;
    --text-light: #aaa;
    --bg-color: #121212;
    --bg-secondary: #1e1e1e;
    --border-color: #333;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    --page-bg: #1e1e1e;
    --highlight-color: #ffd000;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
    line-height: 1.6;
}

/* Header and Navigation */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background-color: var(--bg-secondary);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-icon {
    font-size: 1.8rem;
    color: var(--primary-color);
}

.logo-container h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.main-nav {
    display: flex;
    gap: 1rem;
}

.nav-btn {
    background: none;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-color);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
    text-decoration: none;
}

.nav-btn:hover {
    background-color: rgba(67, 97, 238, 0.1);
}

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

.container {
    max-width: 1400px; /* Increased max-width for two pages */
    margin: 2rem auto;
    padding: 0 20px;
    text-align: center;
}

/* Upload Page Styles */
#upload-container {
    background-color: var(--bg-secondary);
    padding: 3rem;
    border-radius: 12px;
    box-shadow: var(--shadow);
    max-width: 600px;
    margin: 4rem auto;
}

#upload-container h2 {
    margin-top: 0;
    font-size: 1.8rem;
}

#drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 3rem;
    margin-top: 1.5rem;
    cursor: pointer;
    transition: border-color 0.3s, background-color 0.3s;
}

#drop-zone.dragover {
    border-color: var(--primary-color);
    background-color: rgba(67, 97, 238, 0.05);
}

.drop-icon {
    font-size: 4rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

#loading-indicator {
    margin-top: 1.5rem;
    font-size: 1.2rem;
    color: var(--text-light);
}

/* Reader Styles */
.container.reader-mode {
    padding-bottom: 120px; /* Space for the fixed footer */
}

.reader-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 2rem 0;
    padding: 1rem;
    width: 100%;
    box-sizing: border-box;
}

/* **MODIFIED: Page layout container styles** */
.pages {
    display: flex;
    flex-wrap: nowrap;
    gap: 30px;
    justify-content: center;
    width: 100%;
    max-width: 100%;
}

.page {
    border: 1px solid var(--border-color);
    padding: 20px;
    height: calc(100vh - 250px);
    min-height: 500px;
    overflow: hidden;
    text-align: left;
    font-size: 18px;
    line-height: 1.6;
    background-color: var(--page-bg);
    border-radius: 8px;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

/* **NEW: Styles for single and two-page layouts** */
.single-page-layout .page {
    width: 90%;
    max-width: 800px;
    min-width: 300px;
}

.two-page-layout .page {
    width: 48%;
    max-width: 700px; /* Max width for each page in a pair */
    min-width: 300px;
}

.page-number {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--border-color);
}

.page-content {
    flex: 1;
    overflow: auto;
    padding: 10px;
    word-wrap: break-word;
}

/* PDF formatting styles */
.pdf-line, .pdf-list-item {
    line-height: 1.5;
}

/* Reader Footer Styles */
.reader-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--bg-secondary);
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.1);
    padding: 1rem 0;
    z-index: 1000;
}

body.dark .reader-footer {
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.3);
}

.controls {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    align-items: center;
}

.control-btn {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 3.5rem;
    height: 3.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-color);
    box-shadow: var(--shadow);
}

.control-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: scale(1);
}

.control-btn.primary {
    background-color: var(--primary-color);
    color: white;
    border: none;
    width: 4rem;
    height: 4rem;
    font-size: 1.4rem;
}

/* Speed Control Position */
.speed-toggle {
    position: relative;
}

.speed-control {
    position: absolute;
    bottom: 120%; /* Position above the speed button */
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--bg-secondary);
    border-radius: 8px;
    padding: 0.5rem;
    box-shadow: var(--shadow);
    width: 300px;
    z-index: 1001;
}

.speed-options {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
}

.speed-option {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.5rem;
    cursor: pointer;
    flex: 1;
    text-align: center;
    color: var(--text-color);
    transition: all 0.2s;
}

.speed-option:hover {
    background-color: rgba(67, 97, 238, 0.1);
}

.speed-option.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Highlight & Line Styles */
span.highlight {
    background-color: var(--highlight-color);
    color: #000;
    border-radius: 3px;
    padding: 0 2px;
}

body.dark span.highlight {
    background-color: #ffdd00;
    color: #000;
}

span.line {
    display: inline-block;
    width: 100%;
    padding: 2px 0;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

span.line:hover {
    background-color: rgba(67, 97, 238, 0.1);
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-header {
        padding: 0.5rem 1rem;
    }
    .page {
        height: calc(100vh - 220px);
    }
    .container.reader-mode {
        padding-bottom: 100px; /* Adjust footer space */
    }
    .reader-footer {
        padding: 0.5rem 0;
    }
}