﻿/* Viewer Container */
#viewer {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    background-color: transparent;
    transition: background-color 0.3s ease;
    touch-action: pan-y;
    /* Allow vertical pan, improve passive listener behavior */
}

#viewer.paginated-view {
    touch-action: pan-x;
    /* Paginated mode usually horizontal or tap */
}

/* Reader UI (Bars) */
.reader-ui {
    position: fixed;
    left: 0;
    width: 100%;
    background: var(--bg-color);
    z-index: 100;
    transition: transform 0.3s ease;
    border-color: var(--border-color);
}

/* Hidden bars handled via transform in top-bar/bottom-bar classes */

/* Top Bar */
.top-bar {
    top: 0;
    height: 60px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
    transform: translateY(0);
}

.top-bar.hidden {
    transform: translateY(-100%);
}

#book-title-display {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
    opacity: 0.8;
}

/* Bottom Bar */
.bottom-bar {
    bottom: 0;
    padding: 20px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    transform: translateY(0);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.bottom-bar.hidden {
    transform: translateY(100%);
}

/* Text Button (Back) */
.text-btn {
    width: auto;
    padding: 0 10px;
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--accent-color);
    border-radius: 8px;
}

.text-btn i {
    margin-right: 4px;
}

/* Controls */
.controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Premium Sliders */
.premium-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
    outline: none;
    margin: 15px 0;
}

[data-theme="dark"] .premium-slider {
    background: rgba(255, 255, 255, 0.1);
}

.premium-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--accent-color);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: transform 0.1s;
}

.premium-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

/* Touch Zones - Fix for Scrolling & Dragging */
#prev-page-zone,
#next-page-zone,
#menu-toggle-zone {
    position: absolute;
    top: 0;
    height: 100%;
    z-index: 5;
    pointer-events: none;
    /* Default for scrolling mode */
    touch-action: none;
    /* Prevent browser gestures on these specific zones when active */
}

.touch-zone {
    position: absolute;
    top: 60px;
    bottom: 80px;
    z-index: 50;
    display: block;
    pointer-events: none;
    /* Default to none to allow text interaction */
}

/* Enable pointer events only in paginated mode via JS or specific classes */
.paginated-view .touch-zone {
    pointer-events: auto;
}

.touch-zone.left {
    left: 0;
    width: 20%;
}

.touch-zone.right {
    right: 0;
    width: 20%;
}

.touch-zone.center {
    left: 20%;
    right: 20%;
    pointer-events: auto;
    /* Always allow center tap for UI toggle */
}

/* Full-Screen Settings */
.settings-full-view {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    color: var(--text-color);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    animation: slide-up 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.settings-full-view.hidden {
    display: none;
}

@keyframes slide-up {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
}

.settings-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
}

.settings-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: 80px;
}

.settings-section {
    margin-bottom: 30px;
}

.section-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-color-secondary);
    text-transform: uppercase;
    margin-bottom: 15px;
    letter-spacing: 0.5px;
}

.setting-item {
    margin-bottom: 20px;
}

.item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.95rem;
    font-weight: 500;
}

.item-header span {
    color: var(--accent-color);
    font-weight: 700;
}

.control-row {
    display: flex;
    align-items: center;
    gap: 15px;
}

.control-row input[type="range"] {
    flex: 1;
}

.circle-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.circle-btn:active {
    background: rgba(0, 0, 0, 0.05);
}

/* Theme Grid */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.theme-opt-large {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border: 2px solid transparent;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.03);
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
}

.theme-opt-large.active {
    border-color: var(--accent-color);
    background: rgba(var(--accent-color-rgb, 0, 0, 0), 0.05);
}

.theme-opt-large .preview {
    width: 100%;
    height: 40px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.theme-opt-large span {
    font-size: 0.8rem;
    font-weight: 600;
}

/* iOS Switch */
.setting-toggle-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.setting-toggle-item .info label {
    display: block;
    font-weight: 600;
    font-size: 0.95rem;
}

.setting-toggle-item .info p {
    font-size: 0.8rem;
    color: var(--text-color-secondary);
    margin-top: 4px;
    max-width: 80%;
}

.ios-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.ios-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.ios-switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 24px;
}

.ios-switch .slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.ios-switch input:checked+.slider {
    background-color: #4cd964;
}

.ios-switch input:checked+.slider:before {
    transform: translateX(20px);
}

.toc-modal {
    height: 60vh;
    display: flex;
    flex-direction: column;
    top: 50%;
    transform: translate(-50%, -50%) scale(1);
    bottom: auto;
}

.toc-modal.hidden {
    transform: translate(-50%, -50%) scale(0.95);
}

.settings-group {
    margin-bottom: 20px;
}

.settings-group:last-child {
    margin-bottom: 0;
}

.settings-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-color-secondary);
    margin-bottom: 10px;
    text-transform: uppercase;
}

/* Theme Toggles */
.theme-toggles {
    display: flex;
    background: rgba(0, 0, 0, 0.05);
    padding: 4px;
    border-radius: var(--radius-sm);
}

[data-theme="dark"] .theme-toggles {
    background: rgba(255, 255, 255, 0.1);
}

.theme-opt {
    flex: 1;
    padding: 8px;
    font-size: 0.9rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--text-color-secondary);
}

.theme-opt.active {
    background: #fff;
    color: #000;
    box-shadow: var(--shadow-sm);
    font-weight: 600;
}

[data-theme="dark"] .theme-opt.active {
    background: #444;
    color: #fff;
}

.theme-opt .circle {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.theme-opt.light .circle {
    background: #fff;
}

.theme-opt.sepia .circle {
    background: #f6f1d1;
}

.theme-opt.dark .circle {
    background: #1a1a1a;
}

/* Font Control */
.font-control {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.05);
    border-radius: var(--radius-sm);
    padding: 5px;
}

[data-theme="dark"] .font-control {
    background: rgba(255, 255, 255, 0.1);
}

.font-control button {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

/* TOC List */
.toc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

#toc-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
}

#toc-list li {
    padding: 12px 5px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    font-size: 0.95rem;
}

#toc-list li:hover {
    color: var(--accent-color);
}

/* Touch Zones (hidden by default, used if needed for overlay capture) */
.touch-zone {
    position: absolute;
    top: 60px;
    bottom: 80px;
    z-index: 50;
    display: block;
}

.touch-zone.left {
    left: 0;
    width: 25%;
}

.touch-zone.right {
    right: 0;
    width: 25%;
}

.touch-zone.center {
    left: 25%;
    right: 25%;
}