body {
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #e0e0e0;
    font-family: Arial, sans-serif;
    overflow: hidden;
    position: relative;
}

.container {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    margin: 10px 0;
    width: 100%;
    height: 100vh;
    max-width: 98vw;
}

.sidebar-wrapper {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: 220px; /* Espacio para el contenido y el botón */
    z-index: 20;
}

.sidebar-content {
    width: 200px;
    height: 100vh;
    background-color: #e0e0e0; /* Igual al fondo del body y flipbook */
    border-right: 1px solid #ccc;
    padding: 20px;
    overflow-y: auto;
    box-sizing: border-box;
    transition: transform 0.3s ease-in-out;
}

.sidebar-content.collapsed {
    transform: translateX(-100%);
}

.sidebar-content h2 {
    margin-top: 0;
    font-size: 18px;
    color: #333;
    border-bottom: 1px solid #ddd;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
}

.download-full-btn, .download-chapter-btn {
    text-decoration: none;
    color: #007bff;
    transition: color 0.3s;
    display: flex;
    align-items: center;
}

.download-full-btn:hover, .download-chapter-btn:hover {
    color: #0056b3;
}

.download-icon {
    font-size: 16px;
    margin-left: 5px;
}

.sidebar-toggle {
    position: absolute;
    top: 50%;
    right: 0; /* Alineado al borde derecho del wrapper inicialmente */
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    z-index: 1000; /* Muy alto para asegurar visibilidad */
    transition: right 0.3s ease-in-out; /* Transición suave para el movimiento */
}

.sidebar-toggle.collapsed {
    right: calc(100% - 30px); /* Se mueve al borde izquierdo del wrapper cuando está colapsado */
}

.toggle-arrow {
    width: 30px;
    height: 30px;
    background-color: #007bff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.3s;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-arrow:hover {
    background-color: #0056b3;
}

.toggle-arrow::before {
    content: '';
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 6px 0 6px 10px;
    border-color: transparent transparent transparent white;
}

.toggle-arrow.collapsed::before {
    border-width: 6px 10px 6px 0;
    border-color: transparent white transparent transparent;
}

.chapter-menu {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

.chapter-menu li {
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chapter-menu a {
    text-decoration: none;
    color: #007bff;
    font-size: 14px;
    display: block;
    padding: 5px 10px;
    border-radius: 3px;
    transition: background-color 0.3s, color 0.3s;
}

.chapter-menu a:hover {
    background-color: #007bff;
    color: white;
}

.flipbook-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-left: 220px;
    width: calc(100% - 220px);
    height: 100vh;
    transition: margin-left 0.3s ease-in-out, width 0.3s ease-in-out;
}

.flipbook-container.expanded {
    margin-left: 0;
    width: 100%;
}

.controls {
    margin-top: 10px;
    margin-bottom: 10px;
    text-align: center;
    z-index: 10;
}

button {
    padding: 8px 16px;
    margin: 0 10px;
    font-size: 16px;
    cursor: not-allowed;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    transition: background-color 0.3s;
}

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

button:disabled {
    background-color: #cccc;
    cursor: pointer;
}

#flipbook {
    width: 95vw;
    height: 85vh;
    max-width: 1600px;
    max-height: 900px;
    background-color: #fff;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    overflow: hidden;
    position: relative;
    transition: width 0.5s ease-in-out, height 0.5s ease-in-out;
}

.page {
    width: 100%;
    height: 100%;
    background-color: white;
    border: none;
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #ffff;
    margin: 0;
    padding: 0;
}

.page img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    margin: 0;
}

.turn-page-wrapper {
    position: relative;
    margin: 0;
    padding: 0;
}

@media (max-width: 768px) {
    .container {
    flex-direction: column;
    }
    .sidebar-wrapper {
    position: relative;
    width: 100%;
    height: auto;
    }
    .sidebar-content {
    width: 100%;
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 1px solid #ccc;
    transform: translateX(0);
    }
    .sidebar-content.collapsed {
    height: 60px;
    overflow: hidden;
    }
    .sidebar-toggle {
    position: absolute;
    left: 50%;
    top: auto;
    bottom: 15px;
    transform: translateX(-50%);
    right: auto;
    }
    .sidebar-toggle.collapsed {
    left: 50%; /* Permanece centrado en móviles */
    right: auto;
    }
    .toggle-arrow::before {
    border-width: 10px 6px 0 6px;
    border-color: white transparent transparent transparent;
    }
    .toggle-arrow.collapsed::before {
    border-width: 0 6px 10px 6px;
    border-color: transparent transparent white transparent;

    }
    .flipbook-container {
    margin-left: 0;
    width: 100%;
    }
    .flipbook-container.expanded {
    margin-top: 60px;
    }
}
