/* Basic Reset & Body Styling */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #fff; /* White background */
    color: #333; /* Dark gray text */
    line-height: 1.6;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 15px;
    padding-bottom: 80px; /* Add space for fixed bottom navigation */
}

/* Header & Navigation (top) */
header {
    background-color: #f8f8f8; /* Light gray header */
    padding: 15px;
    border-bottom: 1px solid #eee;
    text-align: center;
}

header h1 {
    margin: 0;
    color: #333;
}

nav {
    margin-top: 10px;
}

nav a {
    color: #007bff; /* Blue links */
    text-decoration: none;
    margin: 0 10px;
    font-weight: 500;
}

nav a:hover {
    text-decoration: underline;
}

/* Main Content */
main {
    padding: 20px 0;
}

/* Book List */
.book-list {
    list-style: none;
    padding: 0;
}

.book-list li {
    background-color: #f9f9f9;
    border: 1px solid #eee;
    margin-bottom: 10px;
    padding: 15px;
    border-radius: 5px;
}

.book-list li a {
    color: #333;
    text-decoration: none;
    display: block;
    font-size: 1.1em;
}

.book-list li a:hover {
    color: #007bff;
}

/* Upload Form */
.upload-form {
    display: flex;
    flex-direction: column;
    max-width: 400px;
    margin: 20px auto;
    padding: 20px;
    border: 1px solid #eee;
    border-radius: 5px;
    background-color: #f9f9f9;
}

.upload-form label {
    margin-bottom: 8px;
    font-weight: 500;
}

.upload-form input[type="file"] {
    margin-bottom: 15px;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.upload-form button {
    background-color: #007bff;
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
}

.upload-form button:hover {
    background-color: #0056b3;
}

/* EPUB Viewer */
.epub-viewer {
    width: 100%;
    height: calc(100vh - 160px); /* Adjust height to account for header and new bottom navigation */
    border: 1px solid #ccc;
    background-color: #fdfdfd;
    overflow: hidden; /* Important for epub.js */
    margin-bottom: 15px;
}

/* EPUB.js specific styling to make it look clean */
.epub-viewer iframe {
    border: none;
}

/* --- New Navigation Bottom Section --- */
.navigation-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: #333; /* Dark background for controls */
    color: white;
    padding: 10px 15px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column; /* Stack controls vertically on small screens */
    align-items: center;
    justify-content: center;
    border-top: 1px solid #555;
    z-index: 1000; /* Ensure it stays on top */
}

#page-progress-container {
    display: flex;
    align-items: center;
    width: 100%;
    margin-bottom: 10px; /* Space between slider and buttons */
}

#page-indicator {
    white-space: nowrap; /* Prevent text wrapping */
    margin-right: 10px;
    font-size: 0.9em;
    min-width: 80px; /* Give it some space */
    text-align: right;
}

#page-slider {
    flex-grow: 1; /* Take up remaining space */
    -webkit-appearance: none; /* Remove default styling for Chrome/Safari */
    width: 100%;
    height: 8px;
    background: #555;
    outline: none;
    opacity: 0.7;
    -webkit-transition: .2s;
    transition: opacity .2s;
    border-radius: 4px;
}

#page-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
}

#page-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
}

/* Controls for Reader */
.controls {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 300px; /* Limit button width for better mobile layout */
}

.nav-button {
    background-color: #007bff; /* Blue buttons */
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    flex: 1; /* Make buttons take equal space */
    margin: 0 5px; /* Space between buttons */
}

.nav-button:hover {
    background-color: #0056b3;
}

/* Footer */
footer {
    text-align: center;
    padding: 15px;
    margin-top: 30px; /* This will be pushed up by fixed footer */
    border-top: 1px solid #eee;
    color: #777;
    font-size: 0.9em;
}

/* Flash Messages */
.flashes {
    list-style: none;
    padding: 0;
    margin: 15px 0;
}

.flashes li {
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 4px;
    font-weight: 500;
}

.flashes .success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.flashes .error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Responsive Adjustments for Mobile */
@media (max-width: 600px) {
    .container {
        padding: 10px;
        padding-bottom: 120px; /* More space for bottom navigation on very small screens */
    }
    header {
        padding: 10px;
    }
    header h1 {
        font-size: 1.5em;
    }
    nav a {
        margin: 0 5px;
        font-size: 0.9em;
    }
    .upload-form {
        margin: 10px auto;
        padding: 15px;
    }
    .book-list li {
        padding: 10px;
    }
    .epub-viewer {
        height: calc(100vh - 180px); /* Adjust height for mobile UI */
    }
    .navigation-bottom {
        padding: 10px 5px; /* Less padding on very small screens */
    }
    #page-progress-container {
        flex-direction: column; /* Stack indicator and slider on very small screens */
        margin-bottom: 5px;
    }
    #page-indicator {
        margin-right: 0;
        margin-bottom: 5px;
        text-align: center;
        width: 100%;
        min-width: unset;
    }
    .controls {
        flex-direction: row; /* Keep buttons side-by-side */
    }
    .nav-button {
        padding: 8px 10px;
        font-size: 0.9em;
        margin: 0 2px;
    }
}